Skip to content

Instantly share code, notes, and snippets.

@romicofre
Last active April 28, 2024 02:34
Show Gist options
  • Save romicofre/1d6e1e47d316e103943a4fdb1b56c5aa to your computer and use it in GitHub Desktop.
Save romicofre/1d6e1e47d316e103943a4fdb1b56c5aa to your computer and use it in GitHub Desktop.
load image with c++
/*
Compilar: g++ $(pkg-config --cflags --libs opencv) loadImage.cpp -o loadImage
*/
#include <opencv2/opencv.hpp> //incluye todas las librerias OpenCV
using namespace cv;
int main( int argc, char** argv ) {
//imread puede leer “BMP, DIB, JPEG, JPE, PNG, PBM, PGM, PPM, SR, RAS, and TIFF”
Mat img = imread(argv[1],-1);
if( img.empty() )
return -1;
namedWindow( "Example1", cv::WINDOW_AUTOSIZE );
imshow( "Example1", img );
waitKey( 0 );
destroyWindow( "Example1" );
return 0;
}
//Compilar g++ opencvTest_OSX.c -o opencvTest_OSX
#include <stdio.h>
//#include "opencv2/core.hpp" //Tambien sirve
#include "opencv2/core/core.hpp"
int main(){
printf("OpenCV version: %d.%d\n", CV_MAJOR_VERSION, CV_MINOR_VERSION);
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment