|
|
@ -743,7 +743,18 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// visualize(ncnnPath.c_str(), in);
|
|
|
|
// visualize(ncnnPath.c_str(), in);
|
|
|
|
std::vector<Object> objs;
|
|
|
|
std::vector<Object> objs;
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
|
|
double startTime = ncnn::get_current_time();
|
|
|
|
|
|
|
|
#endif // _DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
bool detected = YoloV5NcnnDetect(mat, true, objs);
|
|
|
|
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 (detected && !objs.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
@ -759,7 +770,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
"hair drier", "toothbrush"
|
|
|
|
"hair drier", "toothbrush"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#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)
|
|
|
|
for (std::vector<Object>::const_iterator it = objs.cbegin(); it != objs.cend(); ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (it->label >= m_pRecognizationCfg->items.size())
|
|
|
|
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);
|
|
|
|
ALOGD("Label: %d=%s (%f,%f)-(%f,%f)", it->label, item.name.c_str(), it->x, it->y, it->w, it->h);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
cv::Rect rc(it->x, it->y, it->w, it->h);
|
|
|
|
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
|
|
|
|
// putText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
|
|
ALOGD("Not recognized");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int thickness2 = 8 * ratio;
|
|
|
|
int thickness2 = 8 * ratio;
|
|
|
|