c++ - opencv: Mat constructor from rect -


i attempting generate subimage opencv matrix data structure follows:

cv::rect sub_image = cv::rect(10, 10, 200, 200); cv::mat submat = original_image(sub_image); 

my question if have low level memcpy operations , use submat.data source, pointing correct subimage? guess not documentation seems allude points same dataset.

if so, how can use construct

cv::mat submat = original_image(sub_image); 

to copy data well?

use

cv::mat submat = original_image(sub_image).clone(); 

this deep-copy data of original_image new (probably continuous) matrix.

you use original_image(sub_image).copyto(submat); reach same, .clone() leads shorter code.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -