Merge branch 2.4
authorAndrey Kamaev <andrey.kamaev@itseez.com>
Fri, 30 Nov 2012 15:52:59 +0000 (19:52 +0400)
committerAndrey Kamaev <andrey.kamaev@itseez.com>
Fri, 30 Nov 2012 15:54:24 +0000 (19:54 +0400)
1  2 
samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp

@@@ -73,32 -26,26 +73,32 @@@ JNIEXPORT jlong JNICALL Java_org_opencv
      string stdFileName(jnamestr);
      jlong result = 0;
  
 +    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject");
 +
      try
      {
 -        DetectionBasedTracker::Parameters DetectorParams;
 +        cv::Ptr<CascadeDetectorAdapter> mainDetector = new CascadeDetectorAdapter(new CascadeClassifier(stdFileName));
 +        cv::Ptr<CascadeDetectorAdapter> trackingDetector = new CascadeDetectorAdapter(new CascadeClassifier(stdFileName));
 +        result = (jlong)new DetectorAgregator(mainDetector, trackingDetector);
          if (faceSize > 0)
 -            DetectorParams.minObjectSize = faceSize;
 -        result = (jlong)new DetectionBasedTracker(stdFileName, DetectorParams);
 +        {
 +            mainDetector->setMinObjectSize(Size(faceSize, faceSize));
 +            //trackingDetector->setMinObjectSize(Size(faceSize, faceSize));
 +        }
      }
-     catch(cv::Exception e)
+     catch(cv::Exception& e)
      {
-         LOGD("nativeCreateObject catched cv::Exception: %s", e.what());
+         LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
          jclass je = jenv->FindClass("org/opencv/core/CvException");
          if(!je)
              je = jenv->FindClass("java/lang/Exception");
          jenv->ThrowNew(je, e.what());
      }
 -    catch (...)
 -    {
 +        catch (...)
 +        {
-         LOGD("nativeCreateObject catched unknown exception");
+         LOGD("nativeCreateObject caught unknown exception");
          jclass je = jenv->FindClass("java/lang/Exception");
 -        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
 +        jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeCreateObject(...)}");
          return 0;
      }
  
@@@ -115,13 -61,13 +115,13 @@@ JNIEXPORT void JNICALL Java_org_opencv_
      {
          if(thiz != 0)
          {
 -            ((DetectionBasedTracker*)thiz)->stop();
 -            delete (DetectionBasedTracker*)thiz;
 +            ((DetectorAgregator*)thiz)->tracker->stop();
 +            delete (DetectorAgregator*)thiz;
          }
      }
-     catch(cv::Exception e)
+     catch(cv::Exception& e)
      {
-         LOGD("nativeestroyObject catched cv::Exception: %s", e.what());
+         LOGD("nativeestroyObject caught cv::Exception: %s", e.what());
          jclass je = jenv->FindClass("org/opencv/core/CvException");
          if(!je)
              je = jenv->FindClass("java/lang/Exception");
      }
      catch (...)
      {
-         LOGD("nativeDestroyObject catched unknown exception");
+         LOGD("nativeDestroyObject caught unknown exception");
          jclass je = jenv->FindClass("java/lang/Exception");
 -        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
 +        jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject(...)}");
      }
      LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDestroyObject exit");
  }
  JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart
  (JNIEnv * jenv, jclass, jlong thiz)
  {
 -    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart enter");
 +    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart");
 +
      try
      {
 -        ((DetectionBasedTracker*)thiz)->run();
 +        ((DetectorAgregator*)thiz)->tracker->run();
      }
-     catch(cv::Exception e)
+     catch(cv::Exception& e)
      {
-         LOGD("nativeStart catched cv::Exception: %s", e.what());
+         LOGD("nativeStart caught cv::Exception: %s", e.what());
          jclass je = jenv->FindClass("org/opencv/core/CvException");
          if(!je)
              je = jenv->FindClass("java/lang/Exception");
      }
      catch (...)
      {
-         LOGD("nativeStart catched unknown exception");
+         LOGD("nativeStart caught unknown exception");
          jclass je = jenv->FindClass("java/lang/Exception");
 -        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
 +        jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart(...)}");
      }
      LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStart exit");
  }
  JNIEXPORT void JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop
  (JNIEnv * jenv, jclass, jlong thiz)
  {
 -    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop enter");
 +    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop");
 +
      try
      {
 -        ((DetectionBasedTracker*)thiz)->stop();
 +        ((DetectorAgregator*)thiz)->tracker->stop();
      }
-     catch(cv::Exception e)
+     catch(cv::Exception& e)
      {
-         LOGD("nativeStop catched cv::Exception: %s", e.what());
+         LOGD("nativeStop caught cv::Exception: %s", e.what());
          jclass je = jenv->FindClass("org/opencv/core/CvException");
          if(!je)
              je = jenv->FindClass("java/lang/Exception");
      }
      catch (...)
      {
-         LOGD("nativeStop catched unknown exception");
+         LOGD("nativeStop caught unknown exception");
          jclass je = jenv->FindClass("java/lang/Exception");
 -        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
 +        jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop(...)}");
      }
      LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeStop exit");
  }
