Class 2

This class teaches students to test their setup and start programming with the OpenCV library.

When developing with third-party libraries, library set up is extremely important. Compilation, installation, and compiler configuration are the three big steps in library set up. Especially in compiler configuration, every letter entered in the library path, include path, and linker flags, must be exactly the same as shown in the instruction. Compiler and error detectors integrated into IDEs are not good at debugging include errors with external libraries. Therefore, we need to make sure we don’t miss a component or include any extras.

The following example code is given to test the setup.

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;
int main()
{
	Mat img = imread("./src/image.jpg");

	if(!img.data)
	{
		cout << "not read in" << endl;
		return -1;
	}
	namedWindow("img", CV_WINDOW_AUTOSIZE);
	imshow("img", img);
	waitKey();
	return 0;
}

This is a basic OpenCV code that reads in a specific image in the file system and displays it in a window. The code uses the “imread” and “imshow” functions. If the code compiles and run succesfully on the computer, we know our IDEs are ready for OpenCV development.