Skip to content
Snippets Groups Projects
Commit 2635e905 authored by Sebastian Gomez-Gonzalez's avatar Sebastian Gomez-Gonzalez
Browse files

Some new files for the client server part (Not tested)

parent b1770e53
Branches
Tags
No related merge requests found
......@@ -17,7 +17,7 @@ In a modern version of Ubuntu you might be able to get the right version of thes
```
sudo apt-get install libopencv-dev libboost-dev libboost-log-dev libboost-program-options-dev \
libboost-test-dev cmake
libboost-test-dev cmake libzmqpp-dev
```
However, it is very likely that the software version is not up to date. We use OpenCV 3.2,
......
{
"server": {
"position_publisher": "tcp://*:7650"
},
"log": {
"auto_flush": true,
"file": "/tmp/ball_tracking.log"
},
"cameras": {
"type": "pvapi",
"conf": [
{
"ID": 1,
"IP": "192.168.101.101",
"conf": {
"mtu": 8228,
"EnumSet": {
"FrameStartTriggerMode": "FixedRate",
"AcquisitionMode": "Continuous",
"SyncOut1Mode": "Exposing"
},
"Float32Set": {
"FrameRate": 2.0
},
"Uint32Set": {
"StreamBytesPerSecond": 123000000,
"ExposureValue": 4000
},
"Sleep": 500,
"FrameTimeOut": 2000,
"debayer": true
}
},
{
"ID": 2,
"IP": "192.168.102.102",
"conf": {
"mtu": 8228,
"EnumSet": {
"FrameStartTriggerMode": "SyncIn1",
"AcquisitionMode": "Continuous"
},
"Uint32Set": {
"StreamBytesPerSecond": 123000000,
"ExposureValue": 4000
},
"FrameTimeOut": 2000,
"debayer": true
}
}
]
},
"trackers": [
{"ID": 1, "file": "cam1.json"},
{"ID": 2, "file": "cam2.json"}
]
}
#ifndef BALL_TRACKING_SERVER
#define BALL_TRACKING_SERVER
#include <memory>
#include <json.hpp>
namespace ball_tracking {
class TrackServer {
private:
class Impl;
std::shared_ptr<Impl> _impl;
public:
TrackServer(const nlohmann::json& conf);
~TrackServer();
};
};
#endif
#include <ball_tracking/server.hpp>
#include <ball_tracking/tracker.hpp>
#include <ball_tracking/utils.hpp>
#include <zmqpp/zmqpp.hpp>
#include <string>
#include <unordered_map>
#include <thread>
#include <camera.hpp>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
namespace logging = boost::log;
using namespace std;
using json = nlohmann::json;
using namespace camera;
namespace ball_tracking {
class TrackServer::Impl {
public:
unordered_map<unsigned int,Tracker> trackers;
ThreadedListener tlistener;
zmqpp::socket position_pub;
CameraSet cams;
void start_trackers(const json& conf) {
for (auto tracker : conf) {
unsigned int ID = tracker.at("ID");
if (tracker.count("file")) {
json tconf = load_json(tracker.at("file"));
}
}
}
void start_server(const json& conf) {
if (conf.count("log")) set_log_config(conf.at("log"));
//1) Start the networking sockets
const json& srv_conf = conf.at("servers");
zmqpp::context context;
auto socket_type = zmqpp::socket_type::pub;
position_pub = zmqpp::socket(context, socket_type);
const string& pp_url = srv_conf.at("position_publisher");
BOOST_LOG_TRIVIAL(info) << "Binding to " << pp_url;
position_pub.bind(pp_url);
//2) Start the tracking pipeline
start_trackers(conf.at("trackers"));
//3) Start the cameras
cams = CameraSet(conf.at("cameras"));
}
};
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment