Issue
Using OpenCV, I'm trying to get the video stream from the camera, but I get this error:
openOpenCV(3.4.3) Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvWaitKey, file /home/Ulugbe/Downloads/Telegram Desktop/opencv-3.4.3/modules/highgui/src/window.cpp, line 698
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.3) /home/Ulugbe/Downloads/Telegram Desktop/opencv-3.4.3/modules/highgui/src/window.cpp:698: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
This is my code:
#include <opencv2/opencv.hpp>
#include <dlib/any.h>
#include <iostream>
int main (int argc, char **argv)
{
std::cout << cv::getBuildInformation() << std::endl;
cv::VideoCapture video(0);
// video.open("/home/Ulugbe/oson/ulugbek_face.mp4");
if(video.isOpened())
std::cout<<"open";
cv::Mat frame;
video.read(frame);
cv::imshow("image", frame);
cv::waitKey(0);
video.release();
return 0;
}
I don't understand the error because the opencv version in the message is not suitable with my current one and the path shown in the error also doesn't exist (But I remembered it was initially installed there but it was then uninstalled and installed as root).
If you comment out the imshow
and waitKey
lines, the program will not show any errors, so I think the problem is somehow related to it.
Screenshots of my NetBeans configuration: compiler properties linker properties
Solution
The path is still "there" because it is stored inside the library that you built. It is preserved because it is useful debugging information.
You built OpenCV without any GUI support. That's what the error means. It also says:
Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
So you should rebuild OpenCV. Run cmake-gui
and look at the output to understand what GUI backends could be possible, and what causes them to be unavailable. Browse the settings/variables and enable a GUI backend if none were enabled.
Answered By - Christoph Rackwitz
Answer Checked By - Marilyn (JavaFixing Volunteer)