Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 53

How do i convert a Grayscale video to a Tensor?

$
0
0
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<

Viewing all articles
Browse latest Browse all 53

Trending Articles