1 | #include "VislabImageProcessor.h"
|
---|
2 |
|
---|
3 | #if (OPENCV_MAJOR == 3)
|
---|
4 | # include <opencv2/opencv.hpp>
|
---|
5 | # include <opencv2/highgui.hpp>
|
---|
6 | #else
|
---|
7 | # include <opencv/cv.h>
|
---|
8 | # include <opencv/highgui.h>
|
---|
9 | #endif
|
---|
10 |
|
---|
11 |
|
---|
12 | VislabImageProcessor::VislabImageProcessor(const QString& name, lib3dv::image::type::types imageType)
|
---|
13 | :mImageType(imageType), mName(name)
|
---|
14 | {
|
---|
15 | }
|
---|
16 |
|
---|
17 | void VislabImageProcessor::image_callback(boost::shared_ptr< const lib3dv::image> image)
|
---|
18 | {
|
---|
19 | if(image->type() == mImageType)
|
---|
20 | {
|
---|
21 | /*! Type picture : Mono 8 */
|
---|
22 | if(image->format() == lib3dv::image::format::MONO8)
|
---|
23 | {
|
---|
24 | cv::Mat cvimage(image->height(), image->width(), CV_8UC1);
|
---|
25 | std::memcpy(cvimage.data,image->data(),image->height()*image->width());
|
---|
26 | /*for(int i=0;i<image->m_height*image->m_width;i++)
|
---|
27 | {
|
---|
28 | cvimage.data[i] = image->m_buffer[i];
|
---|
29 | }*/
|
---|
30 | process(cvimage);
|
---|
31 | }
|
---|
32 |
|
---|
33 | /*! Type picture : Mono 16 */
|
---|
34 | if(image->format() == lib3dv::image::format::MONO16)
|
---|
35 | {
|
---|
36 | cv::Mat cvimage(image->height(), image->width(), CV_16UC1);
|
---|
37 | std::memcpy(cvimage.data,image->data(),image->height()*image->width()*2);
|
---|
38 | /**for(int i=0;i<image->m_height*image->m_width*2;i++)
|
---|
39 | {
|
---|
40 | cvimage.data[i] = image->m_buffer[i];
|
---|
41 | }*/
|
---|
42 | process(cvimage);
|
---|
43 | }
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | QString VislabImageProcessor::getName()
|
---|
48 | {
|
---|
49 | return mName;
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|