Could you post the error you are getting after running python yourcode.py?
What is the output of running uname -a?
Then, check the openCV you have installed with:
Python 2.7.3 (default, Sep 29 2015, 22:25:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cv2 import __version__
If you want to install gstreamer you can run the command opkg install http://iotdk.intel.com/repos/1.1/iotdk/i586/gstreamer_0.10.36-r2_i586.ipk and if you want to change the repository address you need to do it in the file /etc/opkg/iotdk.conf. What are you getting after trying to install gstreamer from the 1.1 repository?
Is the board able to run a simple code like:
import cv2.cv as cv capture = cv.CaptureFromCAM(0) img = cv.QueryFrame(capture) cv.SaveImage("camera.jpg", img
1) The output for our 'camera2.py' that runs the code above is:
root@galileo:/camera# python camera2.py VideoWriter failed to open!
The text on line 2 is my print for the:
if out.isOpened(): #if conditions else: print("VideoWriter failed to open!")
2) The output for uname -a is:
root@galileo:/camera# uname -a Linux galileo 3.8.7-yocto-standard #1 Tue Jun 9 22:07:14 GMT 2015 i586 GNU/Linux
3) Running the code you asked gives us:
root@galileo:/camera# python Python 2.7.3 (default, May 29 2015, 21:31:34) [GCC 4.9.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from cv2 import __version__ >>> __version__ '2.4.9'
4) For the command to install the gstreamer, we have:
Downloading http://iotdk.intel.com/repos/1.1/iotdk/i586/gstreamer_0.10.36-r2_i586.ipk. Installing gstreamer (0.10.36-r2) on root. Configuring gstreamer.
And after that, we try to run our code again and we get the same output as before.
5) For the code that you asked us to run, we do have a simple code that captures an image from the camera and saves it as a png file:
import numpy as np import cv2 import cv cap = cv2.VideoCapture(-1) cap.set(cv.CV_CAP_PROP_FRAME_WIDTH, 720); cap.set(cv.CV_CAP_PROP_FRAME_HEIGHT, 480); if not cap.isOpened(): print "The camera was not able to be opened!" sys.exit(-1) else: print "The camera works! Smile! (:" ret, frame = cap.read() cv2.imwrite('testImage.jpg', frame) cap.release()
We used this code to test if our webcam was working properly. The image is created and works well.
Thank you for your answer!
Do you have updates on this?
Have you tried to set the width and height with different sizes?
I’ve been testing your code but I’m not receiving the message “VideoWriter failed to open! ” neither I’m able to save a video using your code.
Have you tried to install the codecs?
Still didn't got any updates. Also, I didn't install any codecs because I couldn't find any easy solution to do it.
Right now I decided to move on from recording a video and I'm going to use a burst of images to do what I need to do.
Also, answering to your othe question: I did try to change the width and height sizes, and image capturing works well, but not recording videos.
I believe that installing the codecs would solve my problem, but as I said before, I couldn't find any easy way to do it.
If you get better results don’t hesitate to share them with us, I know there will be other makers interested in this.
If you want to try one last thing:
fourcc = cv2.cv.CV_FOURCC(*'XVID') out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))