@@@ -197,13 -140,15 +197,13 @@@ JNIEXPORT void JNICALL Java_org_opencv_
      {
          if (faceSize > 0)
          {
 -            DetectionBasedTracker::Parameters DetectorParams = \
 -            ((DetectionBasedTracker*)thiz)->getParameters();
 -            DetectorParams.minObjectSize = faceSize;
 -            ((DetectionBasedTracker*)thiz)->setParameters(DetectorParams);
 +            ((DetectorAgregator*)thiz)->mainDetector->setMinObjectSize(Size(faceSize, faceSize));
 +            //((DetectorAgregator*)thiz)->trackingDetector->setMinObjectSize(Size(faceSize, faceSize));
          }
      }
-     catch(cv::Exception e)
+     catch(cv::Exception& e)
      {
-         LOGD("nativeStop catched cv::Exception: %s", e.what());
+         LOGD("nativeStop caught cv::Exception: %s", e.what());
          jclass je = jenv->FindClass("org/opencv/core/CvException");
          if(!je)
              je = jenv->FindClass("java/lang/Exception");
      }
      catch (...)
      {
-         LOGD("nativeSetFaceSize catched unknown exception");
+         LOGD("nativeSetFaceSize caught unknown exception");
          jclass je = jenv->FindClass("java/lang/Exception");
 -        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
 +        jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize(...)}");
      }
 -    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize exit");
 +    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeSetFaceSize -- END");
  }
  
  
@@@ -227,13 -171,13 +227,13 @@@ JNIEXPORT void JNICALL Java_org_opencv_
      try
      {
          vector<Rect> RectFaces;
 -        ((DetectionBasedTracker*)thiz)->process(*((Mat*)imageGray));
 -        ((DetectionBasedTracker*)thiz)->getObjects(RectFaces);
 -        vector_Rect_to_Mat(RectFaces, *((Mat*)faces));
 +        ((DetectorAgregator*)thiz)->tracker->process(*((Mat*)imageGray));
 +        ((DetectorAgregator*)thiz)->tracker->getObjects(RectFaces);
 +        *((Mat*)faces) = Mat(RectFaces, true);
      }
-     catch(cv::Exception e)
+     catch(cv::Exception& e)
      {
-         LOGD("nativeCreateObject catched cv::Exception: %s", e.what());
+         LOGD("nativeCreateObject caught cv::Exception: %s", e.what());
          jclass je = jenv->FindClass("org/opencv/core/CvException");
          if(!je)
              je = jenv->FindClass("java/lang/Exception");
      }
      catch (...)
      {
-         LOGD("nativeDetect catched unknown exception");
+         LOGD("nativeDetect caught unknown exception");
          jclass je = jenv->FindClass("java/lang/Exception");
 -        jenv->ThrowNew(je, "Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}");
 +        jenv->ThrowNew(je, "Unknown exception in JNI code {Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect(...)}");
      }
 -    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect exit");
 -}
 +    LOGD("Java_org_opencv_samples_facedetect_DetectionBasedTracker_nativeDetect END");
 +}