相机添加矫正文件,链接输出图像

master
zhou.mengjia 2 years ago
parent 1702a988fb
commit 71163a60e3

3
.gitignore vendored

@ -3,3 +3,6 @@
/tpvs17/SmokeBoxIdentification/x64
/tpvs17/numStatisticAlgo/x64
/tpvs17/lpSerial/x64
/runner17/Release/fileData
/runner17/Release/log
/runner17/Release/templateNum

@ -1,222 +0,0 @@
{
"devices": {
"LP-OCM-R060GC 00J50359918": {
"algorithm": 1,
"algorithm_dll": 1,
"auto_open": false,
"auto_push": true,
"balanceRatio": 1868,
"balanceRatioSelector": 0,
"board_config_file": "",
"board_name": "",
"board_num": 0,
"board_type": 64,
"camera_file": "",
"exposure": 50000,
"folder": "model5\\",
"format": "None",
"frame_rate": 7.400000095367432,
"gain": 1.0052000284194946,
"height": 2048,
"id": 5,
"loop": 1,
"mac_address": "",
"offset_x": 0,
"offset_y": 0,
"param_policy": 2,
"rely_on_camera": "",
"rotation_angle": 90,
"save": 0,
"save_img_suffix": ".JPG",
"savefile_rgb_swapped": false,
"showname": "相机五",
"trigger_source": "Line0",
"type": 140,
"width": 3072,
"zoom": 1
},
"LP-OCM-R060GC 00J50359922": {
"algorithm": 1,
"algorithm_dll": 1,
"auto_open": false,
"auto_push": true,
"balanceRatio": 0,
"balanceRatioSelector": 0,
"board_config_file": "",
"board_name": "",
"board_num": 0,
"board_type": 64,
"camera_file": "",
"exposure": 25000,
"folder": "model1\\",
"format": "None",
"frame_rate": 9.3,
"gain": 1,
"height": 2048,
"id": 1,
"loop": 1,
"mac_address": "",
"offset_x": 0,
"offset_y": 0,
"param_policy": 2,
"rely_on_camera": "",
"rotation_angle": 0,
"save": 1,
"save_img_suffix": ".JPG",
"savefile_rgb_swapped": false,
"showname": "相机一",
"trigger_source": "Line0",
"type": 140,
"width": 3072,
"zoom": 1
},
"LP-OCM-R060GC 00J50359923": {
"algorithm": 1,
"algorithm_dll": 1,
"auto_open": false,
"auto_push": true,
"balanceRatio": 0,
"balanceRatioSelector": 0,
"board_config_file": "",
"board_name": "",
"board_num": 0,
"board_type": 64,
"camera_file": "",
"exposure": 25000,
"folder": "model4\\",
"format": "None",
"frame_rate": 7.400000095367432,
"gain": 0,
"height": 2048,
"id": 4,
"loop": 1,
"mac_address": "",
"offset_x": 0,
"offset_y": 0,
"param_policy": 2,
"rely_on_camera": "",
"rotation_angle": 0,
"save": 1,
"save_img_suffix": ".JPG",
"savefile_rgb_swapped": false,
"showname": "相机四",
"trigger_source": "Line0",
"type": 140,
"width": 3072,
"zoom": 1
},
"LP-OCM-R060GC 00J50359927": {
"algorithm": 1,
"algorithm_dll": 1,
"auto_open": false,
"auto_push": true,
"balanceRatio": 0,
"balanceRatioSelector": 0,
"board_config_file": "",
"board_name": "",
"board_num": 0,
"board_type": 64,
"camera_file": "",
"exposure": 25000,
"folder": "model2\\",
"format": "None",
"frame_rate": 7.400000095367432,
"gain": 0,
"height": 2048,
"id": 2,
"loop": 1,
"mac_address": "",
"offset_x": 0,
"offset_y": 0,
"param_policy": 2,
"rely_on_camera": "",
"rotation_angle": 0,
"save": 1,
"save_img_suffix": ".JPG",
"savefile_rgb_swapped": false,
"showname": "相机二",
"trigger_source": "Line0",
"type": 140,
"width": 3072,
"zoom": 1
},
"LP-OCM-R060GC 00J50359938": {
"algorithm": 1,
"algorithm_dll": 1,
"auto_open": false,
"auto_push": true,
"balanceRatio": 0,
"balanceRatioSelector": 0,
"board_config_file": "",
"board_name": "",
"board_num": 0,
"board_type": 64,
"camera_file": "",
"exposure": 25000,
"folder": "model3\\",
"format": "None",
"frame_rate": 7.400000095367432,
"gain": 0,
"height": 2048,
"id": 3,
"loop": 1,
"mac_address": "",
"offset_x": 0,
"offset_y": 0,
"param_policy": 2,
"rely_on_camera": "",
"rotation_angle": 0,
"save": 1,
"save_img_suffix": ".JPG",
"savefile_rgb_swapped": false,
"showname": "相机三",
"trigger_source": "Line0",
"type": 140,
"width": 3072,
"zoom": 1
},
"LP-OCM-R060GC 00J50359945": {
"algorithm": 1,
"algorithm_dll": 1,
"auto_open": false,
"auto_push": true,
"balanceRatio": 0,
"balanceRatioSelector": 0,
"board_config_file": "",
"board_name": "",
"board_num": 0,
"board_type": 64,
"camera_file": "",
"exposure": 50000,
"folder": "model6\\",
"format": "None",
"frame_rate": 7.400000095367432,
"gain": 0,
"height": 2048,
"id": 6,
"loop": 1,
"mac_address": "",
"offset_x": 0,
"offset_y": 0,
"param_policy": 2,
"rely_on_camera": "",
"rotation_angle": 270,
"save": 0,
"save_img_suffix": ".JPG",
"savefile_rgb_swapped": false,
"showname": "相机六",
"trigger_source": "Line0",
"type": 140,
"width": 3072,
"zoom": 1
}
},
"top": {
"startID": 5,
"endID": 6
},
"side": {
"startID": 1,
"endID": 4
}
}

