// // main.cpp // AutoGrader // // Created by Robert LiKamWa on 9/17/13. // Copyright (c) 2013 Robert LiKamWa. All rights reserved. // #include #include #include #include #include "opencv2/imgproc/imgproc.hpp" #include "dirent.h" #include #include #include #include //#include using namespace cv; using namespace std; string corners_window="corners_window"; char buf[120]; void showim(Mat image){ namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display. imshow( "Display window", image ); waitKey(0); } string dirChooser(NSString *title, NSString * startdir){ NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setCanChooseFiles:NO]; [panel setCanChooseDirectories:YES]; [panel setDirectoryURL:[NSURL URLWithString:startdir]]; //[panel setAllowsMultipleSelection:YES]; // yes if more than one dir is allowed [panel setTitle:title]; NSInteger clicked = [panel runModal]; if (clicked != NSFileHandlingPanelOKButton) { //clicked = [panel runModal]; exit(0); } NSString * str = [[panel URL] path]; NSLog(str); string s = [str UTF8String]; cout<d_name; size_t i = filename.rfind(".png"); if ((i != string::npos) && (i == (filename.length() - 4))){ cout<<"File: "<channel[1]+100; Mat red = channel[2]>channel[0]+50; Mat green = channel[1]>channel[0]+100; //showim(red); //cvNamedWindow("hello"); //imshow("hello",green); //waitKey(); cv::SimpleBlobDetector::Params params; params.minDistBetweenBlobs = 10.0f; params.filterByInertia = false; params.filterByConvexity = false; params.filterByColor = false; params.filterByCircularity = false; params.filterByArea = true; params.minArea = 5.0f; params.maxArea = 1000.0f; cv::Ptr blob_detector = new cv::SimpleBlobDetector(params); blob_detector->create("SimpleBlob"); vector keypoints; blob_detector->detect(red, keypoints); cout< greenkeypoints; blob_detector->detect(green, greenkeypoints); //cout< keypoints2; blob_detector->detect(blue, keypoints2); cout<0){ string commentsparamspath = paramspath + "/Comments" + filename+".txt"; std::ofstream commentsparams; commentsparams.open (commentsparamspath.c_str()); string greenstring=""; int minX=5000000; int maxX=-1; for(long j=0; jmaxX){ maxX=greenkeypoints[j].pt.x; } } commentsparams<=0; j--){ float distance = Y-greenkeypoints[j].pt.y; if (distance>0 && distancecloseBottomY){ g2 = greenkeypoints[j].pt.y; closeBottomY=distance; } } commentsparams<