Skip to content

Instantly share code, notes, and snippets.

@j2doll
Created June 15, 2018 00:09
Show Gist options
  • Select an option

  • Save j2doll/65a1087551d0b0d9a0e27e5202a8935e to your computer and use it in GitHub Desktop.

Select an option

Save j2doll/65a1087551d0b0d9a0e27e5202a8935e to your computer and use it in GitHub Desktop.
Hello, OpenCV
// opencv_basic.cpp
//
#include "stdafx.h"
// Test environment (Feb 26, 2018)
// - OpenCV 3.4.0
// - Visual Studio 2017 win64(x64)
// environment value 'OPENCV_DIR' is 'D:\opencv\build\x64\vc15' (for example)
// BIN path: $(OPENCV_DIR)\bin
// INCLUDE path: $(OPENCV_DIR)\..\..\include
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
// LIB path: $(OPENCV_DIR)\lib
// Link lib file
// - debug mode: opencv_world340d.lib
// - release mode: opencv_world340.lib
int main(int argc, char** argv)
{
// main function code: https://gist.github.com/EyalAr/3940636
using namespace cv;
//create a gui window:
namedWindow("Output", 1);
//initialize a 120X350 matrix of black pixels:
Mat output = Mat::zeros(120, 350, CV_8UC3);
//write text on the matrix:
putText(output,
"Hello World :)",
cvPoint(15, 70),
FONT_HERSHEY_PLAIN,
3,
cvScalar(0, 255, 0),
4);
//display the image:
imshow("Output", output);
//wait for the user to press any key:
waitKey(0);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment