Skip to main content

Posts

Showing posts with the label CLion

OpenCV : Show Video and Picture in CLion

1. Show Video by using VideoCapture int main () { VideoCapture capture ( "./res/chat.avi" ); Mat frame ; if ( ! capture .isOpened()){ printf( "AVI file can not open \n " ); return 0 ; } namedWindow( "w" , 0 ); // 0 : resizable, 1 : fit autosize while ( 1 ){ capture >> frame ; if ( frame .empty()) break ; // when arrive at the end of the video     Sobel( frame , frame , frame .depth(), 1 , 0 ); // make color reversal   imshow( "w" , frame ); if (waitKey( 10 ) == 27 ) break ; // 27 is esc key code number } return 0 ; }   2. Read and Show Picture int main () { Mat img = imread( "./res/mh.jpg" ); namedWindow( "win" , 0 ); imshow( "win" , img ); waitKey( 0 ); return 0 ; } Warning! : If you use CLion IDE, you should set proper working directory.

OpenCV : How to setting OpenCV in CLion

CLion is A Cross-Platform IDE for C and C++ by JetBrains Setting OpenCV in CLion is so easy. FIrst, make new c++ project. Second, edit CmakeList.txt cmake_minimum_required( VERSION 3.10 ) project( [YourProject] ) set( CMAKE_CXX_STANDARD 11 ) find_package( OpenCV REQUIRED ) add_executable( [YourProject] main.cpp ) target_link_libraries( [YourProject] ${OpenCV_LIBS} ) At Last include OpenCV to main.cpp #include <iostream> #include "opencv2/opencv.hpp" using namespace std ; using namespace cv ; ...