简体   繁体   中英

OPENCV : count pixel from the left edge of the image

i want to know how to make a loop to count image pixel start counting pixels from the left edge of the image

how to make this using c++ opencv

you don't need to build the loop yourself, it is all already done for you.

cv::Mat img = cv::imread("img.jpg");
std::cout << img.total() << std::endl;

The first line loads your image into the standard C++ OpenCV container Mat . The second line prints the number of elements in the underlaying array of the Mat , in case of an image, this is equal to the total number of pixels of that image.

If those constructs were new to you, you should start with reading these tutorials.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM