Hey guys! I installed OpenCV here and am using it with C ++. I tested the image, it worked, I tried opening the video it worked, I compiled it on another system on that same note, it worked! But here is giving a failure when opening the Webcam, when I compile this code:
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
int main( int argc, char ** argv ){
cv::VideoCapture cap( 0 );
cv::Mat img;
while( true ){
cap.read( img );
cv::imshow( "Minha Webcam (VĂdeo)", img );
cv::waitKey( 1 );
}
//std::getline( std::cin, path );
return 0;
}
With g++: g++ -I/usr/include/opencv4 -I/usr/include/opencv4 -g -o binary show-video-2.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio -std=c++11
And try run binary, i get this message:
[ INFO:0] global /var/tmp/portage/media-libs/opencv-4.5.1/work/opencv-4.5.1/modules/videoio/src/videoio_registry.cpp (197) VideoBackendRegistry VIDEOIO: Enabled backends(7, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); CV_IMAGES(960); CV_MJPEG(950); UEYE(940)
[ WARN:0] global /var/tmp/portage/media-libs/opencv-4.5.1/work/opencv-4.5.1/modules/videoio/src/cap_gstreamer.cpp (501) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[ INFO:0] global /var/tmp/portage/media-libs/opencv-4.5.1/work/opencv-4.5.1/modules/videoio/src/backend_plugin.cpp (385) getPluginCandidates VideoIO pluigin (MSMF): glob is 'libopencv_videoio_msmf*.so', 1 location(s)
[ INFO:0] global /var/tmp/portage/media-libs/opencv-4.5.1/work/opencv-4.5.1/modules/videoio/src/backend_plugin.cpp (392) getPluginCandidates - /usr/lib64: 0
[ INFO:0] global /var/tmp/portage/media-libs/opencv-4.5.1/work/opencv-4.5.1/modules/videoio/src/backend_plugin.cpp (396) getPluginCandidates Found 0 plugin(s) for MSMF
[ INFO:0] global /var/tmp/portage/media-libs/opencv-4.5.1/work/opencv-4.5.1/modules/videoio/src/backend_plugin.cpp (385) getPluginCandidates VideoIO pluigin (UEYE): glob is 'libopencv_videoio_ueye*.so', 1 location(s)
[ INFO:0] global /var/tmp/portage/media-libs/opencv-4.5.1/work/opencv-4.5.1/modules/videoio/src/backend_plugin.cpp (392) getPluginCandidates - /usr/lib64: 0
[ INFO:0] global /var/tmp/portage/media-libs/opencv-4.5.1/work/opencv-4.5.1/modules/videoio/src/backend_plugin.cpp (396) getPluginCandidates Found 0 plugin(s) for UEYE
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.1) /var/tmp/portage/media-libs/opencv-4.5.1/work/opencv-4.5.1/modules/highgui/src/window.cpp:384: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
Aborted