source: pacpussensors/trunk/Vislab/VislabCamera.cpp

Last change on this file was 147, checked in by ldecherf, 8 years ago

Ajout CameraPlayer

File size: 3.4 KB
Line 
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/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
23using namespace pacpus;
24
25//ComponentFactory<VislabCamera> sFactory("VislabComponent");
26/*! Constructor with 2 instantiations of DiskWriter and 2 instatiations of Display*/
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 outputVideo(lib3dv::image::type::RIGHT_RECTIFIED),
33 outputDisparite(lib3dv::image::type::DSI)
34{
35
36}
37
38VislabCamera::~VislabCamera()
39{
40
41}
42
43void VislabCamera::open()
44{
45 curr_devices = lib3dv::device::enumerate(boost::asio::ip::address_v4::from_string("192.168.0.2"), 0);
46 if (error != lib3dv::error::NONE)
47 {
48 std::cout << "[EE] 3dv-client: error detected: " << error << std::endl;
49 return;
50 }
51
52 if(curr_devices.empty())
53 {
54 std::cout << "[EE] 3dv-client: no devices found" << std::endl;
55 return;
56 //return lib3dv::error::NONE;
57 }
58 //disk_writer = boost::shared_ptr< ::disk_writer>(new ::disk_writer(paths, data_format, autonumber, params, guid_type, log_level));
59
60 //curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>)>(boost::bind(&::VislabImageProcessor::image_callback, &displayVideo, _1)));
61 //curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>)>(boost::bind(&::VislabImageProcessor::image_callback, &displayDisparite, _1)));
62 curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>)>(boost::bind(&::VislabImageProcessor::image_callback, &diskwriterVideo, _1)));
63 curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>)>(boost::bind(&::VislabImageProcessor::image_callback, &diskwriterDisparite, _1)));
64 curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>)>(boost::bind(&::VislabImageProcessor::image_callback, &outputVideo, _1)));
65 curr_devices[0].connect_image_callback(boost::function<void(boost::shared_ptr< const lib3dv::image>)>(boost::bind(&::VislabImageProcessor::image_callback, &outputDisparite, _1)));
66 curr_devices[0].start_transmission(false);
67 if(error != lib3dv::error::NONE)
68 std::cout << "[EE] 3dv-client: error detected: " << error << std::endl;
69 else
70 std::cout << "[II] 3dv-client: device successfully opened" << std::endl;
71}
72
73void VislabCamera::close()
74{
75 if (curr_devices.empty())
76 {
77 std::cout << "[EE] 3dv-client: no devices found" << std::endl;
78 return;
79 //return lib3dv::error::NONE;
80 }
81 else
82 {
83 curr_devices[0].stop_transmission();
84 }
85
86 //curr_devices[0].poweroff();
87}
88
89void VislabCamera::setVideoOutput(OutputInterface<cv::Mat, VislabComponent>* output)
90{
91 outputVideo.setOutput(output);
92}
93
94void VislabCamera::setDispariteOutput(OutputInterface<cv::Mat, VislabComponent>* output)
95{
96 outputDisparite.setOutput(output);
97}
Note: See TracBrowser for help on using the repository browser.