[127] | 1 |
|
---|
| 2 | // Includes, project.
|
---|
| 3 | #include "VislabComponent.hpp"
|
---|
| 4 | #include "VislabCamera.hpp"
|
---|
| 5 |
|
---|
| 6 | // Includes, pacpus.
|
---|
| 7 | #include <Pacpus/kernel/ComponentFactory.h>
|
---|
| 8 | #include <Pacpus/kernel/Log.h>
|
---|
| 9 | #include <Pacpus/kernel/DbiteFileTypes.h>
|
---|
[131] | 10 | #include <Pacpus/kernel/DbiteException.h>
|
---|
| 11 | #include <lib3dv-1.2.0/lib3dv/device.h>
|
---|
[127] | 12 | #include <20150310_lib3dv-1.2.0/src/display.h>
|
---|
| 13 |
|
---|
| 14 | // Includes, qt.
|
---|
| 15 | #include <QDir>
|
---|
| 16 | #include <QMetaType>
|
---|
| 17 |
|
---|
| 18 | // Includes, standard.
|
---|
| 19 | #include <stdexcept>
|
---|
| 20 |
|
---|
| 21 | #include <boost/asio/io_service.hpp>
|
---|
| 22 | #include <boost/bind.hpp>
|
---|
| 23 | #include <boost/ref.hpp>
|
---|
| 24 | #include <boost/thread.hpp>
|
---|
| 25 |
|
---|
| 26 | using namespace pacpus;
|
---|
| 27 |
|
---|
| 28 | // Declare the logger and register the new component.
|
---|
| 29 | //DECLARE_STATIC_LOGGER("pacpus.component.vislabCamera")
|
---|
| 30 | //REGISTER_COMPONENT(VislabComponent, "Camera");
|
---|
| 31 |
|
---|
| 32 | ComponentFactory<VislabComponent> sFactory("VislabComponent");
|
---|
| 33 |
|
---|
| 34 | VislabComponent::VislabComponent(QString const& name)
|
---|
| 35 | :ComponentBase(name),
|
---|
| 36 | camera(name)
|
---|
| 37 | {
|
---|
| 38 |
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | VislabComponent::~VislabComponent()
|
---|
| 42 | {
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | void
|
---|
| 48 | VislabComponent::stopActivity()
|
---|
| 49 | {
|
---|
| 50 | camera.close();
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | void
|
---|
| 54 | VislabComponent::startActivity()
|
---|
| 55 | {
|
---|
| 56 | camera.open();
|
---|
| 57 |
|
---|
| 58 | try
|
---|
| 59 | {
|
---|
| 60 | QString filename = name() + ".dbt";
|
---|
| 61 | //mDBTFile.open(filename.toStdString(), WriteMode, FILE_JPEG,MAX_LENGTH_NAME);
|
---|
| 62 | }
|
---|
| 63 | catch (std::exception const& e)
|
---|
| 64 | {
|
---|
| 65 | LOG_ERROR(e.what());
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | ComponentBase::COMPONENT_CONFIGURATION
|
---|
| 72 | VislabComponent::configureComponent(XmlComponentConfig config)
|
---|
| 73 | {
|
---|
| 74 | try
|
---|
| 75 | {
|
---|
| 76 | QDir directory;
|
---|
| 77 | if (!directory.exists(name().toLatin1()) && !directory.mkdir(name().toLatin1()))
|
---|
| 78 | throw std::runtime_error("cannot create the webcam directory");
|
---|
| 79 |
|
---|
| 80 | //mFilenameTemplate = QString("%1/image-%2.jpg").arg(name());
|
---|
| 81 | //LOG_INFO("template filename: " << mFilenameTemplate);
|
---|
| 82 | }
|
---|
| 83 | catch (std::exception const& e)
|
---|
| 84 | {
|
---|
| 85 | LOG_ERROR(e.what());
|
---|
| 86 | return ComponentBase::CONFIGURED_FAILED;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | return ComponentBase::CONFIGURED_OK;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | void VislabComponent::addOutputs()
|
---|
| 93 | {
|
---|
[138] | 94 | addOutput<cv::Mat, VislabComponent>("image");
|
---|
[133] | 95 | addOutput<cv::Mat, VislabComponent>("disparity");
|
---|
[127] | 96 | }
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 |
|
---|