diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index e8741f0d..3411f3c9 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -743,7 +743,18 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) { // visualize(ncnnPath.c_str(), in); std::vector objs; +#ifdef _DEBUG + double startTime = ncnn::get_current_time(); +#endif // _DEBUG + bool detected = YoloV5NcnnDetect(mat, true, objs); +#ifdef _DEBUG + double elasped = ncnn::get_current_time() - startTime; + // __android_log_print(ANDROID_LOG_DEBUG, "YoloV5Ncnn", "%.2fms detect", elasped); +#endif // _DEBUG +#ifdef _DEBUG + ALOGI( "NCNN recognization: %.2fms res=%d", elasped, ((detected && !objs.empty()) ? 1 : 0)); +#endif if (detected && !objs.empty()) { #if 0 @@ -759,7 +770,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) "hair drier", "toothbrush" }; #endif - cv::Scalar clr(0, 255, 255); + cv::Scalar borderColor(m_pRecognizationCfg->borderColor & 0xFF, (m_pRecognizationCfg->borderColor & 0xFF00) >> 8, (m_pRecognizationCfg->borderColor & 0xFF0000) >> 16); for (std::vector::const_iterator it = objs.cbegin(); it != objs.cend(); ++it) { if (it->label >= m_pRecognizationCfg->items.size()) @@ -776,16 +787,10 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) ALOGD("Label: %d=%s (%f,%f)-(%f,%f)", it->label, item.name.c_str(), it->x, it->y, it->w, it->h); #endif cv::Rect rc(it->x, it->y, it->w, it->h); - cv::rectangle(mat, rc, clr, 4); + cv::rectangle(mat, rc, borderColor, m_pRecognizationCfg->thickness); // putText } } - else - { -#ifdef _DEBUG - ALOGD("Not recognized"); -#endif - } } int thickness2 = 8 * ratio; diff --git a/app/src/main/cpp/ncnn/yolov5ncnn.cpp b/app/src/main/cpp/ncnn/yolov5ncnn.cpp index 3d9dc20d..75882087 100644 --- a/app/src/main/cpp/ncnn/yolov5ncnn.cpp +++ b/app/src/main/cpp/ncnn/yolov5ncnn.cpp @@ -421,8 +421,6 @@ bool YoloV5NcnnDetect( cv::Mat& mat, bool use_gpu, std::vector& objects) //return env->NewStringUTF("no vulkan capable gpu"); } - double start_time = ncnn::get_current_time(); - // AndroidBitmapInfo info; // AndroidBitmap_getInfo(env, bitmap, &info); const int width = mat.cols; @@ -599,9 +597,6 @@ bool YoloV5NcnnDetect( cv::Mat& mat, bool use_gpu, std::vector& objects) } */ - double elasped = ncnn::get_current_time() - start_time; - // __android_log_print(ANDROID_LOG_DEBUG, "YoloV5Ncnn", "%.2fms detect", elasped); - return true; }