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 ai demo read timeout crash #97

Merged
merged 17 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
16 changes: 14 additions & 2 deletions package/ai/code/face_alignment/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,16 @@ void ai_worker(ai_worker_args ai_args)
cv::Mat ori_img_B = cv::Mat(valid_height, valid_width, CV_8UC1, rf.virtual_addr_input[0] + valid_width * valid_width * 2);
while(quit.load())
{
bool ret = false;
ScopedTiming st("total", 1);
mtx.lock();
capture.read(rgb24_img_for_ai);
ret = capture.read(rgb24_img_for_ai);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
//拷贝图像的同时修改padding方式,默认读出的图像是最后做padding,修改为前后做padding
if(is_rgb)
{
Expand Down Expand Up @@ -443,10 +449,16 @@ void display_worker(int enable_profile)
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT * 3 / 2, (DRM_INPUT_WIDTH + 15) / 16 * 16, CV_8UC1, fbuf_yuv->map);
{
bool ret = false;
ScopedTiming st("capture read",enable_profile);
mtx.lock();
capture.read(org_img);
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
}

if (drm_dev.req)
Expand Down
16 changes: 14 additions & 2 deletions package/ai/code/face_detect/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,16 @@ void ai_worker(ai_worker_args ai_args)
cv::Mat rgb24_img_for_ai(net_len, net_len, CV_8UC3, rf.virtual_addr_input[0]);
while(quit.load())
{
bool ret = false;
ScopedTiming st("total", 1);
mtx.lock();
capture.read(rgb24_img_for_ai);
ret = capture.read(rgb24_img_for_ai);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
//拷贝图像的同时修改padding方式,默认读出的图像是最后做padding,修改为前后做padding
if(is_rgb)
{
Expand Down Expand Up @@ -269,10 +275,16 @@ void display_worker(int enable_profile)
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT * 3 / 2, (DRM_INPUT_WIDTH + 15) / 16 * 16, CV_8UC1, fbuf_yuv->map);
{
bool ret = false;
ScopedTiming st("capture read",enable_profile);
mtx.lock();
capture.read(org_img);
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
}

if (drm_dev.req)
Expand Down
16 changes: 14 additions & 2 deletions package/ai/code/face_expression/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,16 @@ void ai_worker(ai_worker_args ai_args)
cv::Mat ori_img_B = cv::Mat(valid_height, valid_width, CV_8UC1, rf.virtual_addr_input[0] + valid_width * valid_width * 2);
while(quit.load())
{
bool ret = false;
ScopedTiming st("total", 1);
mtx.lock();
capture.read(rgb24_img_for_ai);
ret = capture.read(rgb24_img_for_ai);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
//拷贝图像的同时修改padding方式,默认读出的图像是最后做padding,修改为前后做padding
if(is_rgb)
{
Expand Down Expand Up @@ -325,10 +331,16 @@ void display_worker(int enable_profile)
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT * 3 / 2, (DRM_INPUT_WIDTH + 15) / 16 * 16, CV_8UC1, fbuf_yuv->map);
{
bool ret = false;
ScopedTiming st("capture read",enable_profile);
mtx.lock();
capture.read(org_img);
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
}

if (drm_dev.req)
Expand Down
16 changes: 14 additions & 2 deletions package/ai/code/face_landmarks/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ void ai_worker(ai_worker_args ai_args)
cv::Mat ori_img_B = cv::Mat(valid_height, valid_width, CV_8UC1, rf.virtual_addr_input[0] + valid_width * valid_width * 2);
while(quit.load())
{
bool ret = false;
ScopedTiming st("total", 1);
mtx.lock();
capture.read(rgb24_img_for_ai);
ret = capture.read(rgb24_img_for_ai);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
//拷贝图像的同时修改padding方式,默认读出的图像是最后做padding,修改为前后做padding
if(is_rgb)
{
Expand Down Expand Up @@ -366,10 +372,16 @@ void display_worker(int enable_profile)
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT * 3 / 2, (DRM_INPUT_WIDTH + 15) / 16 * 16, CV_8UC1, fbuf_yuv->map);
{
bool ret = false;
ScopedTiming st("capture read",enable_profile);
mtx.lock();
capture.read(org_img);
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
}

if (drm_dev.req)
Expand Down
16 changes: 14 additions & 2 deletions package/ai/code/face_recog/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ void ai_worker(ai_worker_args ai_args)
cv::Mat ori_img_B = cv::Mat(valid_height, valid_width, CV_8UC1, rf.virtual_addr_input[0] + valid_width * valid_width * 2);
while(quit.load())
{
bool ret = false;
ScopedTiming st("total", 1);
mtx.lock();
capture.read(rgb24_img_for_ai);
ret = capture.read(rgb24_img_for_ai);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
//拷贝图像的同时修改padding方式,默认读出的图像是最后做padding,修改为前后做padding
if(is_rgb)
{
Expand Down Expand Up @@ -384,10 +390,16 @@ void display_worker(int enable_profile)
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT * 3 / 2, (DRM_INPUT_WIDTH + 15) / 16 * 16, CV_8UC1, fbuf_yuv->map);
{
bool ret = false;
ScopedTiming st("capture read",enable_profile);
mtx.lock();
capture.read(org_img);
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
}

if (drm_dev.req)
Expand Down
20 changes: 16 additions & 4 deletions package/ai/code/hand_image_classify/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,16 @@ void ai_worker(ai_worker_args ai_args)
frame_coordinate_info frame_coordinate;
while(quit.load())
{
bool ret = false;
ScopedTiming st("total", 1);
mtx.lock();
capture.read(rgb24_img_for_ai);
mtx.unlock();
ret = capture.read(rgb24_img_for_ai);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
//拷贝图像的同时修改padding方式,默认读出的图像是最后做padding,修改为前后做padding
if(is_rgb)
{
Expand Down Expand Up @@ -515,10 +521,16 @@ void display_worker(int enable_profile)
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT * 3 / 2, (DRM_INPUT_WIDTH + 15) / 16 * 16, CV_8UC1, fbuf_yuv->map);
{
bool ret = false;
ScopedTiming st("capture read",enable_profile);
mtx.lock();
capture.read(org_img);
mtx.unlock();
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
}

if (drm_dev.req)
Expand Down
20 changes: 16 additions & 4 deletions package/ai/code/head_pose_estimation/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,16 @@ void ai_worker(ai_worker_args ai_args)
cv::Mat ori_img_B = cv::Mat(valid_height, valid_width, CV_8UC1, rf.virtual_addr_input[0] + valid_width * valid_width * 2);
while(quit.load())
{
bool ret = false;
ScopedTiming st("total", 1);
mtx.lock();
capture.read(rgb24_img_for_ai);
mtx.unlock();
ret = capture.read(rgb24_img_for_ai);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
//拷贝图像的同时修改padding方式,默认读出的图像是最后做padding,修改为前后做padding
if(is_rgb)
{
Expand Down Expand Up @@ -284,10 +290,16 @@ void display_worker(int enable_profile)
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT * 3 / 2, (DRM_INPUT_WIDTH + 15) / 16 * 16, CV_8UC1, fbuf_yuv->map);
{
bool ret = false;
ScopedTiming st("capture read",enable_profile);
mtx.lock();
capture.read(org_img);
mtx.unlock();
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
}

if (drm_dev.req)
Expand Down
16 changes: 14 additions & 2 deletions package/ai/code/license_plate_recog/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ void ai_worker(ai_worker_args ai_args)
frame_coordinate_info frame_coordinate;
while(quit.load())
{
bool ret = false;
ScopedTiming st("total", 1);
mtx.lock();
capture.read(rgb24_img_for_ai);
ret = capture.read(rgb24_img_for_ai);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
//拷贝图像的同时修改padding方式,默认读出的图像是最后做padding,修改为前后做padding
if(is_rgb)
{
Expand Down Expand Up @@ -311,10 +317,16 @@ void display_worker(int enable_profile)
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT * 3 / 2, (DRM_INPUT_WIDTH + 15) / 16 * 16, CV_8UC1, fbuf_yuv->map);
{
bool ret = false;
ScopedTiming st("capture read",enable_profile);
mtx.lock();
capture.read(org_img);
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
}

if (drm_dev.req)
Expand Down
18 changes: 16 additions & 2 deletions package/ai/code/object_detect/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,17 @@ void ai_worker(ai_worker_args ai_args)
cv::Mat rgb24_img_for_ai(net_len, net_len, CV_8UC3, od.virtual_addr_input[0] + (valid_width - valid_height) / 2 * valid_width);
while(quit.load())
{
bool ret = false;
ScopedTiming st("total", 1);
mtx.lock();
capture.read(rgb24_img_for_ai);
ret = capture.read(rgb24_img_for_ai);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}

//拷贝图像的同时修改padding方式,默认读出的图像是最后做padding,修改为前后做padding
if(is_rgb)
{
Expand Down Expand Up @@ -273,10 +280,17 @@ void display_worker(int enable_profile)
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT * 3 / 2, (DRM_INPUT_WIDTH + 15) / 16 * 16, CV_8UC1, fbuf_yuv->map);
{
bool ret = false;
ScopedTiming st("capture read",enable_profile);
mtx.lock();
capture.read(org_img);
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}

}

if (drm_dev.req)
Expand Down
26 changes: 19 additions & 7 deletions package/ai/code/object_detect_opencv/main.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,17 @@ void ai_worker()
cv::Mat osd_img;

while(quit.load())
{
{
bool ret = false;
ScopedTiming st("total");
mtx.lock();
capture.read(osd_img); //ARGB
mtx.unlock();
ret = capture.read(osd_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}

for (int r = 0; r < valid_height; r++)
{
Expand Down Expand Up @@ -237,13 +243,19 @@ void display_worker()
drm_bufs_index = !drm_bufs_index;
fbuf_yuv = &drm_dev.drm_bufs[drm_bufs_index];
cv::Mat org_img(DRM_INPUT_HEIGHT*3/2, (DRM_INPUT_WIDTH+15)/16*16, CV_8UC1, fbuf_yuv->map);
{
{
bool ret = false;
#if PROFILING
ScopedTiming st("capture read");
#endif
mtx.lock();
capture.read(org_img);
mtx.unlock();
ret = capture.read(org_img);
mtx.unlock();
if(ret == false)
{
quit.store(false);
continue; //
}
}

if (drm_dev.req)
Expand Down Expand Up @@ -295,4 +307,4 @@ int main(int argc, char *argv[])
}

return 0;
}
}
Loading