WorldViz User Forum  

Go Back   WorldViz User Forum > Plug-in development

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 01-24-2008, 04:51 PM
v-clizzin v-clizzin is offline
Member
 
Join Date: Sep 2006
Posts: 15
problems with webcam plug-in

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
Reply With Quote
  #2  
Old 01-24-2008, 07:25 PM
mjabon mjabon is offline
Member
 
Join Date: Jul 2007
Posts: 63
I am working with Chris on this problem and I'd like to add that we'd be really appreciative if anyone has documentation on how Vizard works with dlls, etc. We have read the documentation on sensor.h and creating a sensor, but we haven't found anything on general C++ classes, how they need to be created, what paths need to be set, etc so that we can just say simply:

import newmodule.py

when newmodule is actually written in C++

Thanks!
Reply With Quote
  #3  
Old 01-25-2008, 04:06 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
When you call:

import module

Python will search the system path for either module.py or module.dll. You don't have to specify what kind of module it is when you import it.

Either way, from the information you provided, it seems that the module is being imported fine. The problem seems to be that one of its functions is failing. Are you sure that the module does not depend on any 3rd party DLLs that might have gone missing on your system?

Also, to be sure that you are using the correct module, execute the following code immediately after importing the capture module:
Code:
print capture.__file__
This will print the path of the module.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
face problems in Vizard 3.0 v-clizzin Vizard 2 09-19-2007 04:32 PM
Problems with making multiple objects from one .wrl? mjabon Vizard 3 07-10-2007 02:23 PM
v 1.09 problems with STEREO/HMD modes hotspur1 Vizard 19 10-17-2005 03:29 AM
Viz PPT 1 problems Adam Vizard 3 08-30-2005 11:54 AM
Problems with lighting in 2.0 murm Vizard 6 04-21-2004 10:59 AM


All times are GMT -7. The time now is 05:15 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC