Hi, I am experiencing problems with a Vizard script that makes use of some plug-ins that a previous member of the lab wrote a while ago to connect to a webcam. That person is now out of contact, so I'm hoping to get some help here.
The webcam connection relies on a DLL file called 'capture.dll' which was used to get information from the connected webcam. Right now, we've determined that the script chokes on a line that invokes a Webcam class from the capture module. The relevant code looks like this:
facetrackNet.py
Code:
import facetrack
facetracker = facetrack.WebcamTrack()
facetrack.py
Code:
import capture
import neven
import math
import threading
import Queue
import chunk
import datetime
import re
class WebcamTrack:
def __init__(self,
width = 320, height = 240, fps = 30, id = 0,
minEyeDist = 20, maxEyeDist = 100, threshhold = 0.4,
fdInit = "V_FD_prec_100.bsk",
ffdInit = "VFFD_22n_101.bsk",
fftInit = "VFFT_22n_103.bsk"):
self.webcam = capture.Webcam(width, height, fps, id,
self._webcamCallback, 0) # CHOKES ON THIS LINE
self.fft = neven.Fft(self.webcam.width(), self.webcam.height(),
minEyeDist, maxEyeDist,
fdInit, ffdInit, fftInit)
self.threshhold = threshhold
self.face = None # Current face. May be None.
self.validFace = GENERIC_FACE # Most recent non-None face.
self.image = "\0" * (self.webcam.width() * self.webcam.height())
self.dataLock = threading.Lock()
self.queue = Queue.Queue(-1)
self.thread = threading.Thread(name = "WebcamTrack" + str(id),
target = _webcamTrackThread,
args = (self,))
self.thread.setDaemon(True)
self.thread.start()
# and so on...
The code chokes on the line "self.webcam = capture.Webcam(width, height, fps, id, self._webcamCallback, 0)". The error I get is:
Code:
ERROR in Webcam: Device has no acceptable format
Traceback (most recent call last):
File "facetrackNetBigInsert.py", line 326, in mytimer
facetracker = facetrack.WebcamTrack()
File ".\facetrack.py", line 957, in __init__
self._webcamCallback, 0)
SystemError: NULL result without error in PyObject_Call
As far as I can tell based on the Python sys.path set up on this machine, 'import capture' refers to a 'capture.dll' file. I then presume that this DLL file was compiled based on some C/C++ code in a Visual Studio project. After rooting around a bit, I've found what I think is the C/C++ code that the DLL was compiled from, but the Capture.h and Capture.cpp files I found don't include any sort of class or method named 'Webcam'.
I don't have much experience with DLL's (I barely know what they are or how they work), much less compiling C/C++ projects into DLL's and then linking them to Python, so if someone could provide a link that explains how that works, that would be helpful.
I apologize if all this boils down to 'Please debug some code for me', but at this point I'm rather lost and would appreciate any help I can get. If someone is willing to take a look at the code, I'd be glad to email it to you and would be very appreciative of the help.
One other thing that may be useful: This program was working until just a couple weeks ago. I can think of a couple changes made that might have affected this:
1. I changed the Windows environment path used to look up Python so that I could use Python from the Windows command line. This was formerly "C:\Python", which was a nonexistent directory; I changed it to "C:\Python23" (we are using Python 2.3 because the plug-ins were written for Vizard 2.5, which uses Python 2.3). After the problem with the program started, I tried changing the environment path variable back, but this made no difference.
2. I installed a new device on the machine that required a PCI card which I also added. In doing so, I unplugged everything from the machine to make it easier to open up, and then re-plugged everything in afterwards, including the webcam. I don't know if this would affect the DLL's ability to locate the webcam, but some testing seems to suggest no because a getWebcamNames() method in the capture library still correctly lists the webcam attached to the computer.
Hope someone can help out, thanks very much in advance!
christopher lin