feat: 添加点云着色按钮 适配调整后的下位机图像采集方式

This commit is contained in:
2026-02-02 14:08:30 +08:00
parent de8ce7c4a6
commit b1871aa9e7
11 changed files with 298 additions and 125 deletions

View File

@@ -94,7 +94,7 @@ void DeviceScanner::onReadyRead()
if (response.contains("D330M_CAMERA")) {
DeviceInfo device;
device.ipAddress = senderIp;
device.deviceName = "D330M Camera";
device.deviceName = "Camera";
device.port = SCAN_PORT;
device.responseTime = 0;

View File

@@ -96,9 +96,9 @@ void GVSPParser::handleLeaderPacket(const uint8_t *data, size_t size)
// 根据像素格式选择对应的状态
StreamState *state = nullptr;
if (pixelFormat == PIXEL_FORMAT_MONO16_LEFT) {
if (pixelFormat == PIXEL_FORMAT_MONO16_LEFT || pixelFormat == PIXEL_FORMAT_MONO8_LEFT) {
state = &m_leftIRState;
} else if (pixelFormat == PIXEL_FORMAT_MONO16_RIGHT) {
} else if (pixelFormat == PIXEL_FORMAT_MONO16_RIGHT || pixelFormat == PIXEL_FORMAT_MONO8_RIGHT) {
state = &m_rightIRState;
} else if (pixelFormat == PIXEL_FORMAT_MJPEG) {
state = &m_rgbState;
@@ -118,6 +118,9 @@ void GVSPParser::handleLeaderPacket(const uint8_t *data, size_t size)
if (pixelFormat == PIXEL_FORMAT_MJPEG) {
// MJPEG是压缩格式实际大小未知设置为0表示动态接收
state->expectedSize = 0;
} else if (pixelFormat == PIXEL_FORMAT_MONO8_LEFT || pixelFormat == PIXEL_FORMAT_MONO8_RIGHT) {
// 8-bit灰度格式下采样
state->expectedSize = imageWidth * imageHeight;
} else {
// 16-bit或12-bit灰度等固定格式
state->expectedSize = imageWidth * imageHeight * 2;
@@ -268,6 +271,29 @@ void GVSPParser::processImageData(GVSPParser::StreamState *state)
return;
}
// 处理Mono8格式左右红外相机下采样8位数据
if (state->pixelFormat == PIXEL_FORMAT_MONO8_LEFT) {
// 检查数据大小
if (state->dataBuffer.size() < state->expectedSize) {
return;
}
// 左红外8位数据
emit leftImageReceived(state->dataBuffer, state->blockId);
m_imageSequence++;
return;
}
if (state->pixelFormat == PIXEL_FORMAT_MONO8_RIGHT) {
// 检查数据大小
if (state->dataBuffer.size() < state->expectedSize) {
return;
}
// 右红外8位数据
emit rightImageReceived(state->dataBuffer, state->blockId);
m_imageSequence++;
return;
}
// 兼容旧版本使用序号区分legacy
if (state->pixelFormat == PIXEL_FORMAT_MONO16) {
// 检查数据大小

View File

@@ -134,23 +134,8 @@ bool NetworkManager::sendStopCommand()
bool NetworkManager::sendExposureCommand(int exposureTime)
{
// 同时发送结构光曝光命令UART控制激光器单位μs
QString exposureCommand = QString("EXPOSURE:%1").arg(exposureTime);
bool success1 = sendCommand(exposureCommand);
// 同时发送红外相机曝光命令通过触发脉冲宽度控制单位μs
// 下位机会将此值用作manual_trigger_pulse()的脉冲宽度参数
// 脉冲宽度直接决定相机的实际曝光时间
int irExposure = exposureTime;
// 限制在有效范围内1000μs ~ 100000μs避免脉冲太短导致相机无法触发
if (irExposure < 1000) irExposure = 1000;
if (irExposure > 100000) irExposure = 100000;
QString irExposureCommand = QString("IR_EXPOSURE:%1").arg(irExposure);
bool success2 = sendCommand(irExposureCommand);
return success1 && success2;
return sendCommand(exposureCommand);
}
// ========== 传输开关命令 ==========