I have written a code which converts a RGB video to Grayscale and **now I want to convert it to a tensor.**
I just gave `cout<
#include
#include
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
double total_non_parallel = omp_get_wtime();
VideoCapture cap("/home/rmulay17/Downloads/2.mp4"); // open the video file for reading
if ( !cap.isOpened() ) // if not success, exit program
{
cout << "Cannot open the video file" << endl;
}
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
while(1)
{
cv::Mat frame;
cv::Mat graymat;
bool bSuccess = cap.read(frame); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
// cout << "Cannot read the frame from video file" << endl;
break;
}
cv::cvtColor(frame,graymat,cv::COLOR_BGR2GRAY); //Converts RGB to Grayscale
Mat float_mat;
graymat.convertTo( float_mat,CV_8U);
imshow("MyVideobnw", graymat);
cout<
↧