Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "opencv2/core.hpp"
- #include <opencv2/ml.hpp>
- #include "opencv2/highgui/highgui.hpp"
- #include "opencv2/imgproc/imgproc.hpp"
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include<vector>
- using namespace std;
- using namespace cv;
- using namespace cv::ml;
- // ---The Code from Greek Letter Recognization----
- //Comes from KNN Character Rec. Program. https://github.com/MicrocontrollersAndMore/OpenCV_3_KNN_Character_Recognition_Cpp/blob/master/GenData.cpp#L38
- // global variables ///////////////////////////////////////////////////////////////////////////////
- const int MIN_CONTOUR_AREA = 100;
- const int RESIZED_IMAGE_WIDTH = 20;
- const int RESIZED_IMAGE_HEIGHT = 30;
- //////////////////////////////////////
- // /First step. Reading the image.
- void ImgRead()
- {
- //Clearing previous images.
- //ClearImages(); TODO: Fix it.
- //Reading from the data folder. I guess...
- cv::Mat im = cv::imread("C:/Users/Ahmet/Documents/Visual Studio 2017/Projects/OpencvTest/data/testSrc.jpg", CV_LOAD_IMAGE_COLOR);
- //If the image attached correctly the im.data value gonna be diff. than 0.
- if (im.data != 0)
- {
- cv::namedWindow("Test_Image", CV_WINDOW_AUTOSIZE);
- //Display the image.
- cv::imshow("Test_Image", im);
- cout << "Image Loaded. Press any key..." << endl;
- cout << "U+0391" << endl;
- //Implementing Canny Filter to detect lines of the characters. Hopefull gonna move on after that.
- Mat gray, edge, canIm; //Creation of a new matrix which hold tha image gray.
- cvtColor(im, gray, CV_BGR2GRAY);
- Canny(gray, edge, 50, 150, 3);
- edge.convertTo(canIm, CV_8U);
- namedWindow("CannyImage", CV_WINDOW_AUTOSIZE);
- imshow("CannyImage", canIm);
- cv::waitKey(0);
- }
- else
- {
- cout << "Error while loading image!" << endl;
- }
- }
- int main()
- {
- /*
- Mat image = imread("C:/Users/Ahmet/Documents/Classes/Fall 2017/AI/Project/Datasets/epfl_corridor/20141008_141323_00/rgb000355.png", IMREAD_COLOR);
- Ptr<SVM> svm = SVM::create();
- namedWindow("Image Display", CV_WINDOW_AUTOSIZE);
- imshow("test_image", image);
- waitKey(0);
- */
- //float labels[4] = { 1.0, -1.0, -1.0, -1.0 };
- ImgRead();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement