x1ongzhu 7 anni fa
parent
commit
bf2ad05555

BIN
gameMatch.xcodeproj/project.xcworkspace/xcuserdata/drew.xcuserdatad/UserInterfaceState.xcuserstate


+ 9 - 6
gameMatch/Trainning.cpp

@@ -89,23 +89,26 @@ namespace Trainning {
         //    cout << "res:" << res << endl;
         
         VideoCapture cap;
-        cap.open("/Users/drew/Desktop/Screenrecorder-2019-01-23-16-03-53-600.mp4");
-        long total = cap.get(CAP_PROP_FRAME_COUNT);
-        long curr = 0;
+        if(!cap.open("rtmp://49.4.66.233:1935/myapp/test")) {
+            cout << "Error opening video stream or file" << std::endl;
+            exit(-1);
+        }
         bool matched = false;
         Mat frame;
+        int curr = 0;
         while(1)
         {
             cap.read(frame);//等价于cap.read(frame);
             if(frame.empty())
                 break;
             if (curr % 3 == 0){
-                cout << curr << "/" << total << endl;
                 Mat v;
-//                rotate(frame, frame, ROTATE_90_COUNTERCLOCKWISE);
+                if (frame.cols < frame.rows) {
+                    rotate(frame, frame, ROTATE_90_COUNTERCLOCKWISE);
+                }
                 resize(frame, v, Size(854,480));
                         imshow("v", v);
-                waitKey(1 );
+                waitKey(1);
                 Mat p = v.reshape(1, 1);
                 p.convertTo(p, CV_32FC1);
                 float res = svm->predict(p);

+ 4 - 4
gameMatch/main.cpp

@@ -6,14 +6,14 @@
 //  Copyright © 2019 Drew. All rights reserved.
 //
 #include "main.h"
-//#include "Trainning.h"
+#include "Trainning.h"
 //#include "HSVFilter.h"
-#include "OCR.h"
+//#include "OCR.h"
 int main(int argc, char*argv[])
 {
     //    Adjust::adjust("/Users/drew/Desktop/matched.jpg");
-    OCR::extract();
+    //    OCR::extract();
     //        Trainning::train();
-    //        Trainning::predict();
+    Trainning::predict();
     return 0;
 }