Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

opencv with windows form application (Visual Studio 13 GUI) c++

$
0
0
how can I write the following code in windows form application in Visual studio, not QT? I want to make use of GUI and make an interactive application that executes the function on click. I searched few links but didn't get what exactly they were trying to say.I tried adding code in header files but it is giving me an error.can someone help me and tell me steps to do GUI? here is the code. #include "opencv2/opencv.hpp" #include using namespace cv; using namespace std; // // if you squint hard, you'll see the close similarity to opencv's face recognition code ;) // void lbp_hist(const Mat &I, Mat &histogram) { Mat_ img(I); Mat_ hist(1, 256, 0.0f); const int m=1; for (int r=m; r cen) << 0; v |= (img(r-1,c+1) > cen) << 1; v |= (img(r ,c+1) > cen) << 2; v |= (img(r+1,c+1) > cen) << 3; v |= (img(r+1,c ) > cen) << 4; v |= (img(r+1,c-1) > cen) << 5; v |= (img(r ,c-1) > cen) << 6; v |= (img(r-1,c-1) > cen) << 7; hist(v) ++; } } histogram = hist; } struct Classifier { vector histograms; vector labels; Classifier( vector&histograms, vector&labels) : histograms(histograms) , labels(labels) {} // nothing else to do // nearest neighbour distance: int predict(const Mat &histogram) { double minDist=DBL_MAX; int minLabel = -1; for (size_t i=0; i hists; vector labels; // 1==agglutinated, 0==not. // ref hists.push_back(h1); labels.push_back(0); hists.push_back(h4); labels.push_back(0); // agglutinated: hists.push_back(h2); labels.push_back(1); hists.push_back(h3); labels.push_back(1); hists.push_back(h5); labels.push_back(1); hists.push_back(h6); labels.push_back(1); // "train" the classifier: Classifier cls(hists, labels); // flip images for testing, so they again look a bit different: // (again, this is only for the demo) Mat f7; flip(ref,f7,1); // y-axis Mat f8; flip(a1,f8,1); Mat f9; flip(a2,f9,1); Mat h7,h8,h9; lbp_hist(f7,h7); lbp_hist(f8,h8); lbp_hist(f9,h9); int p1 = cls.predict(h7); // ref int p2 = cls.predict(h8); // agg. int p3 = cls.predict(h9); // agg. cerr << p1 << " " << p2 << " " << p3 << endl; return 0; }

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>