diff --git a/Cigarette/Cigarette.vcxproj b/Cigarette/Cigarette.vcxproj index 2953400..18e7c3b 100644 --- a/Cigarette/Cigarette.vcxproj +++ b/Cigarette/Cigarette.vcxproj @@ -133,7 +133,7 @@ true true stdcpp14 - Disabled + MaxSpeed false 4819;%(DisableSpecificWarnings) @@ -141,7 +141,7 @@ Console $(OutDir)\$(ProjectName).exe $(QTDIR)\lib;$(ProjectDir)OpenCV455Simple\win64\vc15\lib;$(ProjectDir)Pylon6.2\lib\Win64;$(ProjectDir)MvIMPACT\lib\win64;$(ProjectDir)MVS3.2.1\lib\win64;$(ProjectDir)modbus;%(AdditionalLibraryDirectories) - true + false qtmain.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;opencv_world455.lib;modbus.lib;mvDeviceManager.lib;MvCameraControl.lib;Qt5Network.lib;%(AdditionalDependencies) @@ -151,6 +151,7 @@ + @@ -393,6 +394,7 @@ + $(QTDIR)\bin\moc.exe;%(FullPath) diff --git a/Cigarette/Cigarette.vcxproj.filters b/Cigarette/Cigarette.vcxproj.filters index 3cc8ba2..385d71e 100644 --- a/Cigarette/Cigarette.vcxproj.filters +++ b/Cigarette/Cigarette.vcxproj.filters @@ -257,6 +257,9 @@ Source Files + + Source Files + @@ -417,5 +420,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/Cigarette/alg_jd.cpp b/Cigarette/alg_jd.cpp index 20a23c2..a6faae7 100644 --- a/Cigarette/alg_jd.cpp +++ b/Cigarette/alg_jd.cpp @@ -152,7 +152,6 @@ void AlgJd::analyse(cv::Mat vec_in, std::vector >& vec_ cv::imshow("analyse", topography); cv::waitKey(1); } - } // Get the names of the output layers diff --git a/Cigarette/alg_jd.h b/Cigarette/alg_jd.h index 36e4259..aa66cc8 100644 --- a/Cigarette/alg_jd.h +++ b/Cigarette/alg_jd.h @@ -15,6 +15,7 @@ class AlgJd bool init(QString model_path, QString model_name); bool test_detect(); bool test_detect_batcht(int shoot); + int detect(cv::Mat& in, cv::Mat &draw_frame, cv::Mat& out, std::vector >& results); int detect(cv::Mat& in, cv::Mat &out, std::vector > &results); // Remove the bounding boxes with low confidence using non-maxima suppression void post_process(cv::Mat& frame, std::vector& outs, std::vector > &results); @@ -31,5 +32,10 @@ class AlgJd cv::dnn::Net net; std::vector classes; }; - +//jinhuan+ +bool sort_rect_by_x_center(cv::Rect r1, cv::Rect r2); +bool sort_rect_by_y_center(cv::Rect r1, cv::Rect r2); +bool sort_rect_by_height(cv::Rect r1, cv::Rect r2); +bool sort_rect_by_width(cv::Rect r1, cv::Rect r2); +//jinhuan- #endif //end of _CIGARETTE_JD diff --git a/Cigarette/alg_jd_ng.cpp b/Cigarette/alg_jd_ng.cpp new file mode 100644 index 0000000..67ad154 --- /dev/null +++ b/Cigarette/alg_jd_ng.cpp @@ -0,0 +1,517 @@ +#include "alg_jd_ng.h" +#include //所需的库文件 + +extern SysConf g_sys_conf; + +// Initialize the parameters +static float confThreshold = 0.01; // Confidence threshold +static float nmsThreshold = 0.4; // Non-maximum suppression threshold +static int inpWidth = 416; // Width of network's input image +static int inpHeight = 416; // Height of network's input image + +static std::vector classes; + +bool AlgJd_ng::init_ng(QString model_path, QString model_name) +{ + // Load names of classes + std::string classesFile; + cv::String modelConfiguration; + cv::String modelWeights; + QString image_path; + + modelWeights = model_path.toStdString() + "/" + model_name.toStdString(); + modelConfiguration = model_path.toStdString() + "/jd_ng.cfg"; + classesFile = model_path.toStdString() + "/jd_ng.names"; + image_path = model_path + "/" + "alg_jd_ng.bmp"; + + std::ifstream classNamesFile(classesFile.c_str()); + if (classNamesFile.is_open()) + { + std::string className = ""; + while (std::getline(classNamesFile, className)) + classes.push_back(className); + } + else{ + return false; + } + + // Load the network + net_ng = cv::dnn::readNetFromDarknet(modelConfiguration, modelWeights); + net_ng.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA); + net_ng.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA); + + //cv::Mat image = cv::imread("alg_jd.bmp"); + cv::Mat image = cv::imread(image_path.toStdString()); + + //识别一张图,测试模型是否正确,并且完成GPU数据加载 + if (!image.data) return false; //判断测试图片是否正常读取 + std::vector > results; + detect_ng(image, image, results); + if (results.size() > 0) + return true; //检测到目标,则初始化成功 + else + return false; //否则初始化失败 +} + +bool AlgJd_ng::test_detect_ng() +{ + cv::Mat m1; + m1 = cv::Mat(544, 728, CV_8UC3, cv::Scalar(0, 0, 0)); + std::vector > results; + double t = (double)cv::getTickCount(); + detect_ng(m1, m1, results); + t = ((double)cv::getTickCount() - t) / cv::getTickFrequency(); + DEBUG(" test_detect time process:%f\n", t); + return true; +} + +bool AlgJd_ng::test_detect_batcht_ng(int shoot) +{ + std::vector vec_in; + std::vector vec_out; + std::vector > > vec_results; + cv::Mat m1, m2, m3; + m1 = cv::Mat(544, 728, CV_8UC3, cv::Scalar(0, 0, 0)); + m2 = cv::Mat(544, 728, CV_8UC3, cv::Scalar(0, 0, 0)); + m3 = cv::Mat(544, 728, CV_8UC3, cv::Scalar(0, 0, 0)); + + double t = (double)cv::getTickCount(); + switch(shoot){ + case 1:{ + std::vector > results; + detect_ng(m1, m1, results); + break; + } + case 3:vec_in.push_back(m3); + case 2:vec_in.push_back(m2); + default:{ + vec_in.push_back(m1); + detect_batch_ng(vec_in, vec_out, vec_results); + } + } + t = ((double)cv::getTickCount() - t) / cv::getTickFrequency(); + DEBUG(" test_detect_batcht time process:%f\n", t); + return true; +} + +int AlgJd_ng::detect_ng(cv::Mat& _frame, cv::Mat &out, std::vector > &results) +{ + cv::Mat frame = _frame.clone(); + cv::Mat image_clone=frame.clone(); + // Process frames. + // Create a 4D blob from a frame. + cv::Mat blob; + cv::dnn::blobFromImage(frame, blob, 1/255.0, cv::Size(inpWidth, inpHeight), cv::Scalar(0,0,0), true, false); + + //Sets the input to the network + net_ng.setInput(blob); + + + // Runs the forward pass to get output of the output layers + std::vector outs; + net_ng.forward(outs, getOutputsNames_ng(net_ng)); + + + // Remove the bounding boxes with low confidence + post_process_ng(frame, outs, results); + + + // Write the frame with the detection boxes + cv::Mat detectedFrame; + frame.convertTo(detectedFrame, CV_8U); + //show detectedFrame + out=detectedFrame.clone(); + return results.size(); +} + +int AlgJd_ng::detect_ng(cv::Mat& _frame, cv::Mat& draw_frame, cv::Mat& out, std::vector>& results) +{ + cv::Mat frame = _frame.clone(); + + // Process frames. + // Create a 4D blob from a frame. + // 创建4D的blob用于网络输入 + cv::Mat blob; + cv::dnn::blobFromImage(frame, blob, 1 / 255.0, cv::Size(inpWidth, inpHeight), cv::Scalar(0, 0, 0), true, false); + + //Sets the input to the network + net_ng.setInput(blob); + + + // Runs the forward pass to get output of the output layers + std::vector outs; + net_ng.forward(outs, getOutputsNames_ng(net_ng)); + + + // Remove the bounding boxes with low confidence + // 删除低置信度的边界框 + post_process_ng(draw_frame, outs, results); + + // Write the frame with the detection boxes + cv::Mat detectedFrame; + draw_frame.convertTo(detectedFrame, CV_8U); + + //show detectedFrame + out = detectedFrame.clone(); + return results.size(); +} + +void AlgJd_ng::CircleImagePro_ng(cv::Mat src, cv::Mat dst, std::vector radius) { + QStringList TestData; + src.copyTo(dst); + float c = float(20.5) / float(68.9); + std::vector> contours; + // 图像预处理 + cv::Mat img; + cv::cvtColor(dst, img, cv::COLOR_BGR2GRAY); + GaussianBlur(img, img, cv::Size(3, 3), 1); + Canny(img, img, 50, 150, 3); + imshow("img", img); + + cv::Mat kernel = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3)); // 获取卷积核 + dilate(img, img, kernel, cv::Point(-1, -1), 2); + findContours(img, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE); + img.release(); + + std::vector center(contours.size()); + std::vector rad(contours.size()); + if (contours.size() == 0) { + std::cout << "未找到检测物" << std::endl; + return; + } + for (size_t i = 0; i < contours.size(); ++i) { + minEnclosingCircle(contours[i], center[i], rad[i]); + radius.push_back(rad[i] * c); + } + + for (size_t j = 0; j < center.size(); ++j) { + std::string str = "radius: "; + std::string str1; + float r = 0.0; + circle(dst, center[j], rad[j], cv::Scalar(0, 0, 255), 1); + r = rad[j] * c; + str1 = format("%.4f", r); + str.insert(str.end(), str1.begin(), str1.end()); + TestData.append(QString::fromStdString(str)); + cv::imshow("dst", dst); + cv::putText(dst, str, center[j], 1, 2, cv::Scalar(0, 255, 0), 2, 8); + cv::waitKey(1); + } + TestData.clear(); +} + +void AlgJd_ng::analyse_ng(cv::Mat vec_in, std::vector>& vec_results) +{ + bool IsNG = false; + std::vector vec_jd_results; // 0 胶点 + std::vector vec_kz_results; // 1 卡纸距离 + + for (int i = 0; i < vec_results.size(); i++) + { + if (vec_results[i].first == 0) // jd + { + vec_jd_results.push_back(vec_results[i].second); + } + else if (vec_results[i].first == 1) // 卡纸距离 + { + vec_kz_results.push_back(vec_results[i].second); + } + } + std::sort(vec_jd_results.begin(), vec_jd_results.end(), sort_rect_by_y_center_ng);//升序排列,//jinhuan+ + + //jinhuan+ + if (vec_jd_results.size() && vec_kz_results.size()) + { + //从上往下第一个胶点的中心y值 + int top_jd_y = vec_jd_results[0].y + vec_jd_results[0].height / 2; + //从上往下最后一个胶点的中心y值 + int bottom_jd_y = vec_jd_results[vec_jd_results.size()-1].y + vec_jd_results[vec_jd_results.size()-1].height / 2; + //卡纸的上边沿y值 + int top_kz_y = vec_kz_results[0].tl().y; + //卡纸的下边沿y值 + int bottom_kz_y = vec_kz_results[0].br().y; + + //if(abs(top_jd_y- top_kz_y)>50);//50个像素 + //if (abs(bottom_kz_y - bottom_jd_y)>40);//40个像素 + } else { + IsNG = true;//卡纸和胶点数量不够 + } + //if (vec_kz_results.size() != 1) {//卡纸有褶皱 + // IsNG = true; + //} + + //jinhuan- + cv::waitKey(1); +} + +// Get the names of the output layers +std::vector AlgJd_ng::getOutputsNames_ng(const cv::dnn::Net& net) +{ + std::vector names; + if (names.empty()) + { + //Get the indices of the output layers, i.e. the layers with unconnected outputs + std::vector outLayers = net.getUnconnectedOutLayers(); + + //get the names of all the layers in the network + std::vector layersNames = net.getLayerNames(); + + // Get the names of the output layers in names + names.resize(outLayers.size()); + for (size_t i = 0; i < outLayers.size(); ++i) + names[i] = layersNames[outLayers[i] - 1]; + } + return names; +} + +void AlgJd_ng::post_process_ng(cv::Mat& frame, std::vector& outs, std::vector > &results) +{ + std::vector < std::vector> classIds(classes.size()); + std::vector < std::vector> confidences(classes.size()); + std::vector < std::vector> boxes(classes.size()); + for (size_t i = 0; i < outs.size(); ++i) + { + // Scan through all the bounding boxes output from the network and keep only the + // ones with high confidence scores. Assign the box's class label as the class + // with the highest score for the box. + // 得到每个输出的数据 + float* data = (float*)outs[i].data; + for (int j = 0; j < outs[i].rows; ++j, data += outs[i].cols) + { + // 得到每个输出的所有类别的分数 + cv::Mat scores = outs[i].row(j).colRange(5, outs[i].cols); + cv::Point classIdPoint; + double confidence; + // Get the value and location of the maximum score + cv::minMaxLoc(scores, 0, &confidence, 0, &classIdPoint); + + //if (confidence > g_sys_conf.ConfThresholds[classIdPoint.x]*0.0001) + if (confidence > confThreshold) + { + int centerX = (int)(data[0] * frame.cols); + int centerY = (int)(data[1] * frame.rows); + int width = (int)(data[2] * frame.cols); + int height = (int)(data[3] * frame.rows); + int left = centerX - width / 2; + int top = centerY - height / 2; + + classIds[classIdPoint.x].push_back(classIdPoint.x); + confidences[classIdPoint.x].push_back((float)confidence); + boxes[classIdPoint.x].push_back(cv::Rect(left, top, width, height)); + } + } + } + + + // Perform non maximum suppression to eliminate redundant overlapping boxes with + // lower confidences + + for (size_t i = 0; i < classes.size(); ++i) + { + std::vector indices; + cv::dnn::NMSBoxes(boxes[i], confidences[i], confThreshold, nmsThreshold, indices); + for (size_t j = 0; j < indices.size(); ++j) + { + int idx = indices[j]; + cv::Rect box = boxes[i][idx]; + //if (classIds[i][idx] == 2) continue; + //else if (classIds[i][idx] == 3) continue; + + drawPred_ng(classIds[i][idx], confidences[i][idx], box.x, box.y, + box.x + box.width, box.y + box.height, frame); + results.push_back(std::make_pair(classIds[i][idx], box)); + } + } +} + +// Draw the predicted bounding box +void AlgJd_ng::drawPred_ng(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame) +{ + cv::Scalar color; + if (classId == 0) //jd + color = cv::Scalar(0, 0, 255); // 绿色 + else if (classId == 1) // kz + color = cv::Scalar(0, 255, 0); // + else if (classId == 2) // bm + color = cv::Scalar(0, 255, 0); + else if (classId == 3) // kzx + color = cv::Scalar(0, 255, 0); + else + color = cv::Scalar(255, 255, 255); // 白色 + + //Draw a rectangle displaying the bounding box + cv::rectangle(frame, cv::Point(left, top), cv::Point(right, bottom), color, 4); + + //Get the label for the class name and its confidence + std::string label = cv::format("%.2f%%", (conf*100));/// + if (!classes.empty()) + { + CV_Assert(classId < (int)classes.size()); + label = classes[classId] + ": " + label; + } + else + { + std::cout<<"classes is empty..."<& vec_in, std::vector &vec_out, std::vector>> &vec_results) +{ + cv::Mat blobs; + std::vector image; + + cv::dnn::blobFromImages(vec_in, blobs, 1 / 255.0, cv::Size(inpWidth, inpHeight), cv::Scalar(0, 0, 0), true, false); + + //Sets the input to the network + net_ng.setInput(blobs); + + // Runs the forward pass to get output of the output layers + std::vector outs; + net_ng.forward(outs, getOutputsNames_ng(net_ng)); + + for (int i = 0; i < vec_in.size(); i++) + { + image.push_back(vec_in[i].clone()); + } + + // Remove the bounding boxes with low confidence + post_process_batch_ng(image, outs, vec_results); + + + // Write the frame with the detection boxes + for (int i = 0; i < vec_in.size(); i++) + { + cv::Mat detectedFrame, out; + image[i].convertTo(detectedFrame, CV_8U); + out = detectedFrame.clone(); + vec_out.push_back(out); + } +} + +void AlgJd_ng::detect_batch_ng(std::vector& vec_in, std::vector& transits, std::vector& vec_out, std::vector > >& vec_results) +{ + cv::Mat blobs; + //std::vector image= transits; + + cv::dnn::blobFromImages(vec_in, blobs, 1 / 255.0, cv::Size(inpWidth, inpHeight), cv::Scalar(0, 0, 0), true, false); + + //Sets the input to the network + net_ng.setInput(blobs); + + // Runs the forward pass to get output of the output layers + std::vector outs; + net_ng.forward(outs, getOutputsNames_ng(net_ng)); + //for (int i = 0; i < vec_in.size(); i++) + //{ + // //image.push_back(vec_in[i].clone()); + // transits.push_back(vec_in[i].clone()); + //} + + // Remove the bounding boxes with low confidence + //post_process_batch_ng(image, outs, vec_results); + post_process_batch_ng(transits, outs, vec_results); + + // Write the frame with the detection boxes + for (int i = 0; i < vec_in.size(); i++) + { + cv::Mat detectedFrame, out; + //image[i].convertTo(detectedFrame, CV_8U); + transits[i].convertTo(detectedFrame, CV_8U); + out = detectedFrame.clone(); + vec_out.push_back(out); + } +} + +void AlgJd_ng::post_process_batch_ng(std::vector& vec_frame, std::vector& outs, std::vector > > &vec_results) +{ + int batch = vec_frame.size(); + double confidence;/// + for (int k = 0; k < batch; k++) + { + std::vector < std::vector> classIds(classes.size()); + std::vector < std::vector> confidences(classes.size()); + std::vector < std::vector> boxes(classes.size()); + + //std::cout << "outs.size()\t" << outs.size() << std::endl; + //std::cout << "Type\t" << outs[0].type() << std::endl; + + for (size_t i = 0; i < outs.size(); ++i) + { + //std::cout << "outs.dims\t" << outs[i].dims << std::endl; + //std::cout << "outs[" << i << "].rows\t" << outs[i].size[0] << std::endl; + //std::cout << "outs[" << i << "].cols\t" << outs[i].size[1] << std::endl; + //std::cout << "outs[" << i << "].cols\t" << outs[i].size[2] << std::endl; + // Scan through all the bounding boxes output from the network and keep only the + // ones with high confidence scores. Assign the box's class label as the class + // + cv::Mat m0(outs[i].size[1], outs[i].size[2], CV_32F, outs[i].data + outs[i].step[0] * k); + // with the highest score for the box. + float* data = (float*)m0.data; + for (int j = 0; j < m0.rows; ++j, data += m0.cols) + { + cv::Mat scores = m0.row(j).colRange(5, m0.cols); + cv::Point classIdPoint; + //double confidence; + // Get the value and location of the maximum score + cv::minMaxLoc(scores, 0, &confidence, 0, &classIdPoint); + + //if (confidence > g_sys_conf.ConfThresholds[classIdPoint.x]*0.0001) + if (confidence > confThreshold) + { + int centerX = (int)(data[0] * vec_frame[k].cols); + int centerY = (int)(data[1] * vec_frame[k].rows); + int width = (int)(data[2] * vec_frame[k].cols); + int height = (int)(data[3] * vec_frame[k].rows); + int left = centerX - width / 2; + int top = centerY - height / 2; + + classIds[classIdPoint.x].push_back(classIdPoint.x); + confidences[classIdPoint.x].push_back((float)confidence); + boxes[classIdPoint.x].push_back(cv::Rect(left, top, width, height)); + } + } + } + std::vector > results; + // Perform non maximum suppression to eliminate redundant overlapping boxes with + // lower confidences + for (size_t i = 0; i < classes.size(); ++i) + { + std::vector indices; + cv::dnn::NMSBoxes(boxes[i], confidences[i], confThreshold, nmsThreshold, indices); + for (size_t j = 0; j < indices.size(); ++j) + { + int idx = indices[j]; + cv::Rect box = boxes[i][idx]; + drawPred_ng(classIds[i][idx], confidences[i][idx], box.x, box.y, + box.x + box.width, box.y + box.height, vec_frame[k]); + results.push_back(std::make_pair(classIds[i][idx], box)); + } + } + vec_results.push_back(results); + } +} + +//jinhuan+ +bool sort_rect_by_x_center_ng(cv::Rect r1, cv::Rect r2) +{ + return (r1.x + r1.width / 2) < (r2.x + r2.width / 2); +} +bool sort_rect_by_y_center_ng(cv::Rect r1, cv::Rect r2) +{ + return (r1.y + r1.height / 2) < (r2.y + r2.height / 2); +} +bool sort_rect_by_height_ng(cv::Rect r1, cv::Rect r2) +{ + return (r1.height) < (r2.height); +} +bool sort_rect_by_width_ng(cv::Rect r1, cv::Rect r2) +{ + return (r1.width) < (r2.width); +} +//jinhuan- \ No newline at end of file diff --git a/Cigarette/alg_jd_ng.h b/Cigarette/alg_jd_ng.h new file mode 100644 index 0000000..58f8fd6 --- /dev/null +++ b/Cigarette/alg_jd_ng.h @@ -0,0 +1,42 @@ +#ifndef _CIGARETTE_JD_ng +#define _CIGARETTE_JD_ng + +#include +#include +#include +#include +#include +#include +#include +#include "common.h" +class AlgJd_ng +{ + public: + bool init_ng(QString model_path, QString model_name); + bool test_detect_ng(); + bool test_detect_batcht_ng(int shoot); + int detect_ng(cv::Mat& in, cv::Mat &draw_frame, cv::Mat &out, std::vector> &results); + int detect_ng(cv::Mat& in, cv::Mat &out, std::vector > &results); + // Remove the bounding boxes with low confidence using non-maxima suppression + void post_process_ng(cv::Mat& frame, std::vector& outs, std::vector> &results); + void CircleImagePro_ng(cv::Mat src, cv::Mat dst, std::vector radius); + void detect_batch_ng(std::vector& vec_in, std::vector &vec_out, std::vector > > &vec_results); + void detect_batch_ng(std::vector& vec_in, std::vector &transits, std::vector &vec_out, std::vector>> &vec_results); + // Remove the bounding boxes with low confidence using non-maxima suppression + void post_process_batch_ng(std::vector& vec_frame, std::vector& outs, std::vector>> &vec_results); + void analyse_ng(cv::Mat vec_in, std::vector > & vec_results); + // Get the names of the output layers + std::vector getOutputsNames_ng(const cv::dnn::Net& net); + // Draw the predicted bounding box + void drawPred_ng(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame); + private: + cv::dnn::Net net_ng; + std::vector classes_ng; +}; +//jinhuan+ +bool sort_rect_by_x_center_ng(cv::Rect r1, cv::Rect r2); +bool sort_rect_by_y_center_ng(cv::Rect r1, cv::Rect r2); +bool sort_rect_by_height_ng(cv::Rect r1, cv::Rect r2); +bool sort_rect_by_width_ng(cv::Rect r1, cv::Rect r2); +//jinhuan- +#endif //end of _CIGARETTE_JD diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp index c6f9d23..959c2c1 100644 --- a/Cigarette/cigarette.cpp +++ b/Cigarette/cigarette.cpp @@ -28,8 +28,10 @@ QDateTime g_ts_start; extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras]; AlgJd alg_jd[NumberOfSupportedCameras]; //检测胶点的AI算法 +AlgJd_ng alg_jd_ng[NumberOfSupportedCameras]; // 检测卡纸、薄膜褶皱 #ifdef __DEBUG AlgJd alg_test;//test AI算法 +AlgKz alg_kz_test; #endif QThread* pThread[NumberOfSupportedCameras]; @@ -90,6 +92,7 @@ VOID BeforeWork(int shoot[]) { if (SingleCamInfo[i].Detect && SingleCamInfo[i].IsOpen) { alg_jd[i].test_detect_batcht(shoot[i]); + alg_jd_ng[i].test_detect_batcht_ng(shoot[i]); } } } @@ -102,7 +105,6 @@ Cigarette::Cigarette(QWidget *parent) ui.setupUi(this); InitPtrMat(); read_conf(g_conf_path); - if (!g_conf_path.config_path.isEmpty()) { // 如果非空 QDir* dirinfo = new QDir(g_conf_path.config_path); @@ -312,26 +314,36 @@ Cigarette::Cigarette(QWidget *parent) { if(SingleCamInfo[i].Detect){ cam_status_mat[i]->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); - QString model_path, model_name; + + QString model_path, model1_name, model2_name; if (g_sys_conf.model_path.isEmpty()) { model_path = "D:/model"; - g_sys_conf.model_path = "D:/model"; + //g_sys_conf.model_path = model_path; } else model_path = g_sys_conf.model_path; - if (g_sys_conf.model_name.isEmpty()) { - model_name = "jd.weights"; - g_sys_conf.model_name = "jd.weights"; + if (g_sys_conf.model1_name.isEmpty()) { + model1_name = "jd.weights"; + g_sys_conf.model1_name = model1_name; + model2_name = "jd_ng.weights"; + g_sys_conf.model2_name = model2_name; } - else - model_name = g_sys_conf.model_name; - - if (!alg_jd[i].init(model_path, model_name)) + else { + model1_name = g_sys_conf.model1_name; + model2_name = g_sys_conf.model2_name; + } + + if (!alg_jd[i].init(model_path, model1_name)) { QMessageBox::information(NULL, QStringLiteral("系统自检失败"), QStringLiteral("AI模型1初始化失败,请检查程序完整性"), QMessageBox::Ok); exit(-1); } + else if (!alg_jd_ng[i].init_ng(model_path, model2_name)) + { + QMessageBox::information(NULL, QStringLiteral("系统自检失败"), QStringLiteral("AI模型2初始化失败,请检查程序完整性"), QMessageBox::Ok); + exit(-1); + } CreatWorkThread(SingleCamInfo[i].CamClass, i, this); } else { @@ -378,7 +390,8 @@ Cigarette::Cigarette(QWidget *parent) } #ifdef __DEBUG - alg_test.init(g_sys_conf.model_path, g_sys_conf.model_name);//test AI算法 + alg_test.init(g_sys_conf.model_path, g_sys_conf.model1_name);//test AI算法 + alg_kz_test.init(g_sys_conf.model_path, g_sys_conf.model2_name); #endif //自动打开所有相机 @@ -779,7 +792,14 @@ void Cigarette::TestImg() } std::vector > results; cv::Mat output; - alg_test.detect(imagein, output,results); + // alg_test.detect(imagein, output, results); + //alg_kz_test.detect(imagein, output, results); + + cv::Mat transit = imagein.clone(); + //std::vector > results; + alg_test.detect(imagein, transit, output, results); + alg_kz_test.detect(imagein, transit, output, results); + std::string WindowName = "TestImg"; cv::namedWindow(WindowName, cv::WINDOW_NORMAL); cv::imshow(WindowName, output); @@ -815,12 +835,17 @@ void Cigarette::TestImgs() } cv::Mat output; + cv::Mat transit = imagein.clone(); std::vector > results; - alg_test.detect(imagein, output,results); - std::string WindowName = "TestImg"; + std::vector vec_jd_results; + std::vector vec_bm_results; + alg_test.detect(imagein, transit, output, results); + alg_kz_test.detect(imagein, transit, output, results); + + std::string WindowName = "TestImgs"; cv::namedWindow(WindowName, cv::WINDOW_NORMAL); - cv::imshow(WindowName, output); - int k = cv::waitKeyEx(1); + cv::imshow(WindowName, transit); + int k = cv::waitKeyEx(100); if (k == 27)break;//ESC键 #ifdef __ExportData alg_test.analyse(imagein, results); @@ -2385,6 +2410,26 @@ bool Cigarette::read_sys_config(SysConf &conf, QString conf_path) { ///相似度 conf.ConfThreshold = atoi(line.substr(pos + 1).c_str()); } + else if (tmp_key == "CONFTHRESHOLDS") + { ///相似度 + std::vector vec_info; + string_split(line.substr(pos + 1), "|",vec_info); + if (vec_info.size() == 4) + { + conf.ConfThresholds[0]=atoi(vec_info[0].c_str());// 0 胶点 + conf.ConfThresholds[1]=atoi(vec_info[1].c_str());// 1 卡纸 + conf.ConfThresholds[2]=atoi(vec_info[2].c_str());// 2 薄膜 + conf.ConfThresholds[3]=atoi(vec_info[3].c_str());// 3 卡纸下 + } + } + else if (tmp_key == "UP_JD_SPACE") + { /// 是否自动打开相机:0否;1是 + conf.Up_jd_Space= atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "DOWN_JD_SPACE") + { /// 是否自动打开相机:0否;1是 + conf.Down_jd_Space = atoi(line.substr(pos + 1).c_str()); + } else if (tmp_key == "AUTO_OPEN") { /// 是否自动打开相机:0否;1是 conf.auto_open = atoi(line.substr(pos + 1).c_str()); @@ -2438,7 +2483,11 @@ bool Cigarette::read_sys_config(SysConf &conf, QString conf_path) } else if (tmp_key == "MODELNAME") { - conf.model_name = line.substr(pos + 1).c_str(); + conf.model1_name = line.substr(pos + 1).c_str(); + } + else if (tmp_key == "KZMODELNAME") + { + conf.model2_name = line.substr(pos + 1).c_str(); } else if (tmp_key == "JPGPATH") { diff --git a/Cigarette/cigarette.h b/Cigarette/cigarette.h index 9db2d26..da3461e 100644 --- a/Cigarette/cigarette.h +++ b/Cigarette/cigarette.h @@ -7,6 +7,7 @@ #include "dialogsetup.hpp" #include "plcsetup.hpp" #include "alg_jd.h" +#include "alg_jd_ng.h" #include "balluffcamera.h" #include "baslercamera.h" #include "hikcamera.h" diff --git a/Cigarette/common.cpp b/Cigarette/common.cpp index cffa104..469ad5a 100644 --- a/Cigarette/common.cpp +++ b/Cigarette/common.cpp @@ -56,7 +56,7 @@ void DrawSelectRects(cv::Mat input,DisplayLabelConf &t_DisplayLabelConf,int Cnt) cv::Point( t_DisplayLabelConf.processPoint.x * input.cols, t_DisplayLabelConf.processPoint.y * input.rows), - cv::Scalar(0, 0, 255), + cv::Scalar(127, 255, 0), 4); } for (int i = 0; i < t_DisplayLabelConf.RectVet[Cnt].size(); i++) { @@ -68,7 +68,7 @@ void DrawSelectRects(cv::Mat input,DisplayLabelConf &t_DisplayLabelConf,int Cnt) cv::Point( t_DisplayLabelConf.RectVet[Cnt][i].BR.x * input.cols, t_DisplayLabelConf.RectVet[Cnt][i].BR.y * input.rows), - cv::Scalar(0, 0, 255), + cv::Scalar(127, 255, 0), 4); } } diff --git a/Cigarette/common.h b/Cigarette/common.h index b0389af..1c28a28 100644 --- a/Cigarette/common.h +++ b/Cigarette/common.h @@ -85,7 +85,10 @@ public: int save_days; ///照片保存天数 int freesize; /// 设定清理图片最小空间 std::string ComPort; ///COM口 - int ConfThreshold; //识别率 + int ConfThreshold; //识别率 + int ConfThresholds[4]; //四类别识别率 + int Up_jd_Space; //上方胶点到卡纸上边间距 + int Down_jd_Space; //下方胶点到卡纸下边间距 int auto_open; //是否自动打开相机,0否,1是 int auto_work; //是否自动开始工作,0否,1是 int auto_shift; //是否自动换班,0否,1是 @@ -95,7 +98,8 @@ public: QTime shiftC; //C换班时间 QString location; // 所在地 QString model_path; // 模型文件夹路径 - QString model_name; // 模型名 + QString model1_name; // 模型名 + QString model2_name; QString model_jpg_path; // 模型图片路径 int timing_shift; //是否定时换班,0否,1是 int expo[NumberOfSupportedCameras]; //相机曝光时间,单位微秒 @@ -121,6 +125,9 @@ public: freesize = 10; /// 设定清理图片最小空间 ComPort = "COM1"; ///COM口 ConfThreshold = 1; ///百分比识别率 + ConfThresholds[4] = 0; ///四类别百分比识别率 + Up_jd_Space = 0; //上方胶点到卡纸上边间距 + Down_jd_Space = 0; //下方胶点到卡纸下边间距 auto_open=1; //是否自动打开相机,0否,1是 auto_work=1; //是否自动开始工作,0否,1是 auto_shift=0; //是否自动换班,0否,1是 @@ -128,7 +135,8 @@ public: timing_shift = 0; //是否定时换班,0否,1是 location = ""; model_path = ""; - model_name = ""; + model1_name = ""; + model2_name = ""; model_jpg_path = ""; shiftA.setHMS(0, 0, 0); shiftB.setHMS(0, 0, 0); diff --git a/Cigarette/conf_path.txt b/Cigarette/conf_path.txt new file mode 100644 index 0000000..db3c365 --- /dev/null +++ b/Cigarette/conf_path.txt @@ -0,0 +1,2 @@ +CONF_PATH=D:/conf-test +SAVE_PICS_PATH=D:/image diff --git a/Cigarette/dialogsetup.cpp b/Cigarette/dialogsetup.cpp index 0e57bd8..6fdf34e 100644 --- a/Cigarette/dialogsetup.cpp +++ b/Cigarette/dialogsetup.cpp @@ -90,17 +90,17 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) { fileList.removeOne(".."); ui.comboBox_model_path->clear(); ui.comboBox_model_path->addItems(fileList); - if (!g_sys_conf.model_name.isEmpty()) { + if (!g_sys_conf.model1_name.isEmpty()) { // 濡傛灉鏇鹃夋嫨杩囨ā鍨嬶紝鍒欏湪comboBox鏄剧ず閫夋嫨妯″瀷鐨勬枃浠跺悕 - ui.comboBox_model_path->setCurrentText(g_sys_conf.model_name); + ui.comboBox_model_path->setCurrentText(g_sys_conf.model1_name); } delete dirinfo, dirinfo = nullptr; } else { // 濡傛灉鏈浘閫夋嫨杩囨ā鍨嬫枃浠跺す - if (!g_sys_conf.model_name.isEmpty()) { + if (!g_sys_conf.model1_name.isEmpty()) { // 濡傛灉鏇剧粡閫夋嫨杩囨ā鍨嬫枃浠 - ui.comboBox_model_path->addItem(g_sys_conf.model_name); + ui.comboBox_model_path->addItem(g_sys_conf.model1_name); } } // 鏇存崲妯″瀷浜嬩欢 @@ -175,7 +175,7 @@ void DialogSetup::onComboBoxSelect(int index) { // 鑾峰彇comboBox褰撳墠鍐呭 QString ct = ui.comboBox_model_path->currentText(); // 淇濆瓨鍒伴厤缃枃浠朵腑 - g_sys_conf.model_name = ct; + g_sys_conf.model1_name = ct; } void DialogSetup::on_toolButton_keyboard_released() @@ -392,7 +392,7 @@ void DialogSetup::on_toolButton_choose_model_path_released() { QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("璇烽夋嫨妯″瀷鎵鍦ㄦ枃浠跺す"), "./"); //std::cout << "dirName is " << dirName.toStdString().c_str() << std::endl; //std::cout << "g_sys_conf.dir_path is " << g_sys_conf.dir_path.toStdString().c_str() << std::endl; - //std::cout << "g_sys_conf.model_name is " << g_sys_conf.model_name.toStdString().c_str() << std::endl; + //std::cout << "g_sys_conf.model1_name is " << g_sys_conf.model1_name.toStdString().c_str() << std::endl; if (dirName.isEmpty()) { if (g_sys_conf.model_path.isEmpty()) @@ -402,7 +402,7 @@ void DialogSetup::on_toolButton_choose_model_path_released() { ui.comboBox_model_path->addItem(dirName); g_sys_conf.model_path = dirName; - g_sys_conf.model_name = "jd.weights"; + g_sys_conf.model1_name = "jd.weights"; } QDir* dirinfo = new QDir(dirName); if (!dirinfo->exists()) @@ -411,7 +411,7 @@ void DialogSetup::on_toolButton_choose_model_path_released() { QStringList fileList = dirinfo->entryList(QDir::Files); if (fileList.count() == 0) { g_sys_conf.model_path = "D:/model"; - g_sys_conf.model_name = "jd.weights"; + g_sys_conf.model1_name = "jd.weights"; } else g_sys_conf.model_path = dirName; @@ -421,7 +421,7 @@ void DialogSetup::on_toolButton_choose_model_path_released() { ui.comboBox_model_path->clear(); ui.comboBox_model_path->addItems(fileList); - //g_sys_conf.model_name = ui.comboBox_model_path->currentText(); + //g_sys_conf.model1_name = ui.comboBox_model_path->currentText(); connect(ui.comboBox_model_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxSelect(int))); delete dirinfo, dirinfo = nullptr; @@ -536,6 +536,15 @@ void DialogSetup::write_config() memset(buf, 0, 256);/// sprintf(buf, "CONFTHRESHOLD=%d\n", g_sys_conf.ConfThreshold); cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256);/// + sprintf(buf, "CONFTHRESHOLDS=%d|%d|%d|%d\n", g_sys_conf.ConfThresholds[0], g_sys_conf.ConfThresholds[1], g_sys_conf.ConfThresholds[2], g_sys_conf.ConfThresholds[3]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "UP_JD_SPACE=%d\n", g_sys_conf.Up_jd_Space); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "DOWN_JD_SPACE=%d\n", g_sys_conf.Down_jd_Space); + cfg_file.write(buf, strlen(buf)); memset(buf, 0, 256); sprintf(buf, "AUTO_OPEN=%d\n", g_sys_conf.auto_open); cfg_file.write(buf, strlen(buf)); @@ -570,6 +579,9 @@ void DialogSetup::write_config() sprintf(buf, "MODELNAME=%s\n", g_sys_conf.model1_name.toStdString().c_str()); cfg_file.write(buf, strlen(buf)); memset(buf, 0, 256); + sprintf(buf, "KZMODELNAME=%s\n", g_sys_conf.model2_name.toStdString().c_str()); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); sprintf(buf, "JPGPATH=%s\n", g_sys_conf.model_jpg_path.toStdString().c_str()); cfg_file.write(buf, strlen(buf)); memset(buf, 0, 256); diff --git a/Cigarette/dialogsetup.ui b/Cigarette/dialogsetup.ui index 428eb61..500681b 100644 --- a/Cigarette/dialogsetup.ui +++ b/Cigarette/dialogsetup.ui @@ -6,8 +6,8 @@ 0 0 - 682 - 900 + 660 + 992 @@ -24,22 +24,37 @@ background-color: rgb(240, 240, 240); - + 0 0 - 683 - 900 + 661 + 1000 - + + + 0 + 0 + + + + + 0 + 0 + + + + true + + 0 0 - 681 - 901 + 670 + 977 @@ -50,41 +65,37 @@ - 0 - 0 + 670 + 900 - - true - - + - 0 - -122 - 670 - 1000 + 10 + 60 + 641 + 61 - - - 0 - 0 - + + + 寰蒋闆呴粦 + 12 + 75 + true + - - - 670 - 1000 - + + 鍚姩璁剧疆 - + - 10 - 60 - 641 - 61 + 30 + 30 + 220 + 22 @@ -95,59 +106,17 @@ true - - 鍚姩璁剧疆 - - - - - 30 - 30 - 220 - 22 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 鑷姩鎵撳紑鎵鏈夌浉鏈 - - - - - - 380 - 30 - 261 - 21 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 绋嬪簭鍚姩鍚庤嚜鍔ㄥ紑濮嬪伐浣 - - - - - - - 10 - 610 - 641 - 81 + + 鑷姩鎵撳紑鎵鏈夌浉鏈 + + + + + + 380 + 30 + 261 + 21 @@ -158,173 +127,38 @@ true - - 绠$悊鍛樺瘑鐮佷慨鏀 - - - - - 540 - 20 - 91 - 51 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 纭畾 - - - - - - 190 - 30 - 61 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 鏂板瘑鐮侊細 - - - - - - 440 - 32 - 91 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - - - - QLineEdit::Password - - - - - - 250 - 30 - 101 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - - - - QLineEdit::Password - - - - - - 360 - 30 - 81 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 纭瀵嗙爜锛 - - - - - - 90 - 30 - 91 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - - - - QLineEdit::Password - - - - - - 20 - 30 - 61 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 鍘熷瘑鐮侊細 - - - - - - - 10 - 180 - 640 - 278 + + 绋嬪簭鍚姩鍚庤嚜鍔ㄥ紑濮嬪伐浣 + + + + + + + 10 + 610 + 641 + 81 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 绠$悊鍛樺瘑鐮佷慨鏀 + + + + + 540 + 20 + 91 + 51 @@ -335,710 +169,17 @@ true - - 鐩告満鍙傛暟 - - - - - 20 - 40 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 1#鐩告満鏇濆厜鏃堕棿(寰)锛 - - - - - - 210 - 40 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 210 - 70 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 20 - 70 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 2#鐩告満鏇濆厜鏃堕棿(寰)锛 - - - - - - 510 - 70 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 320 - 40 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 1#鐩告満妯℃嫙澧炵泭(0~64)锛 - - - - - - 320 - 70 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 2#鐩告満妯℃嫙澧炵泭(0~64)锛 - - - - - - 510 - 40 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 210 - 100 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 20 - 130 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 4#鐩告満鏇濆厜鏃堕棿(寰)锛 - - - - - - 210 - 130 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 20 - 100 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 3#鐩告満鏇濆厜鏃堕棿(寰)锛 - - - - - - 510 - 130 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 320 - 100 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 3#鐩告満妯℃嫙澧炵泭(0~64)锛 - - - - - - 320 - 130 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 4#鐩告満妯℃嫙澧炵泭(0~64)锛 - - - - - - 510 - 100 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 680 - 90 - 91 - 51 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 纭畾 - - - - - - 20 - 160 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 5#鐩告満鏇濆厜鏃堕棿(寰)锛 - - - - - - 20 - 190 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 6#鐩告満鏇濆厜鏃堕棿(寰)锛 - - - - - - 20 - 220 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 7#鐩告満鏇濆厜鏃堕棿(寰)锛 - - - - - - 210 - 160 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 210 - 190 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 210 - 220 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 320 - 160 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 5#鐩告満妯℃嫙澧炵泭(0~64)锛 - - - - - - 320 - 190 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 6#鐩告満妯℃嫙澧炵泭(0~64)锛 - - - - - - 320 - 220 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 7#鐩告満妯℃嫙澧炵泭(0~64)锛 - - - - - - 510 - 160 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 510 - 190 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 510 - 220 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 20 - 250 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 8#鐩告満鏇濆厜鏃堕棿(寰)锛 - - - - - - 210 - 250 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 320 - 250 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 8#鐩告満妯℃嫙澧炵泭(0~64)锛 - - - - - - 510 - 250 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - - 10 - 770 - 641 - 148 + + 纭畾 + + + + + + 190 + 30 + 61 + 31 @@ -1049,374 +190,17 @@ true - - 婊ゆ尝璁剧疆 - - - - - 20 - 30 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 1#鐩告満婊ゆ尝鏃堕棿(寰)锛 - - - - - - 210 - 30 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 510 - 30 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 320 - 30 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 2#鐩告満婊ゆ尝鏃堕棿(寰)锛 - - - - - - 510 - 60 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 20 - 60 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 3#鐩告満婊ゆ尝鏃堕棿(寰)锛 - - - - - - 210 - 60 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 320 - 60 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 4#鐩告満婊ゆ尝鏃堕棿(寰)锛 - - - - - - 680 - 50 - 91 - 51 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 纭畾 - - - - - - 20 - 90 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 5#鐩告満婊ゆ尝鏃堕棿(寰)锛 - - - - - - 320 - 90 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 6#鐩告満婊ゆ尝鏃堕棿(寰)锛 - - - - - - 20 - 120 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 7#鐩告満婊ゆ尝鏃堕棿(寰)锛 - - - - - - 320 - 120 - 180 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - 8#鐩告満婊ゆ尝鏃堕棿(寰)锛 - - - - - - 210 - 90 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 210 - 120 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 510 - 90 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - 510 - 120 - 90 - 20 - - - - - 寰蒋闆呴粦 - 10 - 75 - true - - - - - - - - - - - 10 - 120 - 641 - 61 + + 鏂板瘑鐮侊細 + + + + + + 440 + 32 + 91 + 31 @@ -1427,101 +211,20 @@ true - - 瀛樺浘璁剧疆 - - - - - 30 - 30 - 90 - 21 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 涓嶅瓨 - - - - - - 230 - 30 - 90 - 21 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 瀛楴G - - - - - - 440 - 30 - 90 - 21 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 鍏ㄥ瓨 - - - - - - 570 - 25 - 50 - 30 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 纭畾 - - - - - - - 110 - 930 - 131 - 51 + + + + + QLineEdit::Password + + + + + + 250 + 30 + 101 + 31 @@ -1533,16 +236,19 @@ - 淇濆瓨鍙傛暟 + + + + QLineEdit::Password - + - 520 - 10 - 130 - 50 + 360 + 30 + 81 + 31 @@ -1554,16 +260,16 @@ - 閫鍑虹郴缁 + 纭瀵嗙爜锛 - + - 10 - 690 - 641 - 81 + 90 + 30 + 91 + 31 @@ -1574,173 +280,20 @@ true - - 鎿嶄綔鍛樺瘑鐮佷慨鏀 - - - - - 190 - 30 - 61 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 鏂板瘑鐮侊細 - - - - - - 440 - 32 - 91 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - - - - QLineEdit::Password - - - - - - 250 - 30 - 101 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - - - - QLineEdit::Password - - - - - - 360 - 30 - 81 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 纭瀵嗙爜锛 - - - - - - 90 - 30 - 91 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - - - - QLineEdit::Password - - - - - - 20 - 30 - 61 - 31 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 鍘熷瘑鐮侊細 - - - - - - 540 - 20 - 91 - 51 - - - - - 寰蒋闆呴粦 - 12 - 75 - true - - - - 纭畾 - - - - - - - 370 - 930 - 131 - 51 + + + + + QLineEdit::Password + + + + + + 20 + 30 + 61 + 31 @@ -1752,256 +305,373 @@ - 鍏抽棴绐楀彛 + 鍘熷瘑鐮侊細 - + + + + + 10 + 180 + 640 + 278 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 鐩告満鍙傛暟 + + - 220 - 10 - 130 - 50 + 20 + 40 + 180 + 20 寰蒋闆呴粦 - 12 + 10 75 true - 鏄剧ず妗岄潰 + 1#鐩告満鏇濆厜鏃堕棿(寰)锛 - + - 110 - 10 - 91 - 41 + 210 + 40 + 90 + 20 寰蒋闆呴粦 - 12 + 10 75 true - - border-image: url(:/Cigarette/Resources/keyboard.png); + + + + + + + + 210 + 70 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + - + 20 - 20 - 81 - 21 + 70 + 180 + 20 寰蒋闆呴粦 - 12 + 10 75 true - 绯荤粺璁剧疆 + 2#鐩告満鏇濆厜鏃堕棿(寰)锛 - + - 40 - 460 - 101 - 41 + 510 + 70 + 90 + 20 寰蒋闆呴粦 - 12 + 10 75 true - 閰嶆柟璁剧疆 + - + - 40 - 560 - 101 - 41 + 320 + 40 + 180 + 20 寰蒋闆呴粦 - 12 + 10 75 true - 鎹㈢彮璁剧疆 + 1#鐩告満妯℃嫙澧炵泭(0~64)锛 - + - 40 - 510 - 101 - 41 + 320 + 70 + 180 + 20 寰蒋闆呴粦 - 12 + 10 75 true - 浜ч噺缁熻 + 2#鐩告満妯℃嫙澧炵泭(0~64)锛 - + - 620 - 470 - 27 - 25 + 510 + 40 + 90 + 20 寰蒋闆呴粦 + 10 + 75 + true - ... + - + - 190 - 470 - 171 - 30 + 210 + 100 + 90 + 20 寰蒋闆呴粦 - 12 + 10 + 75 + true + + + + + + + + + + 20 + 130 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 75 true - 妯″瀷瀛樺偍璺緞 + 4#鐩告満鏇濆厜鏃堕棿(寰)锛 + + + + + + 210 + 130 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + - - Qt::AlignCenter + + - + - 370 - 470 - 241 - 30 + 20 + 100 + 180 + 20 寰蒋闆呴粦 10 + 75 + true + + 3#鐩告満鏇濆厜鏃堕棿(寰)锛 + - + - 340 - 1020 - 91 - 21 + 510 + 130 + 90 + 20 寰蒋闆呴粦 + 10 75 true - 鍥剧墖瀛樺偍璺緞 + - + - 440 - 1020 - 171 - 25 + 320 + 100 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 3#鐩告満妯℃嫙澧炵泭(0~64)锛 + + + + + + 320 + 130 + 180 + 20 寰蒋闆呴粦 + 10 + 75 + true + + 4#鐩告満妯℃嫙澧炵泭(0~64)锛 + - + - 620 - 1020 - 27 - 26 + 510 + 100 + 90 + 20 寰蒋闆呴粦 + 10 + 75 + true - ... + - + - 370 - 10 - 130 - 50 + 680 + 90 + 91 + 51 @@ -2013,165 +683,1485 @@ - 娓呯悊鍥剧墖 + 纭畾 - + - 520 - 930 - 131 - 21 + 20 + 160 + 180 + 20 寰蒋闆呴粦 + 10 75 true - 娴嬭瘯鍗曞紶鍥剧墖 + 5#鐩告満鏇濆厜鏃堕棿(寰)锛 - + - 520 - 960 - 131 - 21 + 20 + 190 + 180 + 20 寰蒋闆呴粦 + 10 75 true - 娴嬭瘯澶氬紶鍥剧墖 + 6#鐩告満鏇濆厜鏃堕棿(寰)锛 - + - 190 - 520 - 171 - 30 + 20 + 220 + 180 + 20 寰蒋闆呴粦 - 12 + 10 75 true - 閰嶇疆鏂囦欢瀛樺偍璺緞 + 7#鐩告満鏇濆厜鏃堕棿(寰)锛 + + + + + + 210 + 160 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + - - Qt::AlignCenter + + - + - 370 - 520 - 241 - 30 + 210 + 190 + 90 + 20 寰蒋闆呴粦 10 + 75 + true + + + - + - 620 - 520 - 27 - 25 + 210 + 220 + 90 + 20 寰蒋闆呴粦 + 10 + 75 + true - ... + - + - 190 - 570 - 171 - 30 + 320 + 160 + 180 + 20 寰蒋闆呴粦 - 12 + 10 75 true - 鍥剧墖瀛樺偍璺緞 + 5#鐩告満妯℃嫙澧炵泭(0~64)锛 + + + + + + 320 + 190 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + - - Qt::AlignCenter + + 6#鐩告満妯℃嫙澧炵泭(0~64)锛 - + - 370 - 570 - 241 - 30 + 320 + 220 + 180 + 20 寰蒋闆呴粦 10 + 75 + true + + 7#鐩告満妯℃嫙澧炵泭(0~64)锛 + - + - 620 - 570 - 27 - 25 + 510 + 160 + 90 + 20 寰蒋闆呴粦 + 10 + 75 + true - ... + + + + + 510 + 190 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 510 + 220 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 20 + 250 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 8#鐩告満鏇濆厜鏃堕棿(寰)锛 + + + + + + 210 + 250 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 320 + 250 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 8#鐩告満妯℃嫙澧炵泭(0~64)锛 + + + + + + 510 + 250 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + + 10 + 770 + 641 + 148 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 婊ゆ尝璁剧疆 + + + + + 20 + 30 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 1#鐩告満婊ゆ尝鏃堕棿(寰)锛 + + + + + + 210 + 30 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 510 + 30 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 320 + 30 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 2#鐩告満婊ゆ尝鏃堕棿(寰)锛 + + + + + + 510 + 60 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 20 + 60 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 3#鐩告満婊ゆ尝鏃堕棿(寰)锛 + + + + + + 210 + 60 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 320 + 60 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 4#鐩告満婊ゆ尝鏃堕棿(寰)锛 + + + + + + 680 + 50 + 91 + 51 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 纭畾 + + + + + + 20 + 90 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 5#鐩告満婊ゆ尝鏃堕棿(寰)锛 + + + + + + 320 + 90 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 6#鐩告満婊ゆ尝鏃堕棿(寰)锛 + + + + + + 20 + 120 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 7#鐩告満婊ゆ尝鏃堕棿(寰)锛 + + + + + + 320 + 120 + 180 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + 8#鐩告満婊ゆ尝鏃堕棿(寰)锛 + + + + + + 210 + 90 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 210 + 120 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 510 + 90 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + 510 + 120 + 90 + 20 + + + + + 寰蒋闆呴粦 + 10 + 75 + true + + + + + + + + + + + 10 + 120 + 641 + 61 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 瀛樺浘璁剧疆 + + + + + 30 + 30 + 90 + 21 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 涓嶅瓨 + + + + + + 230 + 30 + 90 + 21 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 瀛楴G + + + + + + 440 + 30 + 90 + 21 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 鍏ㄥ瓨 + + + + + + 570 + 25 + 50 + 30 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 纭畾 + + + + + + + 110 + 930 + 131 + 51 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 淇濆瓨鍙傛暟 + + + + + + 520 + 10 + 130 + 50 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 閫鍑虹郴缁 + + + + + + 10 + 690 + 641 + 81 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 鎿嶄綔鍛樺瘑鐮佷慨鏀 + + + + + 190 + 30 + 61 + 31 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 鏂板瘑鐮侊細 + + + + + + 440 + 32 + 91 + 31 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + + + + QLineEdit::Password + + + + + + 250 + 30 + 101 + 31 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + + + + QLineEdit::Password + + + + + + 360 + 30 + 81 + 31 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 纭瀵嗙爜锛 + + + + + + 90 + 30 + 91 + 31 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + + + + QLineEdit::Password + + + + + + 20 + 30 + 61 + 31 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 鍘熷瘑鐮侊細 + + + + + + 540 + 20 + 91 + 51 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 纭畾 + + + + + + + 370 + 930 + 131 + 51 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 鍏抽棴绐楀彛 + + + + + + 220 + 10 + 130 + 50 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 鏄剧ず妗岄潰 + + + + + + 110 + 10 + 91 + 41 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + border-image: url(:/Cigarette/Resources/keyboard.png); + + + + + + + + + 20 + 20 + 81 + 21 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 绯荤粺璁剧疆 + + + + + + 40 + 460 + 101 + 41 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 閰嶆柟璁剧疆 + + + + + + 40 + 560 + 101 + 41 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 鎹㈢彮璁剧疆 + + + + + + 40 + 510 + 101 + 41 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 浜ч噺缁熻 + + + + + + 620 + 470 + 27 + 25 + + + + + 寰蒋闆呴粦 + + + + ... + + + + + + 190 + 470 + 171 + 30 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 妯″瀷瀛樺偍璺緞 + + + Qt::AlignCenter + + + + + + 370 + 470 + 241 + 30 + + + + + 寰蒋闆呴粦 + 10 + + + + + + + 340 + 1020 + 91 + 21 + + + + + 寰蒋闆呴粦 + 75 + true + + + + 鍥剧墖瀛樺偍璺緞 + + + + + + 440 + 1020 + 171 + 25 + + + + + 寰蒋闆呴粦 + + + + + + + 620 + 1020 + 27 + 26 + + + + + 寰蒋闆呴粦 + + + + ... + + + + + + 370 + 10 + 130 + 50 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 娓呯悊鍥剧墖 + + + + + + 520 + 930 + 131 + 21 + + + + + 寰蒋闆呴粦 + 75 + true + + + + 娴嬭瘯鍗曞紶鍥剧墖 + + + + + + 520 + 960 + 131 + 21 + + + + + 寰蒋闆呴粦 + 75 + true + + + + 娴嬭瘯澶氬紶鍥剧墖 + + + + + + 190 + 520 + 171 + 30 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 閰嶇疆鏂囦欢瀛樺偍璺緞 + + + Qt::AlignCenter + + + + + + 370 + 520 + 241 + 30 + + + + + 寰蒋闆呴粦 + 10 + + + + + + + 620 + 520 + 27 + 25 + + + + + 寰蒋闆呴粦 + + + + ... + + + + + + 190 + 570 + 171 + 30 + + + + + 寰蒋闆呴粦 + 12 + 75 + true + + + + 鍥剧墖瀛樺偍璺緞 + + + Qt::AlignCenter + + + + + + 370 + 570 + 241 + 30 + + + + + 寰蒋闆呴粦 + 10 + + + + + + + 620 + 570 + 27 + 25 + + + + + 寰蒋闆呴粦 + + + + ... + diff --git a/Cigarette/output_statistic.cpp b/Cigarette/output_statistic.cpp index b247149..c35179a 100644 --- a/Cigarette/output_statistic.cpp +++ b/Cigarette/output_statistic.cpp @@ -82,11 +82,11 @@ void output_statistic::recMsgFromDialogSetup() for (int i = 0; i < NumberOfSupportedCameras; i++) { file_name = QString(STATISTIC_FILE).arg(i); file_path = g_conf_path.config_path + "/" + file_name; + //std::cout << "===>" << file_path.toStdString() << std::endl; file.setFileName(file_path); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); - //in.setCodec("UTF-8"); textBrowser_mat[i]->setText(in.readAll()); } else { diff --git a/Cigarette/workthread.cpp b/Cigarette/workthread.cpp index edd9a5b..1f1e40e 100644 --- a/Cigarette/workthread.cpp +++ b/Cigarette/workthread.cpp @@ -1,5 +1,6 @@ #include "workthread.h" #include "alg_jd.h" +#include "alg_jd_ng.h" #include "common.h" #include "balluffcamera.h" #include "baslercamera.h" @@ -8,6 +9,8 @@ #include "exportData.h" extern AlgJd alg_jd[NumberOfSupportedCameras]; //检测胶点的AI算法 +extern AlgJd_ng alg_jd_ng[NumberOfSupportedCameras]; // ng模型 + extern ConfPath g_conf_path; extern SysConf g_sys_conf; //系统配置参数 extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras]; @@ -15,8 +18,8 @@ extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras]; extern int rotationAngle[NumberOfSupportedCameras]; //图片旋转角度 extern bool isNeedRotate[NumberOfSupportedCameras]; -extern SyncQueue >* g_save_queue; //图片保存队列 -extern SyncQueue >* g_image_queue[NumberOfSupportedCameras]; //int表示一个目标拍了几张 +extern SyncQueue> *g_save_queue; //图片保存队列 +extern SyncQueue> *g_image_queue[NumberOfSupportedCameras]; //int表示一个目标拍了几张 extern SyncQueue<_UDPSendInfo> *UDP_Info_queue; extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue; extern PLCDevice* m_PLCDevice; @@ -59,6 +62,9 @@ void WorkThread::run() local_SysConf.shoot[local_camera_number] = g_sys_conf.shoot[local_camera_number]; local_SysConf.MisMatchAct = g_sys_conf.MisMatchAct; local_SysConf.ConfThreshold = g_sys_conf.ConfThreshold;// + local_SysConf.Up_jd_Space = g_sys_conf.Up_jd_Space; + local_SysConf.Down_jd_Space = g_sys_conf.Down_jd_Space; + for (int i = 0; i < 3; i++)local_SysConf.no[local_camera_number][i] = g_sys_conf.no[local_camera_number][i]; #ifdef DRAW_RECT @@ -73,7 +79,6 @@ void WorkThread::run() #endif } - QDateTime now_ts = QDateTime::currentDateTime(); std::pair element; local_g_image_queue->take(element); @@ -96,18 +101,19 @@ void WorkThread::run() { cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像 } + if (local_SysConf.shoot[local_camera_number] == unit_count) { exportDataInfo.shotCounts = unit_count; std::vector vec_in; int w = image.cols; int h = image.rows / unit_count; - for(int index=0;index vec_out; - std::vector > > vec_results; + + //单张 + cv::Mat transits; + std::vector> results; + std::vector> results_ng; + //多张 + std::vector transits_ng; + std::vector>> vec_results; + std::vector>> vec_results_ng; QDateTime ts_start = QDateTime::currentDateTime(); - if(unit_count == 1){ - std::vector > results; - cv::Mat imagein,imageout; + if (unit_count == 1) { + //std::vector> results; + //std::vector> results_ng; + cv::Mat imagein, imageout; imagein = vec_in[0]; alg_jd[local_camera_number].detect(imagein, imageout, results); + transits = imageout.clone(); + alg_jd_ng[local_camera_number].detect_ng(imagein, transits, imageout, results_ng); vec_out.push_back(imageout.clone()); vec_results.push_back(results); - }else{ + vec_results_ng.push_back(results_ng); + } + else { alg_jd[local_camera_number].detect_batch(vec_in, vec_out, vec_results); + for (int i = 0; i < vec_out.size(); i++) + transits_ng.push_back(vec_out[i]); + alg_jd_ng[local_camera_number].detect_batch_ng(vec_in, transits_ng, vec_out, vec_results_ng); } QDateTime ts_jd = QDateTime::currentDateTime(); int time_process = ts_start.msecsTo(ts_jd); emit display_timecost(local_camera_number, time_process); - UDPSendInfo.timecost = QString::number(time_process); - exportDataInfo.timeCost = QString::number(time_process).toStdString(); + //UDPSendInfo.timecost = QString::number(time_process); + //exportDataInfo.timeCost = QString::number(time_process).toStdString(); cv::Mat image1; cv::Mat image2; - + QString jd_no; - for(int index=0;index 0; } @@ -149,10 +171,10 @@ void WorkThread::run() UDPSendInfo.JD = jd_no; bool IsNG = false; - for(int index=0;index= 2){ - image1 = vec_out[(result_index) % 2].clone(); + image1 = vec_out[0].clone(); #ifdef DRAW_RECT IsNG|=CheckSelectRects(image1,vec_results,(result_index) % 2,local_DisplayLabelConf,0); #endif @@ -189,16 +211,54 @@ void WorkThread::run() #endif } result_index++; - exportDataInfo.isNg = IsNG; + //exportDataInfo.isNg = IsNG; + + ////jinhuan+ + //if (vec_jd_results.size() && vec_kzjl_results.size()) + //{ + // //从上往下第一个胶点的中心y值 + // int top_jd_y = vec_jd_results[0].y + vec_jd_results[0].height / 2; + // //从上往下最后一个胶点的中心y值 + // int bottom_jd_y = vec_jd_results[vec_jd_results.size()-1].y + vec_jd_results[vec_jd_results.size()-1].height / 2; + // //卡纸的上边沿y值 + // int top_kz_y = vec_kzjl_results[0].tl().y; + // //卡纸的下边沿y值 + // int bottom_kz_y = vec_kzjl_results[0].br().y; - if (!IsNG) + // //if (abs(top_jd_y - top_kz_y) < local_SysConf.Up_jd_Space)IsNG=true;//像素 + // //if (abs(bottom_kz_y - bottom_jd_y) < local_SysConf.Down_jd_Space)IsNG = true;//像素 + // + + //} + //else + //{ + // IsNG = true;//卡纸和胶点数量不够 + //} + //if (vec_kzzz_results.size() != 0) {//卡纸有褶皱 + // IsNG = true; + //} + //if (vec_bm_results.size() != 0) {//薄膜有褶皱 + // IsNG = true; + //} + //if (vec_qb_results.size() != 0) {//卡纸有翘边 + // IsNG = true; + // IsNG_model2[2] = IsNG; + //} + ////jinhuan- + + for (int index = 0; index < unit_count; index++) { - if (!g_debug_mode) - { - emit event_ok(local_camera_number); - local_g_result_queue->put(true); + if (results_ng.size() != 0 || vec_results_ng[index].size() != 0) {//ng模型检测:有ng + IsNG = true; + IsNG_model2[index] = IsNG; } } + + if (!IsNG) + { + emit event_ok(local_camera_number); + local_g_result_queue->put(true); + } else { if (!g_debug_mode) @@ -211,20 +271,24 @@ void WorkThread::run() { for(int index=0;indexput(std::make_pair(file_name.toStdString(), m)); - /*m = vec_out[index].clone(); - file_name = "D:/image/" + - now_ts.toString("yyyy-MM-dd") + - "/" + QString::number(local_camera_number + 1) + - "/ng_result/" + QString::number(index) + "/" + - now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + "_" + QString::number(index) + ".bmp";*/ - g_save_queue->put(std::make_pair(file_name.toStdString(), m)); + /*m = vec_out[index].clone(); + file_name = g_conf_path.save_pics_path + "/ng_result/" + + now_ts.toString("yyyy-MM-dd") + "/" + + QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" + + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + + "#" + "_" + QString::number(index + 1) + ".jpg"; + g_save_queue->put(std::make_pair(file_name.toStdString(), m));*/ + } } } } diff --git a/conf/conf.txt b/conf/conf.txt deleted file mode 100644 index f4f7139..0000000 --- a/conf/conf.txt +++ /dev/null @@ -1,77 +0,0 @@ -SAVE=0 -MISMATCHACT=1 -SAVE_DAYS=1 -FREESIZE=10 -ComPort=COM3 -CONFTHRESHOLD=80 -AUTO_OPEN=1 -AUTO_WORK=1 -AUTO_SHIFT=0 -TIMING_SHIFT=1 -SHIFT_BYHAND=1 -SHIFT_A=13|43 -SHIFT_B=13|44 -SHIFT_C=13|45 -LOCATION=CDTHV1.0.1 -MODELPATH=D:/model -MODELNAME=jd.weights -JPGPATH= -***************************************** -EXPO1=2000 -GAIN1=0 -FILTER1=500 -USERID1=5 -NO1=0|0|0 -SHOOT1=1 -***************************************** -EXPO2=2000 -GAIN2=0 -FILTER2=500 -USERID2=255 -NO2=0|0|0 -SHOOT2=3 -***************************************** -EXPO3=2000 -GAIN3=0 -FILTER3=500 -USERID3=255 -NO3=0|0|0 -SHOOT3=3 -***************************************** -EXPO4=2000 -GAIN4=0 -FILTER4=500 -USERID4=255 -NO4=0|0|0 -SHOOT4=3 -***************************************** -EXPO5=2000 -GAIN5=0 -FILTER5=500 -USERID5=255 -NO5=0|0|0 -SHOOT5=3 -***************************************** -EXPO6=2000 -GAIN6=0 -FILTER6=500 -USERID6=255 -NO6=0|0|0 -SHOOT6=3 -***************************************** -EXPO7=2000 -GAIN7=0 -FILTER7=500 -USERID7=255 -NO7=0|0|0 -SHOOT7=3 -***************************************** -EXPO8=2000 -GAIN8=0 -FILTER8=500 -USERID8=255 -NO8=0|0|0 -SHOOT8=3 -***************************************** -MonitorIP=192.168.1.144 -MonitorPort=1234 diff --git a/conf/modbus.txt b/conf/modbus.txt deleted file mode 100644 index 48ea3a0..0000000 --- a/conf/modbus.txt +++ /dev/null @@ -1,16 +0,0 @@ -KICK1=46118 -KICK2=46114 -KICK3=46116 -KICK4=46112 -KICK5=46120 -KICK6=46122 -KICK7=46124 -KICK8=46126 -QUANTITY=46008 -SHIFT=30100 -WORK=30101 -SEND_MESSAGE=30200 -NO_KICK=37102 -DEBUG=30103 -RESET=30104 -ALARM=46018 \ No newline at end of file diff --git a/conf/plc.txt b/conf/plc.txt deleted file mode 100644 index 2179e4c..0000000 --- a/conf/plc.txt +++ /dev/null @@ -1,26 +0,0 @@ -以下数据实验使用|0|0|******************** -脉冲速度|46712|1600|范围0Hz~200KHz -相机校验ON|47000|450|上升沿 -相机校验OFF|47002|900|下降沿 -1#相机拍照1ON|47004|500|上升沿 -1#相机拍照1OFF|47006|520|下降沿 -1#相机拍照2ON|47008|600|上升沿 -1#相机拍照2OFF|47010|620|下降沿 -1#相机拍照3ON|47012|700|上升沿 -1#相机拍照3OFF|47014|720|下降沿 -以下数据视现场情况自行修改|0|0|******************** -开始/暂停|30101|0|1开始,0暂停 -报警|46018|0|0无报警,非零参考报警代码 -当班产量|46008|0|当班产量 -剔除总数|46004|0|NG总数 -换班|30100|0|写1换班 -停机数|46718|20|连续NG报警 -硬件自检开关|37105|0|写1关闭/0打开:一般情况下无需改动 -声开关|37106|1|写1关闭/0打开:蜂鸣器 -光开关|37107|1|写1关闭/0打开:报警灯 -光源时间控制|46710|50|默认5秒 -光源通讯|30160|0|写1开启通讯 -1通道亮度|46600|80|范围0~255 -2通道亮度|46610|80|范围0~255 -3通道亮度|46620|111|范围0~255 -4通道亮度|46630|111|范围0~255 diff --git a/conf/rotate.txt b/conf/rotate.txt deleted file mode 100644 index ee1035c..0000000 --- a/conf/rotate.txt +++ /dev/null @@ -1 +0,0 @@ -0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3, \ No newline at end of file diff --git a/conf/璇存槑.txt b/conf/璇存槑.txt deleted file mode 100644 index 8c5146e..0000000 --- a/conf/璇存槑.txt +++ /dev/null @@ -1 +0,0 @@ -姝ゆ枃浠跺す鏂囦欢璇锋牴鎹幇鍦烘儏鍐佃繘琛屾洿鏀 \ No newline at end of file