Answer the question
In order to leave comments, you need to log in
How to set up OpenCV 2.4.9 in Clion on Ubuntu 14.04?
Installed OpenCV by downloading opencv.sh from github. The installation was successful.
My CMakeLists.txt
project(ar_dip)
set(CMAKE_CXX_STANDARD 11)
set(OpenCV_FOUND 1)
FIND_PACKAGE( OpenCV REQUIRED core highgui imgproc)
find_package(PkgConfig REQUIRED)
pkg_search_module(OpenCV REQUIRED core highgui imgproc)
set(SOURCE_FILES main.cpp)
add_executable(ar_dip ${SOURCE_FILES})
#include <cv.h>
#include <highgui.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
// получаем любую подключённую камеру
CvCapture* capture = cvCreateCameraCapture(CV_CAP_ANY); //cvCaptureFromCAM( 0 );
assert( capture );
//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);//1280);
//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);//960);
// узнаем ширину и высоту кадра
double width = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
double height = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
printf("[i] %.0f x %.0f\n", width, height );
IplImage* frame=0;
cvNamedWindow("capture", CV_WINDOW_AUTOSIZE);
printf("[i] press Enter for capture image and Esc for quit!\n\n");
int counter=0;
char filename[512];
while(true){
// получаем кадр
frame = cvQueryFrame( capture );
// показываем
cvShowImage("capture", frame);
char c = cvWaitKey(33);
if (c == 27) { // нажата ESC
break;
}
else if(c == 13) { // Enter
// сохраняем кадр в файл
sprintf(filename, "Image%d.jpg", counter);
printf("[i] capture... %s\n", filename);
cvSaveImage(filename, frame);
counter++;
}
}
// освобождаем ресурсы
cvReleaseCapture( &capture );
cvDestroyWindow("capture");
return 0;
}
/home/deus/clion-2016.3/bin/cmake/bin/cmake --build /home/deus/ClionProjects/ar_dip/cmake-build-debug --target all -- -j 6
-- Configuring done
-- Generating done
-- Build files have been written to: /home/deus/ClionProjects/ar_dip/cmake-build-debug
[ 50%] Linking CXX executable ar_dip
CMakeFiles/ar_dip.dir/main.cpp.o: In function `main':
/home/deus/ClionProjects/ar_dip/main.cpp:9: undefined reference to `cvCreateCameraCapture'
/home/deus/ClionProjects/ar_dip/main.cpp:16: undefined reference to `cvGetCaptureProperty'
/home/deus/ClionProjects/ar_dip/main.cpp:17: undefined reference to `cvGetCaptureProperty'
/home/deus/ClionProjects/ar_dip/main.cpp:22: undefined reference to `cvNamedWindow'
/home/deus/ClionProjects/ar_dip/main.cpp:31: undefined reference to `cvQueryFrame'
/home/deus/ClionProjects/ar_dip/main.cpp:34: undefined reference to `cvShowImage'
/home/deus/ClionProjects/ar_dip/main.cpp:36: undefined reference to `cvWaitKey'
/home/deus/ClionProjects/ar_dip/main.cpp:49: undefined reference to `cvReleaseCapture'
/home/deus/ClionProjects/ar_dip/main.cpp:50: undefined reference to `cvDestroyWindow'
/home/deus/ClionProjects/ar_dip/main.cpp:44: undefined reference to `cvSaveImage'
collect2: error: ld returned 1 exit status
make[2]: *** [ar_dip] Ошибка 1
make[1]: *** [CMakeFiles/ar_dip.dir/all] Ошибка 2
make: *** [all] Ошибка 2
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question