কম্পিউটার

কিভাবে আপনার কম্পিউটার থেকে ওপেনসিভিতে C++ ব্যবহার করে ভিডিও লোড করবেন?


এই বিষয়ে, আমরা জানব কিভাবে একটি ভিডিও ফাইল লোড করতে হয় এবং OpenCV ব্যবহার করে এটি চালাতে হয়, এবং আমাদের একই পদ্ধতি ব্যবহার করতে হবে যা আমরা আগের বিষয়ে শিখেছি। শুধুমাত্র পার্থক্য হল 'ভিডিওক্যাপচার' ক্লাসের বস্তুর আর্গুমেন্ট হিসাবে সংখ্যা রাখার পরিবর্তে, এবং আমাদের ভিডিওর পথটি রাখতে হবে৷

নিম্নলিখিত প্রোগ্রামটি দেখায় কিভাবে আপনার কম্পিউটার থেকে ওপেনসিভিতে C++ ব্যবহার করে ভিডিও লোড করতে হয়।

উদাহরণ

#include<opencv2/opencv.hpp>//OpenCV header to use VideoCapture class//
#include<iostream>
using namespace std;
using namespace cv;
int main() {
   Mat myImage;//Declaring a matrix to load the frames//
   namedWindow("Video Player");//Declaring the video to show the video//
   VideoCapture cap("video.mp4");//Declaring an object to capture stream of frames from default camera//
   if (!cap.isOpened()){ //This section prompt an error message if no video stream is found//
      cout << "No video stream detected" << endl;
      system("pause");
      return-1;
   }
   while (true){ //Taking an everlasting loop to show the video//
      cap >> myImage;
      if (myImage.empty()){ //Breaking the loop if no video frame is detected//
         break;
      }
      imshow("Video Player", myImage);//Showing the video//
      char c = (char)waitKey(25);//Allowing 25 milliseconds frame processing time and initiating break condition//
      if (c == 27){ //If 'Esc' is entered break the loop//
         break;
      }
   }
   cap.release();//Releasing the buffer memory//
   return 0;
}

আউটপুট

কিভাবে আপনার কম্পিউটার থেকে ওপেনসিভিতে C++ ব্যবহার করে ভিডিও লোড করবেন?


  1. কিভাবে C++ ব্যবহার করে OpenCV তে বাইনারি ইমেজ তৈরি করবেন?

  2. কিভাবে C++ ব্যবহার করে OpenCV-তে ইমেজ লোড এবং দেখাবেন?

  3. কিভাবে আপনার কম্পিউটার থেকে স্টিকার সরান

  4. আপনার কম্পিউটার থেকে পিসি স্পীড আপ কিভাবে মুছে ফেলবেন