Esempio n. 1
0
 /// <summary>
 /// for training
 /// </summary>
 public VehicleSpeedEstimator(System.Drawing.Size hog_training_img_size)
 {
     anomaly = new AnomalySpeedDetector();
     hog     = new HOGDescriptor(new OpenCvSharp.Size(hog_training_img_size.Width, hog_training_img_size.Height), new OpenCvSharp.Size(16, 16),
                                 new OpenCvSharp.Size(8, 8), new OpenCvSharp.Size(8, 8));
     classifier        = OpenCvSharp.ML.SVM.Create();
     AllowErrorRate    = 1.5f;
     SurgingSpeedMin   = 0.45f;
     SurgingCountLimit = 7;
 }
Esempio n. 2
0
 /// <summary>
 /// for estimation
 /// </summary>
 /// <param name="svm_path"></param>
 public VehicleSpeedEstimator(System.Drawing.Size hog_training_img_size, string svm_path)
 {
     try {
         anomaly           = new AnomalySpeedDetector();
         AllowErrorRate    = 1.5f;
         SurgingSpeedMin   = 0.45f;
         SurgingCountLimit = 7;
         classifier        = OpenCvSharp.ML.SVM.Load(svm_path);
         hog = new HOGDescriptor(new OpenCvSharp.Size(hog_training_img_size.Width, hog_training_img_size.Height), new OpenCvSharp.Size(16, 16),
                                 new OpenCvSharp.Size(8, 8), new OpenCvSharp.Size(8, 8));
         var support_vectors = classifier.GetSupportVectors();
         var vectors         = new float[support_vectors.Width * support_vectors.Height];
         Marshal.Copy(support_vectors.Data, vectors, 0, support_vectors.Width * support_vectors.Height);
         hog.SetSVMDetector(vectors);
     }
     catch (Exception) {
         classifier = OpenCvSharp.ML.SVM.Create();
     }
 }