VGA camera capture

I have flashed another Debian Wheezy image on my BBB. It comes with preinstalled opencv (version 2.3.1) but with very old cv bindings. I posted this in googlegroups as a solution which i mention or i dont see as a solution because i just avoided the problem. I am able to stream a video with both cameras. Whichever resolution i set the Logitech camera to, it converts to the one shown below;
root@beaglebone:~/Project/py_servo_facetracker# v4l2-ctl -V
Format Video Capture:
Width/Height : 160/120
Pixel Format : ‘YUYV’
Field : None
Bytes per Line: 320
Size Image : 38400
Colorspace : SRGB
root@beaglebone:~/Project/py_servo_facetracker#

The other webcam is set to a 1280x720 resolution with the pixel format set as YUYV.

I am suspecting it has something to do with the opencv itself when it grabs frames from the webcam. Is there a way i can set opencv to maintain the camera resolution i set it to?

Looks like framegrabber was able to capture images based on the output you provided. Did you look at the images?

If it works for you then the code for the subscriber here http://blog.lemoneerlabs.com/post/bbb-mjpeg-streaming will show you how to load it into opencv.

The 160x120 video stream had no latency but the other camera with 1280x720 was slow, video was displayed as images being flipped like book pages.

I need to understand something from your files. Does it mean the rest of my iris recognition code has to be in the framegrabber.py client file and also this file can also run on BBB? Do i need the zhelper.h file when my PC is running Ubuntu?

Here is my setup like. I have a PC running Ubuntu connected to the BBB via usb and also sharing internet via the same cable (there is no wired connection, only the PC is connected to wifi). I want to see the video stream on my BBB for debugging purposes and once it is working fine it doesn’t have to show the video stream. I am accessing the BBB Desktop/GUI via a tightvnc client running on my Ubuntu PC. Thats when i will move to the hub for a wired connection so that everyone connected to the hub can access web pages served by the BBB (running lighttpd webserver).

I was successful in the part of running BBB as a webserver (without an video stream to show on the site because i don’t need it) but then the first part of getting a video stream to show was not possible because of select timeout errors.

Silva,

It does have MJPEG but opencv is converting the format to YUYV. And also does your board have I/O pins digital and analogue?

I have finally managed to get a video stream (at least i can say for now) by changing the frame resolution inside the python opencv code using instructions on http://stackoverflow.com/questions/11420748/setting-camera-parameters-in-opencv-python. The maximum resolution i can set it to was 640x480 with a 5fps frame rate, increasing the frame rate will result in a select timeout message. At 320x240 i can set it up to 30fps and running htop the CPU utilization will be fluctuating around 86-90%. The python code was taking about 12% and most of the chunk was on tightvnc about 60% (maybe because of the frame window being displayed).

This is the code i was running;

import cv2

#capture from camera at location 0
cap = cv2.VideoCapture(0)
#set the width and height, and UNSUCCESSFULLY set the exposure time
cap.set(3,320)
cap.set(4,240)
cap.set(5, 30)

while True:
ret, img = cap.read()
cv2.imshow(“input”, img)
#cv2.imshow(“thresholded”, imgray*thresh2)

key = cv2.waitKey(10)
if key == 27:
break

cv2.destroyAllWindows()
cap.release()

And also the resolution i forced the camera to in the opencv code is the one displayed after running v4l2-ctl -V;
root@beaglebone:~/Project/Testing# v4l2-ctl -V
Format Video Capture:
Width/Height : 320/240
Pixel Format : ‘YUYV’
Field : None
Bytes per Line: 640
Size Image : 153600
Colorspace : SRGB
root@beaglebone:~/Project/Testing#

What you figured out about bandwidth is really a serious issue. I have a friend who did not experience this problem on their RPi (only much higher resolutions resulted in select timeout messages, message because i don’t think it is an error) maybe because it has many USB ports meaning higher bandwidth compared to BBB with only one.

I wonder what will happen when connecting the BBB wirelessly, with a wifi dongle and camera on a USB hub.

It does have MJPEG but opencv is converting the format to YUYV. And also
does your board have I/O pins digital and analogue?

It has lots of GPIO's, but I don't know if any of them are analog: A20-OLinuXino-LIME - Open Source Hardware Board

João M. S. Silva

I suppose you were using OpenCV in C++. For setting the desired resolution in C++ you have to do as you did in the Python code. Something like: http://stackoverflow.com/a/24867771

You should also set it to MJPEG, if possible: http://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=cv_cap_prop_frame_width#videocapture-set

Please be more structured and succinct in what your current issue is so that it's easier to help. Have you considered the code from https://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html?

Is your code in Python or C++?

In order to solve the larger problem you have to break it down into smaller ones.

João M. S. Silva