I'm just started to process images from the video instead of still image. What is the proper way of doing it?
Need some guide here since I've no experience in video processing.
Thanks all.
EDIT: Does anyone know why there is a significant lag between the video processed in opencv compared to original video even though it's just converting from RGB to HSV?
Video processing is always done frame by frame. e.g. if you want to convert RGB video to HSV, you will do the following procedure:
UPDATE:
C++ sample code for Converting RGB video to HSV:
#include<iostream>
#include<string>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace std;
int main()
{
cv::VideoCapture capture;
cv::Mat RGB, HSV;
string videoPath = "C:/video.avi";
if(!capture.open(videoPath))
{
cout<<"Video Not Found"<<endl;
return;
}
while(true)
{
capture>>RGB; //Read a frame from the video
if(RGB.empty()) //Check if the frame has been read correctly or not
{
cout<<"Capture Finished"<<endl;
break;
}
cv::cvtColor(RGB,HSV,CV_BGR2HSV);
cv::imshow("HSV Image",HSV);
cv::waitKey(10);
}
capture.release();
return 0;
}
The color conversion function may require preallocating the memory for HSV. Read the documentation Here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With