1 | /*********************************************************************
|
---|
2 | // created: 2007/04/12 - 16:30
|
---|
3 | //
|
---|
4 | // author: Elie Al Alam & Gerald Dherbomez
|
---|
5 | //
|
---|
6 | // version: $Id: DbtPlyOpenCVManager.cpp 1239 2012-11-28 16:30:00Z kurdejma $
|
---|
7 | //
|
---|
8 | // purpose: Dbite Player OpenCV Manager implementation
|
---|
9 | *********************************************************************/
|
---|
10 |
|
---|
11 | #include "DbtPlyOpenCVManager.h"
|
---|
12 |
|
---|
13 | #include "Pacpus/kernel/ComponentFactory.h"
|
---|
14 | #include "Pacpus/kernel/ComponentManager.h"
|
---|
15 | #include "Pacpus/kernel/DbiteFileTypes.h"
|
---|
16 | #include "Pacpus/kernel/Log.h"
|
---|
17 | #include "Pacpus/PacpusTools/ShMem.h"
|
---|
18 |
|
---|
19 | #include <iostream>
|
---|
20 | #include <QImage>
|
---|
21 | #include <QMutex>
|
---|
22 |
|
---|
23 | #include <Pacpus/structures/genericStructures.h>
|
---|
24 | #include <Pacpus/kernel/InputOutputInterface.h>
|
---|
25 |
|
---|
26 | namespace pacpus {
|
---|
27 |
|
---|
28 | using namespace std;
|
---|
29 | using namespace pacpus;
|
---|
30 |
|
---|
31 | DECLARE_STATIC_LOGGER("pacpus.base.DbtPlyOpenCVManager");
|
---|
32 |
|
---|
33 | /// Construction de la fabrique de composant DbtPlyOpenCVManager
|
---|
34 | static ComponentFactory<DbtPlyOpenCVManager> sFactory("DbtPlyOpenCVManager");
|
---|
35 |
|
---|
36 | /// Constructor
|
---|
37 | DbtPlyOpenCVManager::DbtPlyOpenCVManager(QString name)
|
---|
38 | : DbtPlyFileManager (name)
|
---|
39 | {
|
---|
40 | }
|
---|
41 |
|
---|
42 | /// Destructor
|
---|
43 | DbtPlyOpenCVManager::~DbtPlyOpenCVManager()
|
---|
44 | {
|
---|
45 |
|
---|
46 | }
|
---|
47 |
|
---|
48 | void DbtPlyOpenCVManager::addInputs()
|
---|
49 | {
|
---|
50 |
|
---|
51 | }
|
---|
52 |
|
---|
53 | void DbtPlyOpenCVManager::addOutputs()
|
---|
54 | {
|
---|
55 | addOutput<cv::Mat, DbtPlyOpenCVManager>("image");
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | /// TODO: doc
|
---|
60 | void DbtPlyOpenCVManager::processData(road_time_t t, road_timerange_t tr, void * buf)
|
---|
61 | {
|
---|
62 | if (!buf) {
|
---|
63 | LOG_WARN("no data to process: empty data buffer");
|
---|
64 | return;
|
---|
65 | }
|
---|
66 |
|
---|
67 | // look at the dbt index in file manager and get the identifier of dbt structure
|
---|
68 | hdfile_header_t::DataTypeT id = dbt_[dbtIndex_].pfile->getType();
|
---|
69 |
|
---|
70 | if (id == FILE_JPEG)
|
---|
71 | {
|
---|
72 | QString imageFile = mDbtDataPath + (char *)buf;
|
---|
73 | LOG_TRACE("image path = " << imageFile);
|
---|
74 | if (mVerbose)
|
---|
75 | {
|
---|
76 | cout << "[IMAGE]:\t"
|
---|
77 | << imageFile.toStdString() << endl;
|
---|
78 | }
|
---|
79 |
|
---|
80 | cv::Mat image = cv::imread(imageFile.toStdString(),CV_LOAD_IMAGE_UNCHANGED);
|
---|
81 | if(!image.data)
|
---|
82 | {
|
---|
83 | LOG_WARN("cannot load image file '" << imageFile << "'");
|
---|
84 | return;
|
---|
85 | }
|
---|
86 | LOG_TRACE("image loaded");
|
---|
87 |
|
---|
88 | OutputInterface<cv::Mat, DbtPlyOpenCVManager> * imageOutput = getTypedOutput<cv::Mat, DbtPlyOpenCVManager>("image");
|
---|
89 | if (imageOutput && imageOutput->hasConnection()) {
|
---|
90 | imageOutput->send(image, t, tr);
|
---|
91 | }
|
---|
92 | }
|
---|
93 | }
|
---|
94 |
|
---|
95 | ComponentBase::COMPONENT_CONFIGURATION DbtPlyOpenCVManager::configureComponent(XmlComponentConfig config)
|
---|
96 | {
|
---|
97 | return DbtPlyFileManager::configureComponent(config);
|
---|
98 | }
|
---|
99 |
|
---|
100 | void DbtPlyOpenCVManager::startActivity()
|
---|
101 | {
|
---|
102 | DbtPlyFileManager::startActivity();
|
---|
103 | }
|
---|
104 |
|
---|
105 | void DbtPlyOpenCVManager::stopActivity()
|
---|
106 | {
|
---|
107 |
|
---|
108 | }
|
---|
109 |
|
---|
110 | } // namespace pacpus
|
---|