|
@@ -3513,11 +3513,12 @@ namespace OnLineCard{
|
|
|
#define HSV_VALUE_H hsv_row_first[hsv_offset]
|
|
|
#define HSV_VALUE_S hsv_row_first[hsv_offset+1]
|
|
|
#define HSV_VALUE_V hsv_row_first[hsv_offset+2]
|
|
|
- const int hsv_v_valve = 255 * 50 / 100;
|
|
|
- const int hsv_h_max_valve = 180 * 20 / 360;
|
|
|
- const int hsv_h_min_valve = 180 * 315 / 360;
|
|
|
+ const int hsv_v_valve = /*255 * 50 / 100*/46;
|
|
|
+ const int hsv_h_max_valve = /*180 * 20 / 360*/180;
|
|
|
+ const int hsv_h_min_valve = /*180 * 315 / 360*/156;
|
|
|
+ const int hsv_h_max_valve2 = /*180 * 20 / 360*/10;
|
|
|
const int hsv_s_valve_1 = /*255 * 23 / 100*/43;
|
|
|
- const int hsv_s_valve_2 = 255 * 33 / 100;
|
|
|
+ const int hsv_s_valve_2 = /*255 * 33 / 100*/255;
|
|
|
const int hsv_valve_high = 255 * (23 + 70) / 100;
|
|
|
const int hsv_valve_low = 255 * (13 + 60) / 100;
|
|
|
for (int y = 0; y<h; y++)
|
|
@@ -3529,7 +3530,7 @@ namespace OnLineCard{
|
|
|
unsigned char * black_row_first = (unsigned char *)(black->imageData + y*black->widthStep);
|
|
|
for (int x = 0, hsv_offset = 0; x<w; x++, hsv_offset += 3)
|
|
|
{
|
|
|
- if (HSV_VALUE_V >= hsv_v_valve && (HSV_VALUE_H >= hsv_h_min_valve || HSV_VALUE_H <= hsv_h_max_valve)){
|
|
|
+ if (HSV_VALUE_V >= hsv_v_valve && (HSV_VALUE_H >= hsv_h_min_valve || HSV_VALUE_H <= hsv_h_max_valve || HSV_VALUE_H <= hsv_h_max_valve2)){
|
|
|
red1_row_first[x] = (HSV_VALUE_S >= hsv_s_valve_1 && (HSV_VALUE_S + HSV_VALUE_V) >= hsv_valve_low) ? 255 : 0;
|
|
|
red2_row_first[x] = (HSV_VALUE_S >= hsv_s_valve_2 && (HSV_VALUE_S + HSV_VALUE_V) >= hsv_valve_high) ? HSV_VALUE_S : 0;
|
|
|
}
|
|
@@ -3540,11 +3541,11 @@ namespace OnLineCard{
|
|
|
}
|
|
|
}
|
|
|
#if GETREDBINARY_DEBUG
|
|
|
- cvSaveImage("D:\\hsv.png", hsv);
|
|
|
- cvSaveImage("D:\\red_low.png", red_low);
|
|
|
- cvSaveImage("D:\\red_high.png", red_high);
|
|
|
- cvSaveImage("D:\\binary.png", binary);
|
|
|
- cvSaveImage("D:\\black.png", black);
|
|
|
+ cvSaveImage("D:\\ImageDebug\\hsv.png", hsv);
|
|
|
+ cvSaveImage("D:\\ImageDebug\\red_low.png", red_low);
|
|
|
+ cvSaveImage("D:\\ImageDebug\\red_high.png", red_high);
|
|
|
+ cvSaveImage("D:\\ImageDebug\\binary.png", binary);
|
|
|
+ cvSaveImage("D:\\ImageDebug\\black.png", black);
|
|
|
#endif
|
|
|
cvThreshold(red_high, red_high, 0, 255, CV_THRESH_OTSU);
|
|
|
#ifdef _DEBUG
|
|
@@ -3594,12 +3595,14 @@ namespace OnLineCard{
|
|
|
}
|
|
|
}
|
|
|
cvReleaseStructuringElement(&element);
|
|
|
- *red_binary = red;
|
|
|
+ //直接使用red_low作为返回值
|
|
|
+ //TODO 此处不太明白red_high存在的意义是什么?
|
|
|
+ *red_binary = red_low;
|
|
|
cvReleaseImage(&hsv);
|
|
|
cvReleaseImage(&binary);
|
|
|
cvReleaseImage(&black);
|
|
|
cvReleaseImage(&black_dilate);
|
|
|
- cvReleaseImage(&red_low);
|
|
|
+ cvReleaseImage(&red);
|
|
|
cvReleaseImage(&red_dilate);
|
|
|
return TRUE;
|
|
|
}
|