Yes of course
> I am trying to write a simple program that will capture images from a
> webcam and work on them.
>
> I have set the
> classifierName = "C:\\OpenCV2.2\\data\\haarcascades\
> \haarcascade_frontalface_alt.xml";
>
> Every time i try to run the sample code i encounter a fatal error (1)
> after
>
> FrameRecorder recorder = new OpenCVFrameRecorder("output.avi",
> width, height);
> recorder.start();
>
> I have installed the latest javacv and opencv . Do I need something
> else?
Ah, it seems the precompiled highgui of OpenCV 2.2 does not work with
the "CV_FOURCC_DEFAULT", but it works with "-1", so I guess I will
change the default in the next release of JavaCV.. for now, you can work
around that by putting this line before "recorder.start()":
recorder.setCodecID(-1);
> My second question I have 2 webcams (1 internal in laptop 1 external
> via usb [I'm trying to run the probgram only with the internal
> activated]) chow can I make javacv capture images ONLY from the
> external?
Just use another number than "0" when creating a new FrameGrabber. Try
1, 2, etc..
Samuel
-1 is not a valid camera number
> When I change the number to any>0 i get the same error.
Then OpenCV does not see any other camera than the first one it seems,
so you should contact the OpenCV people to understand why your camera is
not supported
> If I chose the internal cammera I get another list to select a
> compressor
>
> Anything other than Microsoft RLE gives me a black sample tile (a
> frame with full black inside) and a black avi output file
I am not responsible for what OpenCV captures. If it captures all black
images, then JavaCV will get all black images. You should contact the
OpenCV people to understand why your camera is not supported
> the RLE crashes the application
> "
> Exception in thread "main" java.lang.Exception: cvCreateVideoWriter():
> Could not create a writer
> at
> com.googlecode.javacv.OpenCVFrameRecorder.start(OpenCVFrameRecorder.java:
> 55)
> at Demo.main(Demo.java:76)
> "
It seems OpenCV does not like "Microsoft RLE". You should, again,
contact the OpenCV people to understand why that is
Samuel
Ah, I remember rumors about Microsoft dropping support for Video for
Windows since Vista.. I guess they were true.
I suppose this means we need to use DirectShow to capture from Webcams
in Windows Vista and 7. OpenCV supports capture from DirectShow via
another library called videoInput, but it's not compiled in by default.
>
> Well almost like a charm.
>
> As I wrote above I have 2 cameras , no matter what i wrote in
> OpenCVFrameGrabber( number ); I either got an error or the image from
> the internal cammera.
> I solved this by manually deactivating the internal camera in the
> hardware menager and everything works.
Hum, you could try numbers starting from 200, which correspond to VFW.
i.e.: 201, 202..
Thanks for investigating and reporting!
Samuel
Would you have some code to show us? The shortest program that causes the problem...
Samuel
I see, your startCamera() method is running on the EDT (Event Dispatch
Thread), so it's a bit normal for the UI to freeze in that case. You
have to run long-lasting operations on the separate thread. An easy way
to do that is by using a SwingWorker:
http://download.oracle.com/javase/tutorial/uiswing/concurrency/worker.html
Samuel
Just to let you know that I fixed that in the latest release:
* New `videoInputLib` wrapper and corresponding
`VideoInputFrameGrabber` to capture using DirectShow, useful under
Windows 7 where OpenCV and FFmpeg can fail to capture using Video for
Windows (issue #58)
Samuel
On 2011-03-01 06:53, AzazelPL wrote: