| | |
| | | HalconCpp::ZoomImageSize(hImage, &hZoomImage, width, szHeight, "constant"); |
| | | HalconCpp::MeanImage(hZoomImage, &hMeanImage, 1, 5); |
| | | |
| | | |
| | | double xOutResult[MEASURE_MAX_NUM] = { 0 }; |
| | | double yOutResult[MEASURE_MAX_NUM] = { 0 }; |
| | | double cyOutResult[MEASURE_MAX_NUM] = { 0 }; |
| | |
| | | return 1; |
| | | } |
| | | |
| | | int CVisionMeasureClass::doMeasurePosB(unsigned char* img, int width, int height, double sigma, |
| | | MeasurePoint* measureResult1, int& outResult1, |
| | | MeasurePoint* measureResult2, int& outResult2, |
| | | MeasurePoint* measureResult3, int& outResult3) { |
| | | /* code */ |
| | | if (nullptr == img) return -1; |
| | | |
| | | HalconCpp::HObject hImage, hZoomImage, hMeanImage; |
| | | HalconCpp::GenImage1(&hImage, "byte", width, height, (Hlong)img); |
| | | int szHeight = (int)(0.5 * height); |
| | | HalconCpp::ZoomImageSize(hImage, &hZoomImage, width, szHeight, "constant"); |
| | | HalconCpp::MeanImage(hZoomImage, &hMeanImage, 1, 5); |
| | | |
| | | double xOutResult[MEASURE_MAX_NUM] = { 0 }; |
| | | double yOutResult[MEASURE_MAX_NUM] = { 0 }; |
| | | double cyOutResult[MEASURE_MAX_NUM] = { 0 }; |
| | | double distOutResult[MEASURE_MAX_NUM] = { 0 }; |
| | | int outNum = 0; |
| | | |
| | | int topEdge = 15; |
| | | int botEdge = szHeight - 16; |
| | | int step = (int)((botEdge - topEdge) / 2); |
| | | int x1 = 5; |
| | | int x2 = width - 6; |
| | | for (int i = 0; i < 3; i++) { |
| | | int y1 = topEdge + i * step; |
| | | int y2 = y1; |
| | | int threshold = 10; |
| | | doMeasurePosApi(hMeanImage, x1, y1, x2, y2, 10, threshold, sigma, xOutResult, yOutResult, cyOutResult, distOutResult, outNum); |
| | | if (0 == i) { |
| | | outResult1 = outNum; |
| | | for (int i = 0; i < outNum; i++) { |
| | | measureResult1[i].x = xOutResult[i]; |
| | | measureResult1[i].y = 2 * yOutResult[i]; |
| | | measureResult1[i].cy = cyOutResult[i]; |
| | | } |
| | | } |
| | | else if (1 == i) { |
| | | outResult2 = outNum; |
| | | for (int i = 0; i < outNum; i++) { |
| | | measureResult2[i].x = xOutResult[i]; |
| | | measureResult2[i].y = 2 * yOutResult[i]; |
| | | measureResult2[i].cy = cyOutResult[i]; |
| | | } |
| | | } |
| | | else if (2 == i) { |
| | | outResult3 = outNum; |
| | | for (int i = 0; i < outNum; i++) { |
| | | measureResult3[i].x = xOutResult[i]; |
| | | measureResult3[i].y = 2 * yOutResult[i]; |
| | | measureResult3[i].cy = cyOutResult[i]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | std::string CVisionMeasureClass::GetAppPathA(void) { |
| | | /* code */ |
| | | char szFilePath[MAX_PATH] = { 0 }, szDrive[MAX_PATH] = { 0 }, szDir[MAX_PATH] = { 0 }, szFileName[MAX_PATH] = { 0 }, szExt[MAX_PATH] = { 0 }; |