আমরা OpenCV এর 'set()' ক্লাস ব্যবহার করেছি। 'set()' ক্লাস ব্যবহার করে, আমরা ফ্রেমের উচ্চতা এবং প্রস্থ নির্ধারণ করতে পারি। নিম্নলিখিত লাইনগুলি আমাদের প্রোগ্রামে ভিডিওর উচ্চতা এবং প্রস্থ নির্ধারণ করছে৷
- সেট(CAP_PROP_FRAME_WIDTH, 320);
- সেট(CAP_PROP_FRAME_HEIGHT, 240);
প্রথম লাইনটি ফ্রেমের প্রস্থ 320 পিক্সেলে সেট করছে এবং দ্বিতীয় লাইনটি ফ্রেমের উচ্চতা 240 পিক্সেলে সেট করছে। এই দুটি লাইন একসাথে একটি 320 x 240 রেজোলিউশন ভিডিও স্ট্রিম গঠন করছে। এভাবেই আমরা OpenCV ব্যবহার করে ভিডিওর রেজোলিউশন পরিবর্তন করতে পারি।
নিম্নলিখিত প্রোগ্রামটি ডিফল্ট ক্যামেরা −
থেকে নেওয়া ভিডিও স্ট্রিমের রেজোলিউশন পরিবর্তন করেউদাহরণ
#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(0);//Declaring an object to capture stream of frames from default camera//
cap.set(CAP_PROP_FRAME_WIDTH, 320);//Setting the width of the video
cap.set(CAP_PROP_FRAME_HEIGHT, 240);//Setting the height of the video//
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;
} এই প্রোগ্রামটি 320 x 240 রেজোলিউশনে ভিডিও চালাবে৷
৷