खोज…


परिचय

जब भी आप वीडियो फीड के साथ काम करते हैं तो आप अंततः एक नई वीडियो फ़ाइल के रूप में अपनी छवि प्रसंस्करण परिणाम को बचाना चाहते हैं। सरल वीडियो आउटपुट के लिए आप OpenCV बिल्ट-इन VideoWriter वर्ग का उपयोग कर सकते हैं, इसके लिए डिज़ाइन किया गया है। उनका उपयोग करने से पहले कुछ अवधारणाओं को देखना उपयोगी है। ये अवधारणाएं कोडक यानी डिकोडर और फोरसीसी (फोर कैरेक्टर कोड) हैं।

OpenCV (जावा) के साथ एक वीडियो बनाना

VideoWriter videoWriter;
videoWriter = new VideoWriter(outputFile, VideoWriter.fourcc('x', '2','6','4'),
                fps, frameSize, isRGB);
//We have stated that we will use x264 as codec with FourCC
//For writing, we add the following method and it will write the image we give as parameter in this call.
 public void Write(Mat frame) {
        if(videoWriter.isOpened()==false){
            videoWriter.release();
            throw new IllegalArgumentException("Video Writer Exception: VideoWriter not opened,"
                    + "check parameters.");        
        }
        //Write video
        videoWriter.write(frame);
    }

//With Video Capture for example, we can read images from the camera and write the same video

VideoCapture videoCapture = new VideoCapture(0);
Size frameSize = new Size((int) videoCapture.get(Videoio.CAP_PROP_FRAME_WIDTH), (int) videoCapture.get(Videoio.CAP_PROP_FRAME_HEIGHT));
VideoWriter videoWriter = new VideoWriter("test.avi", VideoWriter.fourcc('x', '2','6','4'),
                videoCapture.get(Videoio.CAP_PROP_FPS), frameSize, true);
while (videoCapture.read(mat)) {
            videoWriter.write(mat);         
        }
        videoCapture.release();
        videoWriter.release();


Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow