Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1,365 Views

Missing Codecs on galileo gen1

Hello guys, we're having some problems with the codecs here on Galileo. Our project uses OpenCV in Python and it reads the stream from a webcam and tries to save it in a video file (code in the end of the post).

First we thought that our problem was related to the VideoWriter function, but later we found that is a codec related problem. Searching in the internet we found this link, which, we know, is not for Galileo, but shows the same problem as us: http://stackoverflow.com/questions/24170952/opencv-videowriter-will-not-open linux - OpenCV VideoWriter will not open - Stack Overflow

In this link, the user provides a code that checks any installed codecs (https://gist.github.com/chriscollins/11ff2f43852e1c93dae8 Quick Python program for testing VideoWriter instantiation · GitHub). We ran the same code and we had a negative for every codec.

Also, we found a post here on the Intel forums about the gstreamer package ( ), but our opkg update returns the version 1.5 on the repository, which does not contain the gstreamer package, which exists on the 1.1 version. We tried to install the gstreamer located in the 1.1 version but with no success.

Here is our code in Python:

import sys

import numpy as np

import cv2

import cv

camera_port = 0

# ramp_frames = 30

camera = cv2.VideoCapture(camera_port)

camera.set(3,960)

camera.set(4,720)

fourcc = cv.CV_FOURCC('M','J','P','G')

size = (int(camera.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)), int(camera.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)))

out = cv2.VideoWriter('video.avi', fourcc, 25, size, 1);

out.open('video.avi', fourcc, 25, size, 1)

a=100

if out.isOpened():

while (a > 0):

ret, frame = camera.read()

if (a < 2):

file = "/camera/test_image.png"

cv2.imwrite(file, frame)

print a,

cv2.waitKey(10)

out.write(frame)

a=a-1

else:

print("Eita")

camera.release()

out.release()

cv2.destroyAllWindows()

Anyone has a solution to our problem?

Thank you very much!

Tags (1)
0 Kudos
6 Replies
Highlighted
Employee
20 Views

Hi EngComp011,

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:

root@galileo:~# python

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__

>>> __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 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

Regards,

Charlie

0 Kudos
Highlighted
Beginner
20 Views

Charlie,

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 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!

0 Kudos
Highlighted
Employee
20 Views

Hi EngComp011,

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?

Regards,

Charlie

0 Kudos
Highlighted
Employee
20 Views

Hi EngComp011,

I would like to know if you were able to record video using your webcam.

Kind regards,

Charlie

0 Kudos
Highlighted
Beginner
20 Views

Hey CMata_Intel,

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.

Thank you!

0 Kudos
Highlighted
Employee
20 Views

Hi EngComp011,

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))

Regards,

Charlie

0 Kudos