[127] | 1 | #include "VislabImageProcessor.h"
|
---|
| 2 |
|
---|
[147] | 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
|
---|
[127] | 10 |
|
---|
[142] | 11 |
|
---|
[127] | 12 | VislabImageProcessor::VislabImageProcessor(const QString& name, lib3dv::image::type::types imageType)
|
---|
| 13 | :mImageType(imageType), mName(name)
|
---|
| 14 | {
|
---|
| 15 | }
|
---|
| 16 |
|
---|
[142] | 17 | void VislabImageProcessor::image_callback(boost::shared_ptr< const lib3dv::image> image)
|
---|
[127] | 18 | {
|
---|
[142] | 19 | if(image->type() == mImageType)
|
---|
[127] | 20 | {
|
---|
[132] | 21 | /*! Type picture : Mono 8 */
|
---|
[142] | 22 | if(image->format() == lib3dv::image::format::MONO8)
|
---|
[127] | 23 | {
|
---|
[142] | 24 | cv::Mat cvimage(image->height(), image->width(), CV_8UC1);
|
---|
| 25 | std::memcpy(cvimage.data,image->data(),image->height()*image->width());
|
---|
[127] | 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 |
|
---|
[132] | 33 | /*! Type picture : Mono 16 */
|
---|
[142] | 34 | if(image->format() == lib3dv::image::format::MONO16)
|
---|
[127] | 35 | {
|
---|
[142] | 36 | cv::Mat cvimage(image->height(), image->width(), CV_16UC1);
|
---|
| 37 | std::memcpy(cvimage.data,image->data(),image->height()*image->width()*2);
|
---|
[127] | 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 |
|
---|