75 lines
1.7 KiB
C++
Executable File
75 lines
1.7 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) instead of local input
|
|
bool open(const std::string& ip, int port, 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__
|