Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visualization and default model for text detection PP-OCR #237

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions models/text_detection_ppocr/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ vector< pair<cv::dnn::Backend, cv::dnn::Target> > backendTargetPairs = {

std::string keys =
"{ help h | | Print help message. }"
"{ model m | text_detection_ch_ppocrv3_2023may.onnx | Usage: Set model type, defaults to text_detection_ch_ppocrv3_2023may.onnx }"
"{ model m | text_detection_cn_ppocrv3_2023may.onnx | Usage: Set model type, defaults to text_detection_ch_ppocrv3_2023may.onnx }"
"{ input i | | Usage: Path to input image or video file. Skip this argument to capture frames from a camera.}"
"{ width | 736 | Usage: Resize input image to certain width, default = 736. It should be multiple by 32.}"
"{ height | 736 | Usage: Resize input image to certain height, default = 736. It should be multiple by 32.}"
Expand Down Expand Up @@ -113,7 +113,7 @@ int main(int argc, char** argv)
int maxCand = parser.get<int>("max_candidates");
double unRatio = parser.get<float>("unclip_ratio");
bool save = parser.get<bool>("save");
bool viz = parser.get<float>("viz");
bool viz = parser.get<bool>("viz");

PPOCRDet model(modelName, inpSize, binThresh, polyThresh, maxCand, unRatio, backendTargetPairs[backendTargetid].first, backendTargetPairs[backendTargetid].second);

Expand Down Expand Up @@ -172,7 +172,10 @@ int main(int argc, char** argv)
imwrite("result.jpg", originalImage);
}
if (viz)
{
imshow(kWinName, originalImage);
waitKey(0);
Copy link
Member

@WanliZhong WanliZhong Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 130 has

 while (waitKey(1) < 0)

So I think we don‘t need to add waitKey(0)?

Copy link
Contributor Author

@ryan1288 ryan1288 Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while (waitKey(1) < 0) - I believe this has a timeout of 1 ms before continuing the loop.

It then attempts to go into

cap >> originalImage;
if (originalImage.empty())
{
    if (parser.has("input"))
    {
        cout << "Frame is empty" << endl;
        break;
    }
    else
        continue;
}

and reaches cout << "Frame is empty" << endl;, breaking the loop and ending the program. On the otherhand, waitKey(0) waits indefinitely, allowing the user to keep the processed image up for viewing.

}
}
else
imshow(kWinName, originalImage);
Expand Down