I'm trying to reduce the resolution of a video streaming got it from the Pi Camera (using uv4l driver).
Now, it seems that when trying to modify default resolution, there is some kind of problem or conflict produced by V4L.
Here's the critical part of the code:
Code: Select all
#!/usr/bin/env python
CAMERAID=1
HAARCASCADE="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml"
MOVIE="/home/gijs/Work/uva/afstuderen/data/movie/heiligenacht.mp4"
STORE=False
OUTPUT="/home/gijs/testje.mp4"
FPS = 1000/15
SCALING = 2
THRESH = 80
XWINDOWS = 2
FACE_BORDER = 0.2
HUEBINS = 30
SATBINS = 32
import cv
import time
import sys
import math
class GetHands:
def __init__(self):
self.threshold_value = THRESH # value associated with slider bar
self.capture = cv.CaptureFromCAM(0)
[b] cv.SetCaptureProperty( self.capture, cv.CV_CAP_PROP_FRAME_WIDTH, 320 );
cv.SetCaptureProperty( self.capture, cv.CV_CAP_PROP_FRAME_HEIGHT, 200 );[/b]
self.hc = cv.Load(HAARCASCADE)
self.ms = cv.CreateMemStorage()
[b]self.orig = cv.QueryFrame(self.capture)[/b]
if not self.orig:
print "can't get frame, check camera"
sys.exit(2)
self.width = self.orig.width
self.height = self.orig.height
self.size = (self.width, self.height)
self.smallwidth = int(self.width/SCALING)
self.smallheight = int(self.height/SCALING)
self.smallsize = (self.smallwidth, self.smallheight)
When not defining the resolution of the video, there are no errors on the execution, however, the video runs by default resolution, which 640x480 (which doesn't work for me, the video must be defined @ 320x240 and below).
Here is the error:
pi@raspberrypi ~/Desktop $ sudo python skin.py
/dev/video0 does not support memory mapping
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
Unable to stop the stream.: Bad file descriptor
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
HIGHGUI ERROR: V4L: Initial Capture Error: Unable to load initial memory buffers.
can't get frame, check camera
*** glibc detected *** python: double free or corruption (!prev): 0x01082e68 ***
Any help will be very much appreciate it.
Thank you very much,
Marco