Skip to content

Commit

Permalink
Add camera index to the camera name
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Mar 7, 2024
1 parent 28c5873 commit b2ec863
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions indi-libcamera/indi_libcamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,38 @@

static class Loader
{
std::map<int, std::shared_ptr<INDILibCamera>> cameras;
public:
Loader()
{
load();
}

public:
public:
void load()
{
RPiCamINDIApp app;
int argc = 0;
char *argv[] = {};
auto options = app.GetOptions();
if (options->Parse(argc, argv))
std::map<int, std::shared_ptr<INDILibCamera>> cameras;
public:
Loader()
{
auto new_cameras = app.GetCameras();
load();
}

if (new_cameras.size() == 0)
public:
public:
void load()
{
RPiCamINDIApp app;
int argc = 0;
char *argv[] = {};
auto options = app.GetOptions();
if (options->Parse(argc, argv))
{
IDLog("No cameras detected.");
return;
}
auto new_cameras = app.GetCameras();

for (size_t i = 0; i < new_cameras.size(); i++)
{
auto newCamera = new INDILibCamera(i, new_cameras[i]->properties());
cameras[i] = std::shared_ptr<INDILibCamera>(newCamera);
if (new_cameras.size() == 0)
{
IDLog("No cameras detected.");
return;
}

for (size_t i = 0; i < new_cameras.size(); i++)
{
auto newCamera = new INDILibCamera(i, new_cameras[i]->properties());
cameras[i] = std::shared_ptr<INDILibCamera>(newCamera);
}
}
}
}

} loader;

Expand All @@ -90,7 +90,7 @@ INDILibCamera::INDILibCamera(uint8_t index, const libcamera::ControlList &list)
{
setVersion(LIBCAMERA_VERSION_MAJOR, LIBCAMERA_VERSION_MINOR);
signal(SIGBUS, default_signal_handler);
auto fullName = std::string("LibCamera ") + list.get(properties::Model).value();
auto fullName = std::string("LibCamera ") + list.get(properties::Model).value() + "-" + std::to_string(index);
setDeviceName(fullName.c_str());
}

Expand Down Expand Up @@ -1302,4 +1302,4 @@ INDI_PIXEL_FORMAT INDILibCamera::bayerToPixelFormat(const char *bayer)
return INDI_BAYER_BGGR;

return INDI_MONO;
}
}

0 comments on commit b2ec863

Please sign in to comment.