opencv Image zu PIL Fehler

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
ciko
User
Beiträge: 2
Registriert: Dienstag 12. Oktober 2010, 10:24

Moin.
Ich habe ein kleines Problemchen betreffend die Konvertierung eines per opencv von meiner Webcam geholten Bildes in ein PIL Image.
Mein Code:

Code: Alles auswählen

from opencv import highgui
import PIL
camera = highgui.cvCreateCameraCapture(-1)

def getimage():
    im = highgui.cvQueryFrame(camera)
    return opencv.adaptors.Ipl2PIL(im) 

im = getimage()
print im.size()
Führt zum Fehler:

Code: Alles auswählen

Traceback (most recent call last):
  File "/home/gendor/Desktop/Touch.py", line 18, in <module>
    im = getimage()
  File "/home/gendor/Desktop/Touch.py", line 16, in getimage
    return opencv.adaptors.Ipl2PIL(im)
  File "/usr/lib/python2.6/site-packages/opencv/adaptors.py", line 80, in Ipl2PIL
    raise TypeError, 'must be called with a cv.CvMat!'
TypeError: must be called with a cv.CvMat!
Das Kamera Lämpchen geht beim Auführen kurz an, dann schmeißt er den Fehler.
Ich konnte durch googlen leider keine Lösung finden, und auch wenn man sich die adaptors.py etwas genauer ansieht sehe ich das Problem nicht.

OS ist wie unschwer zu erkennen Linux, Pakete sind auf dem neusten Stand.
Jemand ne Idee?
ciko
Benutzeravatar
b.esser-wisser
User
Beiträge: 272
Registriert: Freitag 20. Februar 2009, 14:21
Wohnort: Bundeshauptstadt B.

Hier (ubuntu 10.04, eee-pc interne Cam) funktioniert dein Code.

Funktioniert deine Kamera? (mit opencv?)

hth, Jörg

ps.: "Pakete sind auf dem neuesten stand" ist nicht besonders nützlich, wenn du nicht mindestens deine Distro angibst - die offiziellen opencv-docs beziehen sich auf Version 2.1, die Version, die ich hier hab ist noch 2.0.
ciko
User
Beiträge: 2
Registriert: Dienstag 12. Oktober 2010, 10:24

Distri ist ein Fedora 13. Auf dem neuesten Stand bezieht sich auf die aktuellste in der Paketverwaltung bzw. auf der Website verfügbare Version.
Die Kamera lässt sich in Cheese ohne Probleme ansteuern. Auch beim Ausführen des Codes leuchtet sie kurz auf, was ich als Hinweis darauf deute, dass sie richtig erkannt wird.
Ich versuche der Kamera mal ein Bild zu entlocken wenn ich sie mit opencv ansteuere..
MFG
ciko

Edit:
Im Interpreter habe ich opencv noch eine Meldung entlocken können:

Code: Alles auswählen

>>> cam = highgui.cvCreateCameraCapture(-1)
HIGHGUI ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream.: Ungültiger Dateideskriptor
HIGHGUI ERROR: V4L: Pixel format of incoming image is unsupported by OpenCV
GStreamer Plugin: Embedded video playback halted; module v4lsrc3 reported: Die Einstellungen konnten nicht aus der Ressource gelesen oder in die Ressource geschrieben werden.
Sieht aus als wenn er die Cam nicht mag?

Edit2:
Ein etwas anderer Weg führt zum selben Ergebnis, gibt sich allerdings etwas gesprächiger:

Code: Alles auswählen

>>> capture = cv.CaptureFromCAM(0)
HIGHGUI ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream.: Ungültiger Dateideskriptor
HIGHGUI ERROR: V4L: Pixel format of incoming image is unsupported by OpenCV

(<unknown>:4932): GStreamer-CRITICAL **: 
Trying to dispose element appsink14, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(<unknown>:4932): GStreamer-CRITICAL **: 
Trying to dispose element ffmpegcsp14, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(<unknown>:4932): GStreamer-CRITICAL **: 
Trying to dispose element fakesink, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(<unknown>:4932): GStreamer-CRITICAL **: 
Trying to dispose element typefind, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(<unknown>:4932): GStreamer-CRITICAL **: 
Trying to dispose element decodebin14, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

Speicherzugriffsfehler (Speicherabzug geschrieben)
Edit3:
VLC kann die Webcam per Option Video4Linux2 problemlos ansteuern. Ich kann mir also nicht vorstellen das es da ein Problem gibt?
Was mir gerade noch aufgefallen ist: VLC gibt mir als Codev Format YUV 420 aus, also n rawes Avi. Das unterstützt Opencv aber laut dieser Seite hier nativ? Warum kann er die Daten dann nicht lesen? http://opencv.willowgarage.com/wiki/VideoCodecs
Antworten