@ -26,6 +26,7 @@
"param_policy": 2,
"rely_on_camera": "",
"rotation_angle": 0,
"calib_file": ".\\config\\right.calib",
"save": 1,
"save_img_suffix": ".BMP",
"savefile_rgb_swapped": false,

@ -0,0 +1,38 @@
{
"IsCalibrated": "true",
"CalibCameraModel": "NPoints",
"RMSErr": 0.0,
"errorMsg": "",
"PerspectiveScale": 1.0,
"PerspectiveShift": [ 0.0, 0.0 ],
"PixelStage": "PerspectiveTransform",
"imgSize": [ 0, 0 ],
"interpolationFlags": 2,
"useCache": 1,
"EnablePostTransform": "true",
"OriginPosition": [ 0.0, 0.0, 0.0 ],
"OriginAngle": [ 0.0, 0.0, 0.0 ],
"CustmizedMat": {
"type_id": "opencv-matrix",
"rows": 0,
"cols": 0,
"dt": "u",
"data": []
},
"ImgPoints": "$base64$MmYgICAgICAgICAgICAgICAgICAgICAgNdGuRJH4zEMVSqxEObOCRDJU/kSELIJE5JvyRJH4zEM=",
"WorldPoints": "$base64$M2YgICAgICAgICAgICAgICAgICAgICAgAAAAAAAAAAAAAAAAAAAAAAAAIEEAAAAAAAAgQQAAIEEAAAAAAAAgQQAAAAAAAAAA",
"mappingMat": {
"type_id": "opencv-matrix",
"rows": 3,
"cols": 3,
"dt": "d",
"data": "$base64$MWQgICAgICAgICAgICAgICAgICAgICAg67eUKF9jlT9vPaxiI8ZFPzFfmJnGez3AfSIv17w+IbzMdBp71TmWP29BqruqyyHAeG3NzG0b6L5Z9/IBqso4PwAAAAAAAPA/"
},
"invMappingMat": {
"type_id": "opencv-matrix",
"rows": 3,
"cols": 3,
"dt": "d",
"data": "$base64$MWQgICAgICAgICAgICAgICAgICAgICAgtDP7m75GSECGIhv+8+I2wHfIlXZ0L5NAsIuu9q5ayT9nZBx+j+VDQGQB7VSefnZAx/8eTZaqPz90smOCS16PvxuncOdEGOw/"
}
}

