9) web camera

A clean install of a new bbg image and opencv lead to good results.

IM using an ELP- ELP-USB500W05G-FD100 USB camera.  The minimum resolution 
is 640x480@ 30fps.  

using the following to get images form the camera and encode the data 
(after opencv decodes it) yields about .06sec per image (15 fps) with about 
1-2 sec lag between realtime and the image displayed in a browser. 
(@640x480, 50% jpeg quality)
I don't know why it makes sense to go form a jpeg stream (mjpeg) to raw 
data the back to jpegs, but that is an openCV limitation for now.
code grabbed and modified from (Website: http://www.chioka.in/)

I think the BBG is not well suited for this type of use, but it will be ok.

import cv2
import time
class VideoCamera(object):
    
    def __init__(self):
        # Using OpenCV to capture from device 0. If you have trouble 
capturing
        # from a webcam, comment the line below out and use a video file
        # instead.
        self.video = cv2.VideoCapture(0)
        print( 'camera initialized? ', self.video.isOpened())
        self.video.set(3,640)
        self.video.set(4,480)
        self.video.set(5,30)
               
        # If you decide to use video.mp4, you must have this file in the 
folder
        # as the main.py.
        #self.video = cv2.VideoCapture('video.mp4')
    
    def __del__(self):
        self.video.release()
    
    def get_frame(self):
        #before = time.clock()
        success=self.video.grab()
        success,image = self.video.retrieve()
        # We are using Motion JPEG, but OpenCV defaults to capture raw 
images,
        # so we must encode it into JPEG in order to correctly display the
        # video stream.
        encodeoptions =[cv2.IMWRITE_JPEG_QUALITY,50]
        ret, jpeg = cv2.imencode('.jpg', image,encodeoptions)
        #print time.clock()-before
        return jpeg.tostring()


On Sunday, November 13, 2016 at 4:09:06 PM UTC-6, Chris M wrote:
>
> Some thoughts and findings as I begin to learn the BBG (Beaglebone Green) 
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/35927ff9-9b1d-4108-bc74-41ec09c97c2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to