How to read in grayscale video file

When you read in the image, there is a flag that you can set to 0 to make it look like shades of gray.

 cv::Mat img = cv::imread(file, 0); // keeps it grayscale 

Is there an equivalent for video?

+3
source share
1 answer

Not there.

You need to request frames and convert them to shades of gray yourself.

Using C interface: fooobar.com/questions/111069 / ...

With C ++ interface:

 VideoCapture cap(0); if (!cap.isOpened()) { // print error msg return -1; } namedWindow("gray",1); Mat frame; Mat gray; for(;;) { cap >> frame; cvtColor(frame, gray, CV_BGR2GRAY); imshow("gray", gray); if(waitKey(30) >= 0) break; } return 0; 
+5
source

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


All Articles