Gstreamer Opencv backend doesn't support this codec acutally - opencv

This is a problem I got when launching my own project,
OpenCV Error: Unsupported format or combination of formats (Gstreamer
Opencv backend doesn't support this codec acutally.) in
CvVideoWriter_GStreamer::open, file
/home/htf/Downloads/opencv-2.4.9/modules/highgui/src/cap_gstreamer.cpp,
line 505
Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.
terminate called after throwing an instance of 'cv::Exception'
what(): /home/htf/Downloads/opencv-2.4.9/modules/highgui/src/cap_gstreamer.cpp:505:
error: (-210) Gstreamer Opencv backend doesn't support this codec
acutally. in function CvVideoWriter_GStreamer::open
Aborted (core dumped)
opencv version: 2.4.9
I am new to OpenCV, does anyone know how to fix this problem? Your clues would be appreciated too.

Looks like you passed an unsupported fourcc argument to the VideoWriter class.
The list of supported values of fourcc for CvVideoWriter_GStreamer in OpenCV 2.4.9 can be found at: https://github.com/opencv/opencv/blob/2.4.9/modules/highgui/src/cap_gstreamer.cpp#L462.
Just out of curiosity, why are you using a self compiled version of OpenCV?

Related

GStreamer: cannot link elements in `CvVideoWriter_GStreamer::open` running OpenCV C++ application

I am trying to run an OpenCV program that opens a USB cam and streams the video.
The program compiles but when I run it I get the following GStreamer exception (which seems unrelated to OpenCV or the C++ source code):
(TLD:5263): GStreamer-CRITICAL **: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
OpenCV Error: Unspecified error (GStreamer: cannot link elements
) in CvVideoWriter_GStreamer::open, file /home/odroid/Desktop/middleware/CppLibs/opencv-2.4.13.6/modules/highgui/src/cap_gstreamer.cpp, line 1464
terminate called after throwing an instance of 'cv::Exception'
what(): /home/odroid/Desktop/middleware/CppLibs/opencv-2.4.13.6/modules/highgui/src/cap_gstreamer.cpp:1464: error: (-2) GStreamer: cannot link elements
in function CvVideoWriter_GStreamer::open
I am running on odroid.
Have anybody had the same problem?
I was thinking it is a package dependency problem but I have installed xorg libgl-gst libgl1-mesa-* so I am quite lost at the moment.
EDIT
To be precise it is an older version of OpenCV: it is the 2.4.13.6.
The lines initializing VideoCapture are the following (I reported only the relevant ones):
int main(int argc,char** argv){
string devId;
VideoCapture capture;
if(argc>4)
{
int captureNumber;
string deviceId=argv[1];
captureNumber=atoi(argv[1]);
capture.open(captureNumber);
}
EDIT 2
On OSX the same code works without giving this exception (there were only dynamic libraries problem).

(process:10728): GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed

I am using cap = cv.VideoCapture(0)
When opening the camera to record video, the program will work but he prompts me ((process:10728): GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed
) I don't know what the reason is, is it because of a problem with your cmake or a problem with the installation?
I had similar issue in version 3.4.4, compiled with gstreamer support. Syntax "cv2.VideoCapture(0)" just stopped working. I had all gst-* libraries installed, so most of answers wasn't helpful. But finally changing VideoCapture argument to full device path ("/dev/video0") helped.
Try:
cap = cv2.VideoCapture(0, cv2.CAP_V4L)
From this SO Answer
it works in my project

Highgui V4L error when using MJPEG for OpenCV

I am running OpenCV on an ARM A9 processor. I am trying to use MJPEG so my C920 webcam runs a lot faster. The beginning of my program is as follows:
VideoCapture cap(CV_CAP_ANY);
cap.set(CV_CAP_PROP_FOURCC, CV_FOURCC('M', 'J', 'P', 'G'));
cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
The programs compiles, however, the following error appears when I run it:
HIGHGUI ERROR: V4L: Property <unkown property string>(6) not supported by device
I am completely clueless on what to do. Does anyone have an idea of why this error is occurring?

Error Handling in opencv gpu

How to handle opencv gpu exceptions? Is there any specific set of error code api for opencvgpu exception handling?
I tried searching a lot but I only got 1 error code i.e. CV_GpuNotSupported.
Please help me out.
While I'm assuming that you know that CV_GpuNotSupported is NOT how OpenCV handles GPU exceptions, and in fact, it handles error when you try to call gpu methods without compiling OpenCV with -DHAVE_CUDA or -DHAVE_OPENCL, the way OpenCV (I also assume the newest OpenCV released version, 2.4.5) handles error codes, is defined in these files:
For methods that use NVIDIA CUDA:
https://github.com/Itseez/opencv/blob/2.4.5/modules/gpu/src/error.cpp
https://github.com/Itseez/opencv/blob/2.4.5/modules/gpu/src/precomp.hpp
For methods that use OpenCL:
https://github.com/Itseez/opencv/blob/2.4.5/modules/ocl/src/error.cpp
https://github.com/Itseez/opencv/blob/2.4.5/modules/ocl/src/precomp.hpp
As for the API, you can use cv::gpu::error or cv::ocl::error. Or to get the error string, getErrorString for cv::gpu and getOpenCLErrorString. And by the way for CUDA's error you have to specify whether it's an NPP, NCV, cufft, or cublas error.

Stack around variable corrupted when using cvBlobsLib (OpenCV)

I am trying to do simple image processing with OpenCV and the cvBlobsLib in Visual C++ 2008, and I get an error message when I try to create a CBlobResult object
IplImage* original = cvLoadImage("pic6.png",0);
cvThreshold(original, original, 100, 255, CV_THRESH_BINARY);
CBlobResult blobs = CBlobResult(original, NULL, 255);
The message is the following:
Run-Time Check Failure #2 - Stack around the variable blobs was corrupted
Why does this happen? How should I create this object? Thank you very much for your help.
Sorry. Actually it was my fault. I was trying to compile the debug version of my project with the release version of the cvBlobsLib library. As soon as I linked the debug version it worked.

Resources