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

Function cvSetImageROI

deps/opencv/modules/core/src/array.cpp:2996–3028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2994
2995
2996CV_IMPL void
2997cvSetImageROI( IplImage* image, CvRect rect )
2998{
2999 if( !image )
3000 CV_Error( CV_HeaderIsNull, "" );
3001
3002 // allow zero ROI width or height
3003 CV_Assert( rect.width >= 0 && rect.height >= 0 &&
3004 rect.x < image->width && rect.y < image->height &&
3005 rect.x + rect.width >= (int)(rect.width > 0) &&
3006 rect.y + rect.height >= (int)(rect.height > 0) );
3007
3008 rect.width += rect.x;
3009 rect.height += rect.y;
3010
3011 rect.x = std::max(rect.x, 0);
3012 rect.y = std::max(rect.y, 0);
3013 rect.width = std::min(rect.width, image->width);
3014 rect.height = std::min(rect.height, image->height);
3015
3016 rect.width -= rect.x;
3017 rect.height -= rect.y;
3018
3019 if( image->roi )
3020 {
3021 image->roi->xOffset = rect.x;
3022 image->roi->yOffset = rect.y;
3023 image->roi->width = rect.width;
3024 image->roi->height = rect.height;
3025 }
3026 else
3027 image->roi = icvCreateROI( 0, rect.x, rect.y, rect.width, rect.height );
3028}
3029
3030
3031CV_IMPL void

Callers 1

icvReadImageFunction · 0.85

Calls 3

icvCreateROIFunction · 0.85
maxFunction · 0.70
minFunction · 0.70

Tested by

no test coverage detected