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

Method sum

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

Source from the content-addressed store, hash-verified

450}
451
452cv::Scalar cv::sum( InputArray _src )
453{
454 Mat src = _src.getMat();
455 int k, cn = src.channels(), depth = src.depth();
456
457#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
458 size_t total_size = src.total();
459 int rows = src.size[0], cols = (int)(total_size/rows);
460 if( src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
461 {
462 IppiSize sz = { cols, rows };
463 int type = src.type();
464 typedef IppStatus (CV_STDCALL* ippiSumFunc)(const void*, int, IppiSize, double *, int);
465 ippiSumFunc ippFunc =
466 type == CV_8UC1 ? (ippiSumFunc)ippiSum_8u_C1R :
467 type == CV_8UC3 ? (ippiSumFunc)ippiSum_8u_C3R :
468 type == CV_8UC4 ? (ippiSumFunc)ippiSum_8u_C4R :
469 type == CV_16UC1 ? (ippiSumFunc)ippiSum_16u_C1R :
470 type == CV_16UC3 ? (ippiSumFunc)ippiSum_16u_C3R :
471 type == CV_16UC4 ? (ippiSumFunc)ippiSum_16u_C4R :
472 type == CV_16SC1 ? (ippiSumFunc)ippiSum_16s_C1R :
473 type == CV_16SC3 ? (ippiSumFunc)ippiSum_16s_C3R :
474 type == CV_16SC4 ? (ippiSumFunc)ippiSum_16s_C4R :
475 type == CV_32FC1 ? (ippiSumFunc)ippiSum_32f_C1R :
476 type == CV_32FC3 ? (ippiSumFunc)ippiSum_32f_C3R :
477 type == CV_32FC4 ? (ippiSumFunc)ippiSum_32f_C4R :
478 0;
479 if( ippFunc )
480 {
481 Ipp64f res[4];
482 if( ippFunc(src.data, (int)src.step[0], sz, res, ippAlgHintAccurate) >= 0 )
483 {
484 Scalar sc;
485 for( int i = 0; i < cn; i++ )
486 {
487 sc[i] = res[i];
488 }
489 return sc;
490 }
491 }
492 }
493#endif
494
495 SumFunc func = getSumFunc(depth);
496
497 CV_Assert( cn <= 4 && func != 0 );
498
499 const Mat* arrays[] = {&src, 0};
500 uchar* ptrs[1];
501 NAryMatIterator it(arrays, ptrs);
502 Scalar s;
503 int total = (int)it.size, blockSize = total, intSumBlockSize = 0;
504 int j, count = 0;
505 AutoBuffer<int> _buf;
506 int* buf = (int*)&s[0];
507 size_t esz = 0;
508 bool blockSum = depth < CV_32S;
509

Callers

nothing calls this directly

Calls 10

getSumFuncFunction · 0.85
minFunction · 0.70
getMatMethod · 0.45
channelsMethod · 0.45
depthMethod · 0.45
totalMethod · 0.45
isContinuousMethod · 0.45
typeMethod · 0.45
allocateMethod · 0.45
elemSizeMethod · 0.45

Tested by

no test coverage detected