OpenCV Python Video Camera Interfacing

In this tutorial we are going to create a simple program in Python for Web Cam interfacing and viewing preview of camera using OpenCV

Here is the Code




#================================================================
#
#   IN THE NAME OF ALLAH,THE MOST BENEFICENT, THE MOST MERCIFUL
#
# 29-10-15  3:00PM
#===============================================================

import cv2
import numpy as np


video_capture = cv2.VideoCapture(0)





if __name__ == '__main__':
    
    while True:
        #=============================================================
        # Capture frame-by-frame
        #--------------------------------------------------------------
        
        ret, frame = video_capture.read()
        
        #===================================
        #do all processing Here
        #-----------------------------------





        #===================================
        # Display the resulting frame
        #-----------------------------------
        cv2.imshow('Video', frame)
        k=cv2.waitKey(1)
        if k & 0xFF == ord('q'):            
            break



    # When everything is done, release the capture
    video_capture.release()
    cv2.destroyAllWindows()




#========================={End of the Code}===================================

        


Comments