通过配置设置绘制属性

serial
BlueMatthew 2 years ago
parent aed7795126
commit 442b1e4da7

@ -743,7 +743,18 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
{
// visualize(ncnnPath.c_str(), in);
std::vector<Object> 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<Object>::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;

@ -421,8 +421,6 @@ bool YoloV5NcnnDetect( cv::Mat& mat, bool use_gpu, std::vector<Object>& 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<Object>& objects)
}
*/
double elasped = ncnn::get_current_time() - start_time;
// __android_log_print(ANDROID_LOG_DEBUG, "YoloV5Ncnn", "%.2fms detect", elasped);
return true;
}

Loading…
Cancel
Save