1 | // Includes, project.
|
---|
2 | #include "VislabCamera.hpp"
|
---|
3 |
|
---|
4 | // Includes, qt.imageformat
|
---|
5 | #include <QDebug>
|
---|
6 |
|
---|
7 | // Includes, standard.
|
---|
8 | #include <cassert>
|
---|
9 | #include <stdexcept>
|
---|
10 |
|
---|
11 | // Includes lib3dv
|
---|
12 | #include <lib3dv-1.2.0/lib3dv/device.h>
|
---|
13 | #include "DiskWriter.h"
|
---|
14 | #include "Display.h"
|
---|
15 | #include "VislabImageProcessor.h"
|
---|
16 |
|
---|
17 | #include <boost/asio/io_service.hpp>
|
---|
18 | #include <boost/asio/ip/address.hpp>
|
---|
19 | #include <boost/bind.hpp>
|
---|
20 | #include <boost/ref.hpp>
|
---|
21 | #include <boost/thread.hpp>
|
---|
22 |
|
---|
23 | using namespace pacpus;
|
---|
24 |
|
---|
25 | //ComponentFactory<VislabCamera> sFactory("VislabComponent");
|
---|
26 |
|
---|
27 | VislabCamera::VislabCamera(const QString& name)
|
---|
28 | :diskwriterVideo(name,lib3dv::image::type::RIGHT_RECTIFIED),
|
---|
29 | diskwriterDisparite(name,lib3dv::image::type::DSI),
|
---|
30 | displayVideo("Video",lib3dv::image::type::RIGHT_RECTIFIED),
|
---|
31 | displayDisparite("Disparite",lib3dv::image::type::DSI)
|
---|
32 | {
|
---|
33 |
|
---|
34 | }
|
---|
35 |
|
---|
36 | VislabCamera::~VislabCamera()
|
---|
37 | {
|
---|
38 |
|
---|
39 | }
|
---|
40 |
|
---|
41 | void VislabCamera::open()
|
---|
42 | {
|
---|
43 | curr_devices = lib3dv::device::enumerate(boost::asio::ip::address_v4::from_string("192.168.0.2"), 1, error);
|
---|
44 | if(error != lib3dv::error::NONE)
|
---|
45 | std::cout << "[EE] 3dv-client: error detected: " << error << std::endl;
|
---|
46 |
|
---|
47 | if(curr_devices.empty())
|
---|
48 | {
|
---|
49 | std::cout << "[EE] 3dv-client: no devices found" << std::endl;
|
---|
50 | //return lib3dv::error::NONE;
|
---|
51 | }
|
---|
52 | //disk_writer = boost::shared_ptr< ::disk_writer>(new ::disk_writer(paths, data_format, autonumber, params, guid_type, log_level));
|
---|
53 | curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>, unsigned int)>(boost::bind(&::VislabImageProcessor::image_callback, &displayVideo, _1, _2)));
|
---|
54 | curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>, unsigned int)>(boost::bind(&::VislabImageProcessor::image_callback, &displayDisparite, _1, _2)));
|
---|
55 | curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>, unsigned int)>(boost::bind(&::VislabImageProcessor::image_callback, &diskwriterVideo, _1, _2)));
|
---|
56 | curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>, unsigned int)>(boost::bind(&::VislabImageProcessor::image_callback, &diskwriterDisparite, _1, _2)));
|
---|
57 | curr_devices[0].start_transmission(error);
|
---|
58 | if(error != lib3dv::error::NONE)
|
---|
59 | std::cout << "[EE] 3dv-client: error detected: " << error << std::endl;
|
---|
60 | }
|
---|
61 |
|
---|
62 | void
|
---|
63 | VislabCamera::close()
|
---|
64 | {
|
---|
65 | curr_devices[0].stop_transmission(error);
|
---|
66 | //curr_devices[0].poweroff(error);
|
---|
67 | }
|
---|