I'm trying to capture images from an IP camera in real time. The stream works perfectly well in VLC, but OpenCV's cvQueryFrame()
seems to jumble and corrupt the incoming images to the point of no recognition.
Again, capturing from file works fine, but not a live stream. In case it makes a difference, I'm using an rtsp connection URL; I've also tried this with two different camera models (different brands), and the problem remains.
Besides, the (I'm assuming) codec is outputting several errors of the following kind:
Error at MB: 1746
and concealing 6000 DC, 6000 AC, 6000 MV errors
.
What can I do?
Update: The first error in the sequence is always cannot parallelize deblocking type 1, decoding such frames in sequential order
Update 2: Alright, it seems that OpenCV/FFMPEG has an issue with rtsp/h264 streams. I've tried the Qt Phonon library, which also doesn't work, and I've given the Live555 library a quick overview. This last appears to work, in the sense that everyone says it does, and the application example (OpenRTSP) in fact plays my stream well. However, to be quite honest, getting to grips with the Live555 code seems like a lengthy affair which I can hardly afford right now. Barring any other alternative, I guess I'll have to go that route.
Is there any other solution that comes to mind?
Update 3: I got the test RTSP client from the Live555 code to work, so I know how to extract h264 frame information from a stream, but now I need to recombine that frame information into actual displayable frames, which doesn't seem like something straightforward! Anyone familiar with Live555 know how to do this? Thanks.
It seems you need an extra software layer to capture the stream packets and reconstruct the frames locally, and then feed them to openCV. You can easily achieve this with libVLC. This would also avoid codec problems since you can parse almost all codecs with libVLC and then feed raw frames to openCV.