What is the meaning of the following line of code in opencv?

What does this line of code mean and how can I convert this code to javacv?

gray = Scalar::all(255);

This is the whole code associated with this line of code.

Mat src = imread("in.jpg"), gray;

cvtColor(src, gray, CV_BGR2GRAY);
threshold(gray, gray, 230, 255, THRESH_BINARY_INV);
vector<Vec4i> hierarchy;
vector<vector<Point> > contours;
findContours(gray, contours, hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);

gray = Scalar::all(255);

Please can someone explain about this?

+5
source share
2 answers

As I mentioned in my comment, it is used to set the gray image to white.

What is its advantage? This can only be said if we know what kind of code it is or to view the full code.

As for Java, OpenCV now has some android samples in which you can find Java codes.

You can check them out. I saw a similar function there :mWhilte = Scalar.all(255);

JavaCV: http://code.google.com/p/javacv/wiki/OpenCV2_Cookbook_Examples_Chapter_2

+2

255. , OpenCV .

:

gray.setTo(255); // prior to 2.3.1 it was a buggy on multichannel images
gray = 255; // prior to 2.3.1 it was a buggy on multichannel images

gray.setTo(Scalar::all(255)); // it works regardless the OpenCV version.

, , findfContours...

findContours , ( , deteles , , ). (, ).

, set-to-255 .

Mat::setTo() JavaCV, Java

+2

All Articles