diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index cb1ed8f5..99700c11 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -296,7 +296,7 @@ add_library( # Sets the name of the library. ncnn/yolov5ncnn.cpp - camera2/OpenCVFont.cpp + // camera2/OpenCVFont.cpp ${CAMERA2_SOURCES} diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 43d352f8..1c0669cc 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -963,7 +963,28 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) double width = mat.size().width; // double ratio = std::min(height / 1024, width / 1920); double ratio = height / 1024.0; + int thickness = round(1.2 * ratio); + if (thickness < 1) thickness = 1; + else if (thickness > 4) thickness = 4; + cv::Scalar scalar(255, 255, 255); // white + int fontSize = (int)(24.0 * ratio); + std::string fontPath; + if (existsFile("/system/fonts/NotoSansCJK-Regular.ttc")) + { + fontPath = "/system/fonts/NotoSansCJK-Regular.ttc"; + } + else if (existsFile("/system/fonts/NotoSerifCJK-Regular.ttc")) + { + fontPath = "/system/fonts/NotoSerifCJK-Regular.ttc"; + } + else + { + fontPath = m_appPath+ "fonts/Noto.otf"; + } + cv::Ptr ft2; + ft2 = cv::ft::createFreeType2(); + ft2->loadFontData(fontPath.c_str(), 0); // cv::Rect rc(0, 0, mat.cols, mat.rows); // cv::rectangle (mat, rc, cv::Scalar(255, 255, 255), cv::FILLED); std::vector objs; @@ -1021,29 +1042,8 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) } } - int thickness = (int)(4.0 * ratio); - if (thickness < 2) thickness = 2; - else if (thickness > 4) thickness = 4; - cv::Scalar scalar(255, 255, 255); // white - int fontSize = (int)(24.0 * ratio); - std::string fontPath; - if (existsFile("/system/fonts/NotoSansCJK-Regular.ttc")) - { - fontPath = "/system/fonts/NotoSansCJK-Regular.ttc"; - } - else if (existsFile("/system/fonts/NotoSerifCJK-Regular.ttc")) - { - fontPath = "/system/fonts/NotoSerifCJK-Regular.ttc"; - } - else - { - fontPath = m_appPath+ "fonts/Noto.otf"; - } - cv::Ptr ft2; - ft2 = cv::ft::createFreeType2(); - ft2->loadFontData(fontPath.c_str(), 0); #ifdef _DEBUG