@ -1,73 +1,44 @@
Info | 2024-01-09 18:16:14 周二 | initCamera
Debug | 2024-01-09 18:16:14 周二 | Decode smokeInfo from "D:/Code/Logistics/smokeboxidentification/runner17/Release\\user\\smokeInfo.xlsx" successed
Debug | 2024-01-09 18:16:14 周二 | "D:/Code/Logistics/smokeboxidentification/runner17/Release\\templateNum" has not folder
Debug | 2024-01-09 18:16:15 周二 | Find device: "00787720450"
Debug | 2024-01-09 18:16:15 周二 | m_vecPCamera size: 1
Warning | 2024-01-09 18:16:15 周二 | QObject::moveToThread: Cannot move objects with a parent
Debug | 2024-01-09 18:16:16 周二 | init CategoryMatcher successed
Debug | 2024-01-09 18:16:16 周二 | NetControl::onConnected
Info | 2024-01-09 18:47:06 周二 | initCamera
Debug | 2024-01-09 18:47:06 周二 | Decode smokeInfo from "D:/Code/Logistics/smokeboxidentification/runner17/Release\\user\\smokeInfo.xlsx" successed
Debug | 2024-01-09 18:47:06 周二 | "D:/Code/Logistics/smokeboxidentification/runner17/Release\\templateNum" has not folder
Debug | 2024-01-09 18:47:06 周二 | Find device: "00787720450"
Debug | 2024-01-09 18:47:06 周二 | m_vecPCamera size: 1
Warning | 2024-01-09 18:47:06 周二 | QObject::moveToThread: Cannot move objects with a parent
Debug | 2024-01-09 18:47:06 周二 | init CategoryMatcher successed
Debug | 2024-01-09 18:47:06 周二 | NetControl::onConnected
TPTcpClient::slotConnected
Debug | 2024-01-09 18:16:16 周二 | 网络连接成功!!!
Debug | 2024-01-09 18:16:16 周二 | Open camera: "00787720450" successed
Debug | 2024-01-09 18:16:16 周二 | Start camera: "00787720450" successed
Debug | 2024-01-09 18:16:16 周二 | Set device successed
Debug | 2024-01-09 18:16:16 周二 | Set camera: "00787720450" software trigger successed
Warning | 2024-01-09 18:16:18 周二 | i receive data from server: "GP&6&111&2121&1&310102&25>"
Debug | 2024-01-09 18:16:18 周二 | msg: "GP&6&111&2121&1&310102&25>" content: "GP&6&111&2121&1&310102&25"
Debug | 2024-01-09 18:16:18 周二 | strlist length: 7 head: "GP"
Info | 2024-01-09 18:16:18 周二 | [captureSide]: Enter
Info | 2024-01-09 18:16:18 周二 | [onCapture]: Enter
Info | 2024-01-09 18:16:18 周二 | [onCapture]: cameraLocation = 0
Info | 2024-01-09 18:16:18 周二 | [onCapture]: Out
Debug | 2024-01-09 18:16:18 周二 | start capture, length: 1
Debug | 2024-01-09 18:16:18 周二 | convert Mat successed!
Debug | 2024-01-09 18:16:18 周二 | 不旋转
Debug | 2024-01-09 18:16:18 周二 | [Camera]: Side Camera Captured.
Debug | 2024-01-09 18:16:18 周二 | Save image: ".\\fileData\\intoStock\\1.BMP"
Debug | 2024-01-09 18:16:18 周二 | "Camera 00787720450 Match Start ..."
Info | 2024-01-09 18:16:18 周二 | "Camera 00787720450 SetImageData OK!"
Critical | 2024-01-09 18:16:18 周二 | strList.last() = "11"
Critical | 2024-01-09 18:16:18 周二 | jieduan = "1"
Critical | 2024-01-09 18:16:18 周二 | level = 1
Debug | 2024-01-09 18:16:18 周二 | Get TemplateImg OK!
Debug | 2024-01-09 18:16:18 周二 | templateLevel = 1
Info | 2024-01-09 18:16:18 周二 | level = 1
Info | 2024-01-09 18:16:18 周二 | templateImgPath = "./templateImg/310102/310102-11.bmp"
Debug | 2024-01-09 18:16:18 周二 | Level == 1
Info | 2024-01-09 18:16:19 周二 | valueMaxScore = 97.147
Info | 2024-01-09 18:16:19 周二 | indexMaxScore = true
Info | 2024-01-09 18:16:19 周二 | 5
Debug | 2024-01-09 18:16:19 周二 | "Camera 00787720450 Match successful!"
Info | 2024-01-09 18:16:19 周二 | fileName "1_310102_rlt.BMP"
Info | 2024-01-09 18:16:19 周二 | filePath ".\\fileData\\2121\\1_310102_rlt.BMP"
Warning | 2024-01-09 18:16:22 周二 | i receive data from server: "GP&6&111&2121&1&310102&25>"
Debug | 2024-01-09 18:16:22 周二 | msg: "GP&6&111&2121&1&310102&25>" content: "GP&6&111&2121&1&310102&25"
Debug | 2024-01-09 18:16:22 周二 | strlist length: 7 head: "GP"
Info | 2024-01-09 18:16:22 周二 | [captureSide]: Enter
Info | 2024-01-09 18:16:22 周二 | [onCapture]: Enter
Info | 2024-01-09 18:16:22 周二 | [onCapture]: cameraLocation = 0
Info | 2024-01-09 18:16:22 周二 | [onCapture]: Out
Debug | 2024-01-09 18:16:22 周二 | start capture, length: 1
Debug | 2024-01-09 18:16:22 周二 | convert Mat successed!
Debug | 2024-01-09 18:16:22 周二 | 不旋转
Debug | 2024-01-09 18:16:22 周二 | [Camera]: Side Camera Captured.
Debug | 2024-01-09 18:16:22 周二 | Save image: ".\\fileData\\intoStock\\1.BMP"
Debug | 2024-01-09 18:16:22 周二 | "Camera 00787720450 Match Start ..."
Info | 2024-01-09 18:16:22 周二 | "Camera 00787720450 SetImageData OK!"
Critical | 2024-01-09 18:16:22 周二 | strList.last() = "11"
Critical | 2024-01-09 18:16:22 周二 | jieduan = "1"
Critical | 2024-01-09 18:16:22 周二 | level = 1
Debug | 2024-01-09 18:16:22 周二 | Get TemplateImg OK!
Debug | 2024-01-09 18:16:22 周二 | templateLevel = 1
Info | 2024-01-09 18:16:22 周二 | level = 1
Info | 2024-01-09 18:16:22 周二 | templateImgPath = "./templateImg/310102/310102-11.bmp"
Debug | 2024-01-09 18:16:22 周二 | Level == 1
Info | 2024-01-09 18:16:22 周二 | valueMaxScore = 97.147
Info | 2024-01-09 18:16:22 周二 | indexMaxScore = true
Info | 2024-01-09 18:16:22 周二 | 5
Debug | 2024-01-09 18:16:22 周二 | "Camera 00787720450 Match successful!"
Info | 2024-01-09 18:16:22 周二 | fileName "1_310102_rlt.BMP"
Info | 2024-01-09 18:16:22 周二 | filePath ".\\fileData\\2121\\1_310102_rlt.BMP"
Debug | 2024-01-09 18:16:29 周二 | delete netControl
Debug | 2024-01-09 18:16:29 周二 | NetControl::onDisconnected
Debug | 2024-01-09 18:47:06 周二 | 网络连接成功!!!
Debug | 2024-01-09 18:47:08 周二 | Open camera: "00787720450" successed
Debug | 2024-01-09 18:47:08 周二 | Start camera: "00787720450" successed
Debug | 2024-01-09 18:47:08 周二 | Set device successed
Debug | 2024-01-09 18:47:08 周二 | Set camera: "00787720450" software trigger successed
Warning | 2024-01-09 18:47:10 周二 | i receive data from server: "GP&6&111&2121&1&310102&25>"
Debug | 2024-01-09 18:47:10 周二 | msg: "GP&6&111&2121&1&310102&25>" content: "GP&6&111&2121&1&310102&25"
Debug | 2024-01-09 18:47:10 周二 | strlist length: 7 head: "GP"
Info | 2024-01-09 18:47:10 周二 | [captureSide]: Enter
Info | 2024-01-09 18:47:10 周二 | [onCapture]: Enter
Info | 2024-01-09 18:47:10 周二 | [onCapture]: cameraLocation = 0
Info | 2024-01-09 18:47:10 周二 | [onCapture]: Out
Debug | 2024-01-09 18:47:10 周二 | start capture, length: 1
Debug | 2024-01-09 18:47:10 周二 | convert Mat successed!
Debug | 2024-01-09 18:47:10 周二 | 不旋转
Info | 2024-01-09 18:47:10 周二 | imgInfo.image.cols = 1920
Info | 2024-01-09 18:47:10 周二 | imgInfo.image.rows = 1200
Info | 2024-01-09 18:47:10 周二 | imgInfo.image.step = 1920
Info | 2024-01-09 18:47:10 周二 | imgInfo.imageOrigin == nullptr
Debug | 2024-01-09 18:47:10 周二 | [Camera]: Side Camera Captured.
Debug | 2024-01-09 18:47:10 周二 | Save image: ".\\fileData\\\\1.BMP"
Debug | 2024-01-09 18:47:10 周二 | "Camera 00787720450 Match Start ..."
Info | 2024-01-09 18:47:10 周二 | "Camera 00787720450 SetImageData OK!"
Critical | 2024-01-09 18:47:10 周二 | strList.last() = "11"
Critical | 2024-01-09 18:47:10 周二 | jieduan = "1"
Critical | 2024-01-09 18:47:10 周二 | level = 1
Debug | 2024-01-09 18:47:10 周二 | Get TemplateImg OK!
Debug | 2024-01-09 18:47:10 周二 | templateLevel = 1
Info | 2024-01-09 18:47:10 周二 | level = 1
Info | 2024-01-09 18:47:10 周二 | templateImgPath = "./templateImg/310102/310102-11.bmp"
Debug | 2024-01-09 18:47:10 周二 | Level == 1
Debug | 2024-01-09 18:47:11 周二 | "Level: 1 match failed!"
Debug | 2024-01-09 18:47:44 周二 | delete netControl
Debug | 2024-01-09 18:47:44 周二 | NetControl::onDisconnected
TPTcpClient::slotDisconnected

