SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <opencv2/core.hpp> | |
| 2 | #include <opencv2/imgproc.hpp> | |
| 3 | #include "opencv2/imgcodecs.hpp" | |
| 4 | #include <opencv2/highgui.hpp> | |
| 5 | #include <opencv2/ml.hpp> | |
| 6 | #include <iostream> | |
| 7 | ||
| 8 | using namespace cv; | |
| 9 | using namespace cv::ml; | |
| 10 | ||
| 11 | int main(int, char**) | |
| 12 | {
| |
| 13 | cv::Mat inputImg=cv::imread("2.tif",CV_LOAD_IMAGE_COLOR);
| |
| 14 | - | cv::Mat outputImg; |
| 14 | + | Ptr<ml::SVM> svm = Algorithm::load<ml::SVM>("model.yml"); //http://pastebin.com/qeRgvkK4
|
| 15 | - | outputImg.create(inputImg.size(),CV_8U); |
| 15 | + | |
| 16 | - | std::cout<<"input and output image created"<<std::endl; |
| 16 | + | |
| 17 | cv::MatIterator_<cv::Vec3b> it,end; | |
| 18 | - | Ptr<ml::SVM> svm = Algorithm::load<ml::SVM>("model.yml");
|
| 18 | + | |
| 19 | end=inputImg.end<cv::Vec3b>(); | |
| 20 | it!=end;++it){
| |
| 21 | - | std::cout<<inputImg.channels()<<std::endl; |
| 21 | + | Mat sampleMat = (Mat_<float>(1,3)<<(*it)[0],(*it)[1],(*it)[2]); |
| 22 | // float response = svm->predict(*it); | |
| 23 | float response = svm->predict(sampleMat); | |
| 24 | //Both of the lines dont work | |
| 25 | ||
| 26 | } | |
| 27 | ||
| 28 | - | float response = svm->predict(*it); |
| 28 | + | |
| 29 | } |