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).
Related
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?
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
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?
I'm getting errors in XCode attempting to build OSG for iOS 7.0. I've followed these instructions:
http://www.openscenegraph.org/index.php/documentation/platform-specifics/ios/23-configuring-cmake-for-ios
with the additional step of changing the framework version to 7.0 in the CMakeLists.txt file, as using the default of 6.0 caused XCode to complain about an unknown framework. I chose the IPHONE_SIMULATOR option.
When I attempt to build the project after generating it with CMake, I get three errors in osgDB complaining about stat64, and one about a missing header (perhaps related but I get the feeling something else is going on):
/Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:153:9: error: call to unavailable function 'stat64': not available on iOS
if( stat64( path.c_str(), &stbuf ) == 0 )
^~~~~~
In file included from /Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:87:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/stat.h:380:5: note: candidate function has been explicitly made unavailable
int stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
^
/Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:176:13: error: call to unavailable function 'stat64': not available on iOS
if( stat64( dir.c_str(), &stbuf ) < 0 )
^~~~~~
In file included from /Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:87:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/stat.h:380:5: note: candidate function has been explicitly made unavailable
int stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
^
/Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:301:10: error: call to unavailable function 'stat64': not available on iOS
if ( stat64(filename.c_str(), &fileStat) != 0 )
^~~~~~
In file included from /Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:87:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/stat.h:380:5: note: candidate function has been explicitly made unavailable
int stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
^
/Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:881:18: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
^
4 errors generated.
CMake version is 2.8-12, OSG 3.2.0, XCode 5.0.2.
Various things I've tried:
iphone instead of iphone_simulator setting; iphone complains about openthreads being a dynamic library, even though I unchecked DYNAMIC_OPENTHREADS in cmake. It does, however, appear to make the other errors go away.
Blowing away the build directory and re-doing the config step, several times
Manually setting the framework settings for ios in xcode after configuration
I did previously get an OSX build of OSG to work without issue, for what it's worth.
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.