Add overload to maintain backward compatibility with existing code that uses local USB cameras or SVO files. New API: // For network stream cameras open(const std::string& ip, int port, Trigger* ref, int sdk_gpu_id) // For local cameras (USB, SVO, etc.) - backward compatible open(sl::InputType input, Trigger* ref, int sdk_gpu_id) This allows the same ClientPublisher class to work with both: - Remote cameras via streaming (new use case) - Local cameras via USB/SVO (original use case) Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
79 lines
1.8 KiB
C++
Executable File
79 lines
1.8 KiB
C++
Executable File
#ifndef __SENDER_RUNNER_HDR__
|
|
#define __SENDER_RUNNER_HDR__
|
|
|
|
#include <sl/Camera.hpp>
|
|
#include <sl/Fusion.hpp>
|
|
|
|
#include <thread>
|
|
#include <condition_variable>
|
|
|
|
// Hard-coded camera stream configuration from inside_network.json
|
|
struct CameraStreamConfig {
|
|
int serial_number;
|
|
std::string ip_address;
|
|
int port;
|
|
};
|
|
|
|
// Predefined camera stream configurations
|
|
const std::vector<CameraStreamConfig> CAMERA_STREAM_CONFIGS = {
|
|
{44289123, "192.168.128.2", 30000},
|
|
{44435674, "192.168.128.2", 30002},
|
|
{41831756, "192.168.128.2", 30004},
|
|
{46195029, "192.168.128.2", 30006}
|
|
};
|
|
|
|
struct Trigger{
|
|
|
|
void notifyZED(){
|
|
|
|
cv.notify_all();
|
|
|
|
if(running){
|
|
bool wait_for_zed = true;
|
|
const int nb_zed = states.size();
|
|
while(wait_for_zed){
|
|
int count_r = 0;
|
|
for(auto &it:states)
|
|
count_r += it.second;
|
|
wait_for_zed = count_r != nb_zed;
|
|
sl::sleep_ms(1);
|
|
}
|
|
for(auto &it:states)
|
|
it.second = false;
|
|
}
|
|
}
|
|
|
|
std::condition_variable cv;
|
|
bool running = true;
|
|
std::map<int, bool> states;
|
|
};
|
|
|
|
class ClientPublisher{
|
|
|
|
public:
|
|
ClientPublisher();
|
|
~ClientPublisher();
|
|
|
|
// Open camera from stream (IP:port) - for network camera streaming
|
|
bool open(const std::string& ip, int port, Trigger* ref, int sdk_gpu_id);
|
|
|
|
// Open local camera (USB/serial/SVO) - backward compatible overload
|
|
bool open(sl::InputType input, Trigger* ref, int sdk_gpu_id);
|
|
|
|
void start();
|
|
void stop();
|
|
void setStartSVOPosition(unsigned pos);
|
|
|
|
int getSerialNumber() const { return serial; }
|
|
|
|
private:
|
|
sl::Camera zed;
|
|
void work();
|
|
std::thread runner;
|
|
int serial;
|
|
std::mutex mtx;
|
|
Trigger *p_trigger;
|
|
};
|
|
|
|
#endif // ! __SENDER_RUNNER_HDR__
|