खोज…


पूर्व-कैप्चर किए गए वीडियो से फ़्रेम पढ़ना

वीडियो प्रक्षेपण

import numpy as np
import cv2

#access a video from your disk
#to use the GIF in this example, convert to avi!
cap = cv2.VideoCapture('eg_videoRead.avi')


#we are going to read 10 frames 
#we store the frames in a numpy structure
#then we'll generate a minimum projection of those frames

frameStack=[]
numFrames=10

for fr in range(numFrames):
    cap.set(cv2.CAP_PROP_POS_FRAMES,fr) #specifies which frame to read next
    frame=cap.read() #read the frame
    #gray = cv2.cvtColor(frame[1], cv2.COLOR_BGR2GRAY) #convert to gray scale
    frameStack.append(frame[1]) #add current frame to our frame Stack
    
minProjection=np.min(frameStack,axis=0) #find the minimum across frames
cv2.imshow("projection", minProjection) #show the result

OpenCV जावा के साथ VideoCapture का उपयोग करना

जावा में कोई इमोशो नहीं है, आपको इसके लिए एक विधि लिखने की आवश्यकता है। यह विधि एक Mat2bufferedImage है। पैरामीटर और रिटर्न छवि के रूप में मैट ऑब्जेक्ट लेता है।

public static void main(String[] args) {
    Mat frame = new Mat();
    //0; default video device id
    VideoCapture camera = new VideoCapture(0);
    JFrame jframe = new JFrame("Title");
    jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel vidpanel = new JLabel();
    jframe.setContentPane(vidpanel);
    jframe.setVisible(true);

    while (true) {
        if (camera.read(frame)) {

            ImageIcon image = new ImageIcon(Mat2bufferedImage(frame));
            vidpanel.setIcon(image);
            vidpanel.repaint();

        }
    }
}


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