1 #ifndef MTF_INPUT_UTILS_H     2 #define MTF_INPUT_UTILS_H     4 #include "mtf/Utilities/excpUtils.h"     5 #include "mtf/Macros/common.h"     7 #include "opencv2/core/core.hpp"     8 #include "opencv2/highgui/highgui.hpp"     9 #include "boost/filesystem/operations.hpp"    12 #include <visp3/core/vpImage.h>    13 #include <visp3/core/vpFrameGrabber.h>    15 #ifndef DISABLE_XVISION    20 #include <XVDig1394.h>    21 #include <XVImageRGB.h>    22 #include <XVImageSeq.h>    26 namespace fs = boost::filesystem;
    31     enum FrameType{ MUTABLE };
    60         virtual bool initialize() = 0;
    61         virtual bool update() = 0;
    63         virtual void remapBuffer(
unsigned char **new_addr);
    65         virtual int getFrameID()
 const{ 
return frame_id; }
    66         virtual const cv::Mat& getFrame()
 const{
    67             return cv_buffer[buffer_id];
    70         virtual cv::Mat& 
getFrame(FrameType frame_type){
    71             return cv_buffer[buffer_id];
    73         virtual int getNFrames()
 const{ 
return n_frames; }
    74         virtual int getHeight()
 const{ 
return img_height; }
    75         virtual int getWidth()
 const{ 
return img_width; }
    82         virtual void getFrame(vpImage<vpRGBa> &vp_img)
 const {
    83             convert(getFrame(), vp_img);
    85         virtual void convert(
const vpImage<vpRGBa> &vp_img, cv::Mat &cv_img) 
const;
    86         virtual void convert(
const cv::Mat &cv_img, vpImage<vpRGBa> &vp_img) 
const;
    90         int n_frames, img_width, img_height, n_channels, frame_id;
    91         int n_buffers, buffer_id, invert_seq;
    95         vector<cv::Mat> cv_buffer;
   101             int _img_type = CV_8UC3);
   103         bool initialize() 
override;
   104         bool update() 
override;
   108         cv::VideoCapture cap_obj;       
   116             Default, res640x480, res800x600, res1024x768,
   117             res1280x720, res1920x1080
   120             Default, res640x480, res800x600, res1024x768,
   121             res1280x960, res1600x1200
   123         enum class VpDepthFW{
   124             Default, RGB, YUV422, MONO8, MONO16
   127             Default, fps25, fps50
   130             Default, fps15, fps30, fps60, fps120, fps240,
   131             fps7_5, fps3_75, fps1_875
   134             Default, iso100, iso200, iso400,
   135             iso800, iso1600, iso3200
   145             bool _pg_fw_print_info,
   146             float _pg_fw_shutter_ms,
   148             float _pg_fw_exposure,
   149             float _pg_fw_brightness);
   160         float pg_fw_shutter_ms;
   162         float pg_fw_exposure;
   163         float pg_fw_brightness;
   168         typedef InputVPParams::VpResUSB VpResUSB;
   169         typedef InputVPParams::VpResFW VpResFW;
   170         typedef InputVPParams::VpDepthFW VpDepthPGFW;
   171         typedef InputVPParams::VpFpsUSB VpFpsUSB;
   172         typedef InputVPParams::VpFpsFW VpFpsFW;
   173         typedef InputVPParams::VpISOFW VpISOFW;
   178         bool initialize() 
override;
   179         bool update() 
override;
   185         typedef vpImage<vpRGBa> VPImgType;
   187         std::unique_ptr<vpFrameGrabber> cap_obj;
   190 #ifndef DISABLE_XVISION   233         typedef XV_RGB24 PIX_TYPE24;
   234         typedef XVImageRGB< PIX_TYPE24 > IMAGE_TYPE24;
   235         typedef XV_RGB PIX_TYPE32;
   236         typedef XVImageRGB< PIX_TYPE32 > IMAGE_TYPE32;
   238         typedef XVVideo< IMAGE_TYPE24 > VID24;
   239         typedef XVVideo< IMAGE_TYPE32 > VID32;
   241         typedef XVV4L2< IMAGE_TYPE24 > V4L2;
   242         typedef XVDig1394< IMAGE_TYPE24 > DIG1394;
   243         typedef XVImageSeq< IMAGE_TYPE24 > IMG;
   244         typedef XVMpeg< IMAGE_TYPE32 >  MPG;
   249         int img_height, img_width;
   250         virtual void initFrame(
int) = 0;
   251         virtual void updateFrame(
int) = 0;
   252         virtual void initBuffer(PIX_TYPE24**, IMAGE_TYPE24*) = 0;
   253         virtual void updateBuffer(PIX_TYPE24**) = 0;
   258             string dev_path, 
string dev_fmt, 
string file_path,
   259             int n_buffers_in, 
int n_frames);
   260         void initFrame(
int init_buffer_id) 
override;
   261         void initBuffer(PIX_TYPE24 **init_addrs,
   262             IMAGE_TYPE24 *buffer_addrs) 
override;
   263         void updateFrame(
int buffer_id) 
override;
   264         void updateBuffer(PIX_TYPE24 **new_addrs) 
override;
   266         std::unique_ptr<VID24> vid;
   267         IMAGE_TYPE24 *vid_buffers;
   272         InputXV32(
int img_source, 
string file_path);
   273         void initFrame(
int init_buffer_id) 
override;
   274         void initBuffer(PIX_TYPE24 **init_addrs,
   275             IMAGE_TYPE24 *buffer_addrs) 
override;
   278         void updateFrame(
int buffer_id24) 
override;
   279         void updateBuffer(PIX_TYPE24 **new_addrs)
 override{}
   282         std::unique_ptr<VID32> vid;
   283         IMAGE_TYPE24 *buffer24;
   285         void copyFrame32ToBuffer24(IMAGE_TYPE32 &src_frame, 
int buffer_id24);
   291         typedef float PIX_TYPE_GS;
   292         typedef XV_RGB24 PIX_TYPE;
   293         typedef XVImageRGB<PIX_TYPE> IMAGE_TYPE;
   294         typedef XVImageScalar<PIX_TYPE_GS> IMAGE_TYPE_GS;
   297             params(_params), src(
nullptr){}
   303         bool initialize() 
override;
   304         bool update() 
override;
   305         void remapBuffer(
unsigned char** new_addr) 
override;
   308         std::unique_ptr<InputXVSource> src;
   309         vector<IMAGE_TYPE> xv_buffer;
   310         void copyXVToCV(IMAGE_TYPE_GS &xv_img, cv::Mat &cv_img);
   311         void copyXVToCVIter(IMAGE_TYPE_GS &xv_img, cv::Mat &cv_img);
   312         void copyXVToCVIter(IMAGE_TYPE &xv_img, cv::Mat &cv_img);
   324         bool initialize()
 override{ 
return true; }
   325         bool update()
 override{ 
return true; }
   326         void remapBuffer(
unsigned char** new_addr)
 override{}
   327         const cv::Mat& getFrame()
 const override{ 
return curr_img; }
   328         cv::Mat& 
getFrame(FrameType)
 override{ 
return curr_img; }
   329         int getFrameID()
 const override{ 
return 0; }
   330         int getHeight()
 const override{ 
return curr_img.rows; }
   331         int getWidth()
 const override{ 
return curr_img.cols; }
   333     int getNumberOfFrames(
const char *file_template);
   334     int getNumberOfVideoFrames(
const char *file_name);
 
basic functions for preprocessing the raw input image using filtering, resizing and histogram equaliz...
Definition: histUtils.h:20