Binary file not shown.

@ -4,6 +4,9 @@
CameraControl::CameraControl()
{
m_calib = ILCalibNPointsPtr(__uuidof(LCalibNPoints));
m_calib->FixImageMode = LPVFixImageMode::LPVFixImageUndistortAndUntilt;
qRegisterMetaType<QVector<ImageInfo> >("QVector<ImageInfo>");
m_pobjThread = new QThread;
moveToThread(m_pobjThread);
@ -135,6 +138,8 @@ bool CameraControl::readCameraConfig(QString filePath)
cameraInfo.exposure = deviceObj.value("exposure").toDouble();
cameraInfo.imageHeight = deviceObj.value("height").toInt();
cameraInfo.imageWidth = deviceObj.value("width").toInt();
cameraInfo.calibFile = deviceObj.value("calib_file").toString();
m_calib->Load(cameraInfo.calibFile.toStdString().c_str());
cameraInfo.saveImgSuffix = deviceObj.value("save_img_suffix").toString();
int id = deviceObj.value("id").toInt();
if (deviceObj.contains("rotation_angle"))
@ -485,6 +490,16 @@ void CameraControl::capture(const QStringList& serialNumberList)
}
flipImg(capture(serialNumber), imgInfo.image, rotationAngle);
imgInfo.cameraSn = serialNumber;
if (imgInfo.imageOrigin == nullptr)
{
imgInfo.imageOrigin = ILImagePtr(__uuidof(LImage));
imgInfo.imageFixed = ILImagePtr(__uuidof(LImage));
}
imgInfo.imageOrigin->SetImageData(imgInfo.image.cols, imgInfo.image.rows, (void*)imgInfo.image.data, imgInfo.image.step, 0);
if (m_calib->IsCalibrated())
{
m_calib->FixImage(imgInfo.imageOrigin, imgInfo.imageFixed);
}
vecImageInfo.push_back(imgInfo);
}
emit sgCapturedImage(vecImageInfo, m_eCameraLocation);

