DirectShow WebcamVideo Capture Issues

Hello,

I’m having issues capturing from a DataPath Vision E2s capture card.

I’m running Windows 7 x64, with Panda 1.7.2. Previewing the videos in the preview software that comes with the card looks fine. Creating a test graph and routing the capture into a renderer in GraphEdit also works fine.

Here’s the code that I’m using:

import sys 

from pandac.PandaModules import * 
from direct.directbase import DirectStart 

# manually select the video mode 
option = WebcamVideo.getOption(0) 
cursor = option.open() 
videoTexture = Texture('movie') 
cursor.setupTexture(videoTexture) 
# calculate the same as openCVTexture has as function 
videoTextureScale = Vec2(option.getSizeX()/float(videoTexture.getXSize()), option.getSizeY()/float(videoTexture.getYSize())) 

# under windows the webcam must be updated manually 
def updateVideo(task): 
  if cursor.ready(): 
    cursor.fetchIntoTexture(0, videoTexture, 0) 
  return task.cont 
taskMgr.add(updateVideo, 'updateVideo') 
  

# generate a card to show the texture on 
cardMaker = CardMaker('cardMaker') 
# define the card size 
#cardMaker.setFrame(-videoTextureScale[1]/2.,videoTextureScale[1]/2.,-videoTextureScale[0]/2.,videoTextureScale[0]/2.) 
cardMaker.setFrame(-videoTextureScale[1],videoTextureScale[1],-videoTextureScale[0],videoTextureScale[0]) 
# set the uv coordinates of the card, y-scale must be reversed 
cardMaker.setUvRange(Point2(videoTextureScale[0],0), Point2(0,videoTextureScale[1])) 

# create a card and attach to render 
card = render.attachNewNode(cardMaker.generate()) 
card.setTexture(videoTexture) 
card.setTwoSided(True) 

# rotate it 
#card.hprInterval(10,Point3(360,0,0)).loop() 

base.disableMouse() 
base.camera.setPos(0,-3,0) 

run() 

And here is the result I’m getting:

I’ve had other issues with other capture cards that I never was really able to solve, but I’ve never even seen the “Could not select desired video resolution” error before.

Any thoughts?

Thanks much!

Hmm, that error message is generated within code in Panda, and it indicates that IAMStreamConfig::SetFormat() returned something other than S_OK.

To research it further, you’ll probably need to be comfortable with C++, and add a few additional output statements around the relevant calls, in webcamVideoDS.cxx. Are you able to do this?

Thanks!
David

Well, I’ll have to dust off my C++ gloves, but I’m always up for a challenge!

Well, I was going to add the following… not sure how functional/helpful this will be…

    cerr << "hresult: " << hResult << "\n";
    cerr << "PIN_CATEGORY_CAPTURE: " << PIN_CATEGORY_CAPTURE << "\n";
    cerr << "MEDIATYPE_Video: " << MEDIATYPE_Video << "\n";
    cerr << "_pSrcFilter: " << _pSrcFilter << "\n";
    cerr << "IID_IAMStreamConfig: " << IID_IAMStreamConfig << "\n";

but when I try to “makepanda” I get the following error:

Always something…
Any thoughts?

Hmm, I’m not sure, but perhaps it would be better to build the latest cvs trunk code, rather than 1.7.2.

David

Thanks, David.

I’ve snagged the latest code, and got past that error… but now I’m getting another one:

[ 32%] Building C++ object built/tmp/vision_composite1.obj
vision_composite1.cxx
e:\panda3d-testbuilds\cvs-panda3d-092911-1112\panda\src\vision\openCVTexture.h(89) : error C2061: syntax error : identifier 'ssize_t'
e:\panda3d-testbuilds\cvs-panda3d-092911-1112\panda\src\vision\webcamVideoCursor
OpenCV.h(40) : error C2061: syntax error : identifier 'ssize_t'
e:\panda3d-testbuilds\cvs-panda3d-092911-1112\built\include\texturePool.I(40) :
fatal error C1903: unable to recover from previous error(s); stopping compilation
Storing dependency cache.
Elapsed Time: 13 min 3 sec

Build terminated.

E:\Panda3D-TestBuilds\cvs-panda3d-092911-1112>

I tried excluding OpenCV, but I think I need it for what I’m testing (do I?), and although it did compile, it resulted in an error when running the test script:

Seems like it might be referencing some stuff incorrectly though, as the path to my test build is actually
E:\Panda3D-1.7.2\AWBUILDS\caminfo2\bin
so I’m not sure why it’s looking in the original Panda3D build… my panda.pth file specifies the aforementioned path.

I’m obviously doing something wrong, but am not sure where to go next.
Any thoughts?

Thanks!

Well, first, I’d suggest uninstalling any previous versions of Panda to guarantee that you don’t get it conflated with the version you’re trying to run. (If you’re careful setting up your environment, you can keep multiple Pandas installed in parallel, but you do have to be careful, and it appears that you’re getting some bleed-through so something’s not quite right in your environment.)

And the next thing is, you’ll have to fix that compilation error before you can run your dev build. Which compiler are you using? One easy (and hacky) thing to do is to put “typedef long ssize_t;” in the beginning of openCVTexture.h.

David