|
|
@ -1002,7 +1002,7 @@ cvFindNextContour( CvContourScanner scanner ) |
|
|
|
CV_Error( CV_StsNullPtr, "" ); |
|
|
|
CV_Error( CV_StsNullPtr, "" ); |
|
|
|
|
|
|
|
|
|
|
|
#if CV_SSE2 |
|
|
|
#if CV_SSE2 |
|
|
|
bool haveSSE2 = cv::checkHardwareSupport(CPU_SSE2); |
|
|
|
bool haveSIMD = cv::checkHardwareSupport(CPU_SSE2); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
icvEndProcessContour( scanner ); |
|
|
|
icvEndProcessContour( scanner ); |
|
|
@ -1052,7 +1052,7 @@ cvFindNextContour( CvContourScanner scanner ) |
|
|
|
#if CV_SSE2 |
|
|
|
#if CV_SSE2 |
|
|
|
if ((p = img[x]) != prev) { |
|
|
|
if ((p = img[x]) != prev) { |
|
|
|
goto _next_contour; |
|
|
|
goto _next_contour; |
|
|
|
} else if (haveSSE2) { |
|
|
|
} else if (haveSIMD) { |
|
|
|
|
|
|
|
|
|
|
|
__m128i v_prev = _mm_set1_epi8((char)prev); |
|
|
|
__m128i v_prev = _mm_set1_epi8((char)prev); |
|
|
|
int v_size = width - 32; |
|
|
|
int v_size = width - 32; |
|
|
@ -1337,7 +1337,6 @@ cvEndFindContours( CvContourScanner * _scanner ) |
|
|
|
#define ICV_SINGLE 0 |
|
|
|
#define ICV_SINGLE 0 |
|
|
|
#define ICV_CONNECTING_ABOVE 1 |
|
|
|
#define ICV_CONNECTING_ABOVE 1 |
|
|
|
#define ICV_CONNECTING_BELOW -1 |
|
|
|
#define ICV_CONNECTING_BELOW -1 |
|
|
|
//#define ICV_IS_COMPONENT_POINT(val) ((val) != 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define CV_GET_WRITTEN_ELEM( writer ) ((writer).ptr - (writer).seq->elem_size) |
|
|
|
#define CV_GET_WRITTEN_ELEM( writer ) ((writer).ptr - (writer).seq->elem_size) |
|
|
|
|
|
|
|
|
|
|
@ -1349,13 +1348,9 @@ typedef struct CvLinkedRunPoint |
|
|
|
} |
|
|
|
} |
|
|
|
CvLinkedRunPoint; |
|
|
|
CvLinkedRunPoint; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline int findStartContourPoint(uchar *src_data, CvSize img_size, int j, bool haveSIMD) { |
|
|
|
#if CV_SSE2 |
|
|
|
#if CV_SSE2 |
|
|
|
inline int findStartContourPoint(uchar *src_data, CvSize img_size, int j, bool haveSSE2) { |
|
|
|
if (haveSIMD) { |
|
|
|
#else |
|
|
|
|
|
|
|
inline int findStartContourPoint(uchar *src_data, CvSize img_size, int j) { |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#if CV_SSE2 |
|
|
|
|
|
|
|
if (haveSSE2) { |
|
|
|
|
|
|
|
__m128i v_zero = _mm_setzero_si128(); |
|
|
|
__m128i v_zero = _mm_setzero_si128(); |
|
|
|
int v_size = img_size.width - 32; |
|
|
|
int v_size = img_size.width - 32; |
|
|
|
|
|
|
|
|
|
|
@ -1401,15 +1396,11 @@ inline int findStartContourPoint(uchar *src_data, CvSize img_size, int j) { |
|
|
|
return j; |
|
|
|
return j; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if CV_SSE2 |
|
|
|
inline int findEndContourPoint(uchar *src_data, CvSize img_size, int j, bool haveSIMD) { |
|
|
|
inline int findEndContourPoint(uchar *src_data, CvSize img_size, int j, bool haveSSE2) { |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
inline int findEndContourPoint(uchar *src_data, CvSize img_size, int j) { |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#if CV_SSE2 |
|
|
|
#if CV_SSE2 |
|
|
|
if (j < img_size.width && !src_data[j]) { |
|
|
|
if (j < img_size.width && !src_data[j]) { |
|
|
|
return j; |
|
|
|
return j; |
|
|
|
} else if (haveSSE2) { |
|
|
|
} else if (haveSIMD) { |
|
|
|
__m128i v_zero = _mm_setzero_si128(); |
|
|
|
__m128i v_zero = _mm_setzero_si128(); |
|
|
|
int v_size = img_size.width - 32; |
|
|
|
int v_size = img_size.width - 32; |
|
|
|
|
|
|
|
|
|
|
@ -1505,7 +1496,7 @@ icvFindContoursInInterval( const CvArr* src, |
|
|
|
if( contourHeaderSize < (int)sizeof(CvContour)) |
|
|
|
if( contourHeaderSize < (int)sizeof(CvContour)) |
|
|
|
CV_Error( CV_StsBadSize, "Contour header size must be >= sizeof(CvContour)" ); |
|
|
|
CV_Error( CV_StsBadSize, "Contour header size must be >= sizeof(CvContour)" ); |
|
|
|
#if CV_SSE2 |
|
|
|
#if CV_SSE2 |
|
|
|
bool haveSSE2 = cv::checkHardwareSupport(CPU_SSE2); |
|
|
|
bool haveSIMD = cv::checkHardwareSupport(CPU_SSE2); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
storage00.reset(cvCreateChildMemStorage(storage)); |
|
|
|
storage00.reset(cvCreateChildMemStorage(storage)); |
|
|
|
storage01.reset(cvCreateChildMemStorage(storage)); |
|
|
|
storage01.reset(cvCreateChildMemStorage(storage)); |
|
|
@ -1539,11 +1530,8 @@ icvFindContoursInInterval( const CvArr* src, |
|
|
|
tmp_prev = upper_line; |
|
|
|
tmp_prev = upper_line; |
|
|
|
for( j = 0; j < img_size.width; ) |
|
|
|
for( j = 0; j < img_size.width; ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if CV_SSE2 |
|
|
|
j = findStartContourPoint(src_data, img_size, j, haveSIMD); |
|
|
|
j = findStartContourPoint(src_data, img_size, j, haveSSE2); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
j = findStartContourPoint(src_data, img_size, j); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
if( j == img_size.width ) |
|
|
|
if( j == img_size.width ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
@ -1551,11 +1539,9 @@ icvFindContoursInInterval( const CvArr* src, |
|
|
|
CV_WRITE_SEQ_ELEM( tmp, writer ); |
|
|
|
CV_WRITE_SEQ_ELEM( tmp, writer ); |
|
|
|
tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer ); |
|
|
|
tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer ); |
|
|
|
tmp_prev = tmp_prev->next; |
|
|
|
tmp_prev = tmp_prev->next; |
|
|
|
#if CV_SSE2 |
|
|
|
|
|
|
|
j = findEndContourPoint(src_data, img_size, j+1, haveSSE2); |
|
|
|
j = findEndContourPoint(src_data, img_size, j+1, haveSIMD); |
|
|
|
#else |
|
|
|
|
|
|
|
j = findEndContourPoint(src_data, img_size, j+1); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
tmp.pt.x = j - 1; |
|
|
|
tmp.pt.x = j - 1; |
|
|
|
CV_WRITE_SEQ_ELEM( tmp, writer ); |
|
|
|
CV_WRITE_SEQ_ELEM( tmp, writer ); |
|
|
|
tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer ); |
|
|
|
tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer ); |
|
|
@ -1578,22 +1564,17 @@ icvFindContoursInInterval( const CvArr* src, |
|
|
|
all_total = runs->total; |
|
|
|
all_total = runs->total; |
|
|
|
for( j = 0; j < img_size.width; ) |
|
|
|
for( j = 0; j < img_size.width; ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if CV_SSE2 |
|
|
|
j = findStartContourPoint(src_data, img_size, j, haveSIMD); |
|
|
|
j = findStartContourPoint(src_data, img_size, j, haveSSE2); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
j = findStartContourPoint(src_data, img_size, j); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
if( j == img_size.width ) break; |
|
|
|
if( j == img_size.width ) break; |
|
|
|
|
|
|
|
|
|
|
|
tmp.pt.x = j; |
|
|
|
tmp.pt.x = j; |
|
|
|
CV_WRITE_SEQ_ELEM( tmp, writer ); |
|
|
|
CV_WRITE_SEQ_ELEM( tmp, writer ); |
|
|
|
tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer ); |
|
|
|
tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer ); |
|
|
|
tmp_prev = tmp_prev->next; |
|
|
|
tmp_prev = tmp_prev->next; |
|
|
|
#if CV_SSE2 |
|
|
|
|
|
|
|
j = findEndContourPoint(src_data, img_size, j+1, haveSSE2); |
|
|
|
j = findEndContourPoint(src_data, img_size, j+1, haveSIMD); |
|
|
|
#else |
|
|
|
|
|
|
|
j = findEndContourPoint(src_data, img_size, j+1); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
tmp.pt.x = j - 1; |
|
|
|
tmp.pt.x = j - 1; |
|
|
|
CV_WRITE_SEQ_ELEM( tmp, writer ); |
|
|
|
CV_WRITE_SEQ_ELEM( tmp, writer ); |
|
|
|
tmp_prev = tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer ); |
|
|
|
tmp_prev = tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer ); |
|
|
|