|
|
@@ -38,8 +38,6 @@
|
|
|
#include <m_workthread.h>
|
|
|
#include <mserial.h>
|
|
|
#include <curl/curl.h>
|
|
|
-#include <iostream>
|
|
|
-#include <string>
|
|
|
#include <main.h>
|
|
|
#include <m_loger.h>
|
|
|
#include <QMessageBox>
|
|
|
@@ -105,6 +103,10 @@ extern "C" void Java_com_yfkj_cb_Q6iot_UvcCameraActivity_UvcHandle(JNIEnv* env,
|
|
|
env->ReleaseStringUTFChars(strData, strChars);
|
|
|
sender_custom.signalQStr(qstr);
|
|
|
qDebug() << "Received string data from Java:" << qstr;
|
|
|
+ if(qstr.contains("UVCFAILED"))
|
|
|
+ {
|
|
|
+ qDebug() << "相机打开失败!";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -271,8 +273,8 @@ Frames::Frames(QObject * parent)
|
|
|
this, &Frames::onFPSUpdated);
|
|
|
|
|
|
|
|
|
-// connect(this,&Frames::startGrabbing,
|
|
|
-// this,&Frames::handleGrab);
|
|
|
+ connect(this,&Frames::startGrabbing,
|
|
|
+ this,&Frames::handleGrab);
|
|
|
|
|
|
connect(this,&Frames::uvcframeAvailable,
|
|
|
this,&Frames::parseFrame);
|
|
|
@@ -330,7 +332,7 @@ Frames::setVideoSink( QVideoSink * newVideoSink )
|
|
|
void
|
|
|
Frames::setChange(bool stat_t)
|
|
|
{
|
|
|
- qDebug() << "开始自动对焦,发送指令到控制板!";
|
|
|
+ LOG("开始自动对焦,发送指令到控制板!");
|
|
|
if(stat_t){
|
|
|
emit serial_data(m_json.Autofocus());
|
|
|
}
|
|
|
@@ -437,6 +439,11 @@ Frames::setCameraSw(bool stat_cam)
|
|
|
jClass->callMethod<void>("openDevice","(Landroid/content/Context;)V",qtContext.object());
|
|
|
}
|
|
|
#else
|
|
|
+ if (handle)
|
|
|
+ {
|
|
|
+ MV_CC_DestroyHandle(handle);
|
|
|
+ handle = NULL;
|
|
|
+ }
|
|
|
unsigned int nIndex = 0;
|
|
|
MV_CC_DEVICE_INFO_LIST stDeviceList;
|
|
|
memset(&stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));
|
|
|
@@ -521,6 +528,7 @@ Frames::setCameraSw(bool stat_cam)
|
|
|
qDebug() << "Set Trigger Mode fail! nRet" << QString::number(unsignedValue, 16).toUpper();
|
|
|
return;
|
|
|
}
|
|
|
+ #if 0
|
|
|
//注册抓图回调
|
|
|
nRet = MV_CC_RegisterImageCallBackEx(handle,ImageCallBackEx,this);
|
|
|
if (MV_OK != nRet)
|
|
|
@@ -531,6 +539,7 @@ Frames::setCameraSw(bool stat_cam)
|
|
|
}else{
|
|
|
qDebug() << "MV_CC_RegisterImageCallBackEx Success!";
|
|
|
}
|
|
|
+ #endif
|
|
|
MVCC_INTVALUE_EX width,height;
|
|
|
nRet = MV_CC_GetIntValueEx(handle, "Width", &width);
|
|
|
if(nRet==MV_OK){
|
|
|
@@ -559,6 +568,7 @@ Frames::setCameraSw(bool stat_cam)
|
|
|
}else{
|
|
|
m_fps_timer->setRunning(true);
|
|
|
m_1s->start();
|
|
|
+ emit startGrabbing(true);
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
|
@@ -578,6 +588,7 @@ Frames::setCameraSw(bool stat_cam)
|
|
|
unsigned int unsignedValue = static_cast<unsigned int>(nRet);
|
|
|
qDebug() << "MV_CC_StopGrabbing fail! nRet:" << QString::number(unsignedValue, 16).toUpper();
|
|
|
}
|
|
|
+ #if 0
|
|
|
// ch:注销抓图回调 | en:Unregister image callback
|
|
|
nRet = MV_CC_RegisterImageCallBackEx(handle, NULL, NULL);
|
|
|
if (MV_OK != nRet)
|
|
|
@@ -585,6 +596,7 @@ Frames::setCameraSw(bool stat_cam)
|
|
|
unsigned int unsignedValue = static_cast<unsigned int>(nRet);
|
|
|
qDebug() << "MV_CC_RegisterImageCallBackEx fail! nRet:" << QString::number(unsignedValue, 16).toUpper();
|
|
|
}
|
|
|
+ #endif
|
|
|
// close device
|
|
|
nRet = MV_CC_CloseDevice(handle);
|
|
|
if (MV_OK != nRet)
|
|
|
@@ -608,7 +620,7 @@ Frames::setCameraSw(bool stat_cam)
|
|
|
m_processThread.waitForFinished(); //阻塞
|
|
|
}
|
|
|
|
|
|
- Logger::instance()->log("设置相机状态: " + QString::number(camera_sta));
|
|
|
+ LOG("设置相机状态:{}",camera_sta);
|
|
|
emit cameraStaChanged(camera_sta); //同步状态到qml
|
|
|
emit serial_data(m_json.setLedState(camera_sta)); //设置补光灯状态
|
|
|
}
|
|
|
@@ -688,22 +700,26 @@ Frames::handleGrab(bool sta_cam){
|
|
|
if(flag_cam){
|
|
|
nRet = MV_CC_GetOneFrameTimeout(handle, pData, nDataSize, &stImageInfo, 10000);
|
|
|
if (nRet == MV_OK){
|
|
|
- qDebug() << "MV_CC_GetOneFrameTimeout Success" <<stImageInfo.enPixelType << stImageInfo.nHeight << stImageInfo.nWidth;
|
|
|
+ //qDebug() << "MV_CC_GetOneFrameTimeout Success" <<stImageInfo.enPixelType << stImageInfo.nHeight << stImageInfo.nWidth;
|
|
|
if ( stImageInfo.enPixelType == 0 )
|
|
|
{
|
|
|
//转换为Mat类型
|
|
|
//cv::Mat tempMat = Mat(stImageInfo.nHeight , stImageInfo.nWidth, CV_8UC3,pData); //BGR
|
|
|
- tempMat = Mat(stImageInfo.nHeight , stImageInfo.nWidth, CV_8UC2,pData);
|
|
|
+ tempMat = Mat(stImageInfo.nHeight , stImageInfo.nWidth, CV_8UC1,pData); //YUV CV_8UC2
|
|
|
if (tempMat.empty()) {
|
|
|
// 处理转换失败的情况
|
|
|
qDebug() << "Failed to convert QByteArray to cv::Mat";
|
|
|
return; // 可能需要根据实际情况进行处理,比如抛出异常或返回错误码
|
|
|
}
|
|
|
+ #if 0
|
|
|
cv::Mat bgrImage;
|
|
|
cv::cvtColor(tempMat, bgrImage, cv::COLOR_YUV2RGB_YVYU);//YUV422
|
|
|
cv::cvtColor(bgrImage,m_frame,cv::COLOR_RGB2RGBA);
|
|
|
-
|
|
|
- const int size_frame = m_frame.rows * m_frame.cols * 4;
|
|
|
+ #else
|
|
|
+ cv::cvtColor(tempMat,m_frame,cv::COLOR_BayerRG2RGBA);
|
|
|
+ #endif
|
|
|
+ #if 1
|
|
|
+ const int size_frame = m_frame.total()*m_frame.elemSize(); //字节数
|
|
|
//m_image = cvMatToQImage(m_frame);
|
|
|
// 创建 QVideoFrame 对象,并设置相关参数
|
|
|
QVideoFrameFormat frame_format(QSize(m_frame.cols, m_frame.rows),
|
|
|
@@ -714,12 +730,35 @@ Frames::handleGrab(bool sta_cam){
|
|
|
memcpy(f.bits(0),m_frame.data,size_frame);
|
|
|
f.setStartTime(0);
|
|
|
f.unmap();
|
|
|
- if(m_videoSink != nullptr){
|
|
|
- m_videoSink->setVideoFrame(f);
|
|
|
- }
|
|
|
+ // 确保在主线程更新UI
|
|
|
+ QMetaObject::invokeMethod(m_videoSink, [this, f]() {
|
|
|
+ if (m_videoSink) {
|
|
|
+ m_videoSink->setVideoFrame(f);
|
|
|
+ }
|
|
|
+ }, Qt::QueuedConnection);
|
|
|
+ // if(m_videoSink != nullptr){
|
|
|
+ // m_videoSink->setVideoFrame(f);
|
|
|
+ // }
|
|
|
}
|
|
|
+ m_fps_timer->incrementFrame();
|
|
|
+ if(param::camera_tc==1||param::camera_tc==100){
|
|
|
+ QDateTime currentDateTime = QDateTime::currentDateTime();
|
|
|
+ QString currentDateTimeString = currentDateTime.toString("yyyyMMddhhmmss");
|
|
|
+ QString appDataPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
|
|
|
+ if(f.isValid()) m_image = f.toImage().convertToFormat(QImage::Format_RGB32);
|
|
|
+ param::camera_tc = 0;
|
|
|
+ param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
|
|
|
+ LOG("Pt1 is:{}",param::ptlist.at(0).toStdString());
|
|
|
+ if(m_image.save(param::ptlist.at(0),"jpg",100))
|
|
|
+ {
|
|
|
+ emit signal_stitch();
|
|
|
+ setCameraSw(false);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #else
|
|
|
emit uvcframeAvailable(m_frame);
|
|
|
- QThread::msleep(100); // 休眠2秒
|
|
|
+ #endif
|
|
|
}else{
|
|
|
qDebug() << "enPixelType:" << stImageInfo.enPixelType;
|
|
|
}
|
|
|
@@ -755,7 +794,7 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
#if 1
|
|
|
//进行色彩转换
|
|
|
// 将YUV422数据转换为RGB格式
|
|
|
- cv::cvtColor(frame,m_frame,cv::COLOR_RGB2RGBA);
|
|
|
+ //cv::cvtColor(frame,m_frame,cv::COLOR_RGB2RGBA);
|
|
|
const int size_frame = m_frame.total()*m_frame.elemSize(); //字节数
|
|
|
|
|
|
// 创建 QVideoFrame 对象,并设置相关参数
|
|
|
@@ -770,7 +809,7 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
m_videoSink->setVideoFrame(f);
|
|
|
}
|
|
|
}
|
|
|
- #if 1
|
|
|
+ #if 0
|
|
|
if(m_1s->isActive())
|
|
|
m_qulityString = m_opencvfunc.brenner(m_frame); //计算对比度
|
|
|
#endif
|
|
|
@@ -781,7 +820,7 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
QString setup_s;
|
|
|
if(param::camera_tc==100){ //拍照上传
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(0));
|
|
|
+ LOG("Pt1 is:{}",param::ptlist.at(0).toStdString());
|
|
|
if(param::camera_type.contains("hikrobot")){
|
|
|
if(cv::imwrite(param::ptlist.at(0).toStdString(), m_frame)){
|
|
|
param::camera_tc = 10;
|
|
|
@@ -801,7 +840,7 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
switch(param::stitch_photonum){ //拼接数量
|
|
|
case 1:
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(0));
|
|
|
+ LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(0),"jpg",100)) param::camera_tc = 10;
|
|
|
break;
|
|
|
case 2:
|
|
|
@@ -812,7 +851,7 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 0:
|
|
|
if(stitch_des==0){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(0));
|
|
|
+ LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(0),"jpg",100)){
|
|
|
//movx b
|
|
|
setup_s = "b" + QString::number(param::photo_width);
|
|
|
@@ -825,7 +864,7 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 1:
|
|
|
if(stitch_des==1){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-2.jpg");
|
|
|
- Logger::instance()->log("pt2 is:"+param::ptlist.at(1));
|
|
|
+ LOG("pt2 is:{}",param::ptlist.at(1).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(1),"jpg",100)){
|
|
|
stitch_des = 10;
|
|
|
}
|
|
|
@@ -842,7 +881,7 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 0:
|
|
|
if(stitch_des==0){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(0));
|
|
|
+ LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(0),"jpg",100)){
|
|
|
//movx b
|
|
|
setup_s = "b" + QString::number(param::photo_width);
|
|
|
@@ -854,8 +893,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
break;
|
|
|
case 1:
|
|
|
if(stitch_des==1){
|
|
|
- param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-2.jpg");
|
|
|
- Logger::instance()->log("pt2 is:"+param::ptlist.at(1));
|
|
|
+ param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-2.jpg");;
|
|
|
+ LOG("pt2 is:{}",param::ptlist.at(1).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(1),"jpg",100)){
|
|
|
//movx b
|
|
|
setup_s = "b" + QString::number(param::photo_width);
|
|
|
@@ -867,7 +906,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 2:
|
|
|
if(stitch_des==2){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-3.jpg");
|
|
|
- Logger::instance()->log("pt3 is:"+param::ptlist.at(2));
|
|
|
+
|
|
|
+ LOG("pt3 is:{}",param::ptlist.at(2).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(1),"jpg",100)) stitch_des = 10;
|
|
|
}
|
|
|
break;
|
|
|
@@ -883,7 +923,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 0:
|
|
|
if(stitch_des==0){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(0));
|
|
|
+
|
|
|
+ LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(0),"jpg",100)){
|
|
|
//movx b
|
|
|
setup_s = "b" + QString::number(param::photo_width);
|
|
|
@@ -896,7 +937,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 1:
|
|
|
if(stitch_des==1){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-2.jpg");
|
|
|
- Logger::instance()->log("pt2 is:"+param::ptlist.at(1));
|
|
|
+
|
|
|
+ LOG("pt2 is:{}",param::ptlist.at(1).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(1),"jpg",100)){
|
|
|
//movz f
|
|
|
setup_s = "f" + QString::number(param::photo_height);
|
|
|
@@ -909,7 +951,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 2:
|
|
|
if(stitch_des==2){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-3.jpg");
|
|
|
- Logger::instance()->log("pt3 is:"+param::ptlist.at(2));
|
|
|
+
|
|
|
+ LOG("pt3 is:{}",param::ptlist.at(2).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(2),"jpg",100)){
|
|
|
//movx b
|
|
|
setup_s = "f" + QString::number(param::photo_width);
|
|
|
@@ -922,7 +965,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 3:
|
|
|
if(stitch_des==3){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-4.jpg");
|
|
|
- Logger::instance()->log("pt4 is:"+param::ptlist.at(3));
|
|
|
+
|
|
|
+ LOG("pt4 is:{}",param::ptlist.at(3).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(3),"jpg",100)){
|
|
|
param::camera_tc = 10;
|
|
|
}
|
|
|
@@ -954,7 +998,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 0:
|
|
|
if(stitch_des==0){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-1.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(0));
|
|
|
+
|
|
|
+ LOG("pt1 is:{}",param::ptlist.at(0).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(0),"jpg",90)){
|
|
|
//movx b
|
|
|
setup_s = "b" + QString::number(param::photo_width);
|
|
|
@@ -967,7 +1012,7 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 1:
|
|
|
if(stitch_des==1){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-2.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(1));
|
|
|
+ LOG("pt2 is:{}",param::ptlist.at(1).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(1),"jpg",90)){
|
|
|
//movx b
|
|
|
setup_s = "b" + QString::number(param::photo_height);
|
|
|
@@ -980,7 +1025,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 2:
|
|
|
if(stitch_des==2){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-3.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(2));
|
|
|
+
|
|
|
+ LOG("pt3 is:{}",param::ptlist.at(2).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(2),"jpg",90)){
|
|
|
//movz f
|
|
|
setup_s = "f" + QString::number(param::photo_width);
|
|
|
@@ -993,7 +1039,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 3: //movx f
|
|
|
if(stitch_des==3){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-4.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(3));
|
|
|
+
|
|
|
+ LOG("pt4 is:{}",param::ptlist.at(3).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(3),"jpg",90)){
|
|
|
//movx f
|
|
|
setup_s = "f" + QString::number(param::photo_width);
|
|
|
@@ -1005,7 +1052,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 4: //movx f
|
|
|
if(stitch_des==4){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-5.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(4));
|
|
|
+
|
|
|
+ LOG("pt5 is:{}",param::ptlist.at(4).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(4),"jpg",90)){
|
|
|
//movx f
|
|
|
setup_s = "f" + QString::number(param::photo_width);
|
|
|
@@ -1017,7 +1065,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 5: //movz f
|
|
|
if(stitch_des==5){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-6.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(5));
|
|
|
+
|
|
|
+ LOG("pt6 is:{}",param::ptlist.at(5).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(5),"jpg",90)){
|
|
|
|
|
|
setup_s = "f" + QString::number(param::photo_width);
|
|
|
@@ -1029,7 +1078,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 6: //movx b
|
|
|
if(stitch_des==6){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-7.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(6));
|
|
|
+
|
|
|
+ LOG("pt7 is:{}",param::ptlist.at(6).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(6),"jpg",90)){
|
|
|
//movx f
|
|
|
setup_s = "b" + QString::number(param::photo_width);
|
|
|
@@ -1041,7 +1091,8 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 7: //movx b
|
|
|
if(stitch_des==7){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-8.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(7));
|
|
|
+
|
|
|
+ LOG("pt8 is:{}",param::ptlist.at(7).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(7),"jpg",90)){
|
|
|
//movx f
|
|
|
setup_s = "b" + QString::number(param::photo_width);
|
|
|
@@ -1053,7 +1104,7 @@ Frames::parseFrame(const cv::Mat& frame){
|
|
|
case 8:
|
|
|
if(stitch_des==8){
|
|
|
param::ptlist.append(appDataPath + "/" + currentDateTimeString + "-9.jpg");
|
|
|
- Logger::instance()->log("pt1 is:"+param::ptlist.at(8));
|
|
|
+ LOG("pt9 is:{}",param::ptlist.at(8).toStdString());
|
|
|
if(m_image.save(param::ptlist.at(8),"jpg",90)){
|
|
|
param::camera_tc = 10;
|
|
|
stitch_des = 9;
|
|
|
@@ -1266,7 +1317,7 @@ void
|
|
|
Frames::saveImage()
|
|
|
{
|
|
|
//停止清晰度发送,关闭定时器m1s
|
|
|
- Logger::instance()->log("saveImage!");
|
|
|
+ LOG("saveImage start!");
|
|
|
#ifdef focus_board
|
|
|
if(camera_sw()==true)
|
|
|
param::camera_tc = 1;
|
|
|
@@ -1276,9 +1327,10 @@ Frames::saveImage()
|
|
|
Mat image_gray;
|
|
|
cv::cvtColor(m_frame,image_gray,cv::COLOR_RGBA2GRAY);
|
|
|
double grayvalue = cv::mean(image_gray)[0];
|
|
|
- m_qulityString = m_opencvfunc.Laplacian(m_frame);
|
|
|
+ m_qulityString = m_opencvfunc.Tenengrad(m_frame);
|
|
|
emit qulityStringChanged();
|
|
|
- Logger::instance()->log("image_gray!"+QString::number(grayvalue) + "Laplacian:" + m_qulityString);
|
|
|
+ LOG("image_gray:{}",grayvalue);
|
|
|
+ LOG("Tenengrad:{}",m_qulityString.toStdString());
|
|
|
if(grayvalue<50.0){
|
|
|
emit dataUpload(m_json.MakeJsonWarn("Photo ERROR",QString::number(grayvalue)));
|
|
|
setCameraSw(false); //关闭相机
|
|
|
@@ -1291,28 +1343,9 @@ Frames::saveImage()
|
|
|
|
|
|
|
|
|
if(max_image_qulity < 1.0){
|
|
|
- emit serial_data(m_json.MotorMove("movy","f4",""));
|
|
|
- return;
|
|
|
+ emit serial_data(m_json.MotorMove("movy","b50","1"));
|
|
|
}
|
|
|
|
|
|
- if(m_qulityString.toDouble()>2.0&&m_qulityString.toDouble()>max_image_qulity/1.1)
|
|
|
- {
|
|
|
- if(param::auto_focus=="done"){
|
|
|
- MAX_STEP = 6;
|
|
|
- emit serial_data(m_json.MotorMove("movy","b100",""));
|
|
|
- return;
|
|
|
- }
|
|
|
- param::camera_tc = 1;
|
|
|
- return;
|
|
|
- }else{
|
|
|
- //对焦
|
|
|
- MAX_STEP = 6;
|
|
|
- emit serial_data(m_json.MotorMove("movy","b100",""));
|
|
|
- }
|
|
|
-
|
|
|
- //if(param::auto_focus=="done")
|
|
|
- //max_image_qulity = 100.0;
|
|
|
-
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
@@ -1378,11 +1411,11 @@ Frames::captureImage(){
|
|
|
m_imageCapture->captureToFile();
|
|
|
|
|
|
}
|
|
|
- }else if(param::camera_type.contains("uvc")){
|
|
|
+ }else if(param::camera_type.contains("uvc")||param::camera_type.contains("hikrobot")){
|
|
|
setCameraSw(true);
|
|
|
// 延时一段时间后触发拍照
|
|
|
QTimer::singleShot(10000, [](){
|
|
|
- Logger::instance()->log("立即拍照");
|
|
|
+ LOG("立即拍照!");
|
|
|
param::camera_tc = 100;
|
|
|
});
|
|
|
}
|