MCPcopy Create free account
hub / github.com/creatale/node-dv / findNonZero

Method findNonZero

deps/opencv/modules/core/src/stat.cpp:2585–2609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2583
2584
2585void cv::findNonZero( InputArray _src, OutputArray _idx )
2586{
2587 Mat src = _src.getMat();
2588 CV_Assert( src.type() == CV_8UC1 );
2589 int n = countNonZero(src);
2590 if (n == 0)
2591 {
2592 _idx.release();
2593 return;
2594 }
2595 if( _idx.kind() == _InputArray::MAT && !_idx.getMatRef().isContinuous() )
2596 _idx.release();
2597 _idx.create(n, 1, CV_32SC2);
2598 Mat idx = _idx.getMat();
2599 CV_Assert(idx.isContinuous());
2600 Point* idx_ptr = (Point*)idx.data;
2601
2602 for( int i = 0; i < src.rows; i++ )
2603 {
2604 const uchar* bin_ptr = src.ptr(i);
2605 for( int j = 0; j < src.cols; j++ )
2606 if( bin_ptr[j] )
2607 *idx_ptr++ = Point(j, i);
2608 }
2609}
2610
2611
2612CV_IMPL CvScalar cvSum( const CvArr* srcarr )

Callers

nothing calls this directly

Calls 8

kindMethod · 0.80
PointClass · 0.50
getMatMethod · 0.45
typeMethod · 0.45
releaseMethod · 0.45
isContinuousMethod · 0.45
createMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected