source: pacpussensors/trunk/Vislab/VislabCamera.cpp@ 139

Last change on this file since 139 was 134, checked in by ldecherf, 8 years ago

Output modification

File size: 3.1 KB
RevLine 
[127]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
23using namespace pacpus;
24
25//ComponentFactory<VislabCamera> sFactory("VislabComponent");
[132]26/*! Constructor with 2 instantiations of DiskWriter and 2 instatiations of Display*/
[127]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),
[134]31 displayDisparite("Disparite",lib3dv::image::type::DSI),
32 outputVideo(lib3dv::image::type::RIGHT_RECTIFIED),
33 outputDisparite(lib3dv::image::type::DSI)
[127]34{
35
36}
37
38VislabCamera::~VislabCamera()
39{
40
41}
42
43void VislabCamera::open()
44{
[131]45
46 curr_devices = lib3dv::device::enumerate(boost::asio::ip::address_v4::from_string("192.168.0.1"), 1, error);
[127]47 if(error != lib3dv::error::NONE)
48 std::cout << "[EE] 3dv-client: error detected: " << error << std::endl;
49
50 if(curr_devices.empty())
51 {
52 std::cout << "[EE] 3dv-client: no devices found" << std::endl;
53 //return lib3dv::error::NONE;
54 }
55 //disk_writer = boost::shared_ptr< ::disk_writer>(new ::disk_writer(paths, data_format, autonumber, params, guid_type, log_level));
[131]56 curr_devices[0].log_level(2);
57 curr_devices[0].timeout(boost::posix_time::milliseconds(5000));
[127]58 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)));
59 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)));
60 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)));
61 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)));
62 curr_devices[0].start_transmission(error);
63 if(error != lib3dv::error::NONE)
64 std::cout << "[EE] 3dv-client: error detected: " << error << std::endl;
[131]65 else
66 std::cout << "[II] 3dv-client: device successfully opened" << std::endl;
[127]67}
68
[133]69void VislabCamera::close()
[127]70{
71 curr_devices[0].stop_transmission(error);
72 //curr_devices[0].poweroff(error);
73}
[133]74
75void VislabCamera::setVideoOutput(OutputInterface<cv::Mat, VislabComponent>* output)
76{
77 outputVideo.setOutput(output);
78}
79
80void VislabCamera::setDispariteOutput(OutputInterface<cv::Mat, VislabComponent>* output)
81{
82 outputDisparite.setOutput(output);
83}
Note: See TracBrowser for help on using the repository browser.