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

Camera factory get cameras should enumerate multiple ps3 eye cameras #176

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 7 additions & 4 deletions AITracker/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
43 changes: 26 additions & 17 deletions Client/src/camera/CameraFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,41 @@ std::vector<std::shared_ptr<Camera>> CameraFactory::getCameras(CameraSettings& s
{
std::vector<std::shared_ptr<Camera>> cams;

// Search first for any PS3 camera.
try
{
cams.push_back(std::make_shared<Ps3Camera>(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<Camera> c = std::make_shared<OCVCamera>(settings.width, settings.height, settings.fps, i);
std::shared_ptr<Camera> c = std::make_shared<Ps3Camera>(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<Camera> c = std::make_shared<OCVCamera>(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;
Expand Down