What is cv :: setTo function

I have code written using OpenCV in C ++, and this code uses the setTo function. It is mainly used as:

cv::Mat xx; //prefedined and has some values cv::Mat yy; // initially empty yy.setTo(0,xx); 

So can you explain what this setTo means here? Does it leave all zero values ​​in yy or puts 1, where xx is nonzero, and 0, where xx is also zero?

+6
source share
1 answer

yy.setTo(0) set all pixels to 0.

yy.setTo(0, xx) set all the pixels that have the corresponding pixel with a non-zero value in xx Mat equal to 0.

Example:

 yy = 2 2 2 2 2 2 2 2 2 xx = 0 0 0 0 1 0 0 0 0 yy.setTo(0, xx) => yy = 2 2 2 2 0 2 2 2 2 
+20
source

Source: https://habr.com/ru/post/1392460/


All Articles