From a8217fdec39dbcb570726a4af5246501b8406468 Mon Sep 17 00:00:00 2001 From: searching46dof <107732149+searching46dof@users.noreply.github.com> Date: Mon, 12 Sep 2022 21:55:45 -0400 Subject: [PATCH 1/2] losing tracking due to small rectangle returned by proc_face_detect for larger distances. The symptom is currently losing face tracking at distance of approx 2 meters. the additional margin of 0.1 * width and 0.1 * height is only effective for short ranges (e.g. less than 1 meters) since the face is relatively large. For distances up to 2 meters, need additional margins approx 0.2 x width and 0.2 x height since the face is smaller For distances up to 3 meters , need additional margins approx 0.3 x width and 0.3 x height. For distances up to 4 meters, need additional margins approx 0.4 x width and 0.4 x height. --- AITracker/src/model.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/AITracker/src/model.cpp b/AITracker/src/model.cpp index 22b6fb8..3d239ce 100644 --- a/AITracker/src/model.cpp +++ b/AITracker/src/model.cpp @@ -199,10 +199,13 @@ void Tracker::proc_face_detect(float* face, float width, float height) float w = face[2]; float h = face[3]; - int crop_x1 = (int)(x); - int crop_y1 = (int)(y); - int crop_x2 = (int)(x + w); - int crop_y2 = (int)(y + h + h * 0.1f); // force a little taller BB so the chin tends to be covered + int additional_width_margin = (int)(w * 0.4f); + int additional_height_margin = (int)(h * 0.4f); + + int crop_x1 = (int)(x - additional_width_margin); + int crop_y1 = (int)(y - additional_height_margin); + int crop_x2 = (int)(x + w + additional_width_margin); + int crop_y2 = (int)(y + h + additional_height_margin); // force a little taller BB so the chin tends to be covered face[0] = (float)std::max(0, crop_x1); face[1] = (float)std::max(0, crop_y1); From ff6a4313e1ebfc42a61d189c077ef07a551d21a5 Mon Sep 17 00:00:00 2001 From: searching46dof <107732149+searching46dof@users.noreply.github.com> Date: Mon, 12 Sep 2022 22:46:00 -0400 Subject: [PATCH 2/2] CameraFactory::getCameras should enumerate multiple PS3 Eye cameras Currently CameraFactory::getCameras only enumerates 1 PS3 eye camera and up to 4 OCV cameras. Should be able to enumerated multiple PS3 eye cameras --- Client/src/camera/CameraFactory.cpp | 43 +++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/Client/src/camera/CameraFactory.cpp b/Client/src/camera/CameraFactory.cpp index d5bc034..3766e53 100644 --- a/Client/src/camera/CameraFactory.cpp +++ b/Client/src/camera/CameraFactory.cpp @@ -42,32 +42,41 @@ std::vector> CameraFactory::getCameras(CameraSettings& s { std::vector> cams; - // Search first for any PS3 camera. - try - { - cams.push_back(std::make_shared(640, 480, 60)); - cams[0]->set_settings(settings); - } - catch (...) - { - std::cout << "No PS3 camera available." << std::endl; - cams.clear(); - } - - for (int i = 0; i < 5; i++) { + bool bFoundPs3Camera = false; + // Search first for any PS3 camera. try { - std::shared_ptr c = std::make_shared(settings.width, settings.height, settings.fps, i); + std::shared_ptr c = std::make_shared(640, 480, 60); c->set_settings(settings); // Brightness / Exposure cams.push_back(std::move(c)); - std::cout << "Found ID: " << i << std::endl; + bFoundPs3Camera = true; + std::cout << "Found PS3 camera ID: " << i << std::endl; } - catch (const std::exception&) + catch (...) { - std::cout << "Not found device" << i << std::endl; } + + if (!bFoundPs3Camera) + { + // Then search or OCV Camera. + try + { + std::shared_ptr c = std::make_shared(settings.width, settings.height, settings.fps, i); + c->set_settings(settings); // Brightness / Exposure + cams.push_back(std::move(c)); + std::cout << "Found OCV camera ID: " << i << std::endl; + } + catch (const std::exception&) + { + } + } + + } + if (cams.size() == 0) + { + std::cout << "No cameras found" << std::endl; } return cams;