@ -17,6 +17,7 @@ struct CameraInfo
int imageHeight; //高度
int rotationAngle{ 0 }; //旋轉角度
QString calibFile = ""; //标定文件地址
QString saveImgSuffix = ".bmp" ; //保存的图像格式
};
@ -31,6 +32,8 @@ struct FileInfo
struct ImageInfo
{
cv::Mat image;
ILImagePtr imageOrigin;
ILImagePtr imageFixed;
QString cameraSn;
FileInfo saveImgInfo;
};
@ -81,5 +84,7 @@ private:
QThread* m_pobjThread;
QMutex m_mutex;
ILCalibNPointsPtr m_calib;
};
#endif // !CAMERA_CONTROL_H

@ -239,15 +239,9 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector<ImageInfo>& ve
QString str = QString("Camera %1 Match Start ...").arg(imgInfo.cameraSn);
qDebug() << str;
if (!imgInfo.image.empty())
if (imgInfo.imageFixed->Height !=0 && imgInfo.imageFixed->Width!=0)
{
ILImagePtr image(__uuidof(LImage));
image->SetImageData(imgInfo.image.cols, imgInfo.image.rows, (void*)imgInfo.image.data, imgInfo.image.step, 0);
QString str = QString("Camera %1 SetImageData OK!").arg(imgInfo.cameraSn);
qInfo() << str;
image->Load("D:/Code/Logistics/smokeboxidentification/tpvs17/SmokeBoxIdentification/log/TestSave.bmp");
if (m_pCategoryMatcher->smokeMatch(typeNum, image))
if (m_pCategoryMatcher->smokeMatch(typeNum, imgInfo.imageFixed))
{
str = QString("Camera %1 Match successful!").arg(imgInfo.cameraSn);
qDebug() << str;

@ -28,8 +28,6 @@
#define NET_CONFIG "\\config\\netSetting.json"
#define COM_CONFIG "\\config\\comSetting.json"
#define MATCHER_CONFIG "\\config\\match.json"
#define CALIBRATION_LEFT "\\config\\left.calib"
#define CALIBRATION_RIGHT "\\config\\right.calib"
#define SMOKEINFO_XLSX_CONFIG "\\user\\smokeInfo.xlsx"

Loading…
Cancel
Save