diff options
Diffstat (limited to 'opencv')
| -rw-r--r-- | opencv/cvimage.h | 56 | ||||
| -rw-r--r-- | opencv/hello-opencv.cpp | 1 | ||||
| -rw-r--r-- | opencv/hello-opencv.d | 16 |
3 files changed, 60 insertions, 13 deletions
diff --git a/opencv/cvimage.h b/opencv/cvimage.h index b96f704..7588673 100644 --- a/opencv/cvimage.h +++ b/opencv/cvimage.h @@ -1,8 +1,21 @@ #include <math.h> +#include <cv.h> using namespace std; //converting to use a cv image... +//cv::Mat supports most of what we want here +//need to think +//http://answers.opencv.org/question/8202/using-external-image-data-in-a-cvmat/ + +//all access to the image is presently through a pointer to the data +//cv::Mat supports this + +//how will copying work? +//Rotor::Image will contain a cv::Mat object which may own its data or inherit it +//cv::Mat should take care of reference counting + +//can cv::Mat namespace Rotor { class pixeltables{ @@ -74,6 +87,13 @@ namespace Rotor { ownsRGBdata=ownsAdata=ownsZdata=false; } bool setup(int _w,int _h){ //set up with internal data + rgb.create(_w,_h,CV_8UC3); + RGBdata=rgb.data; //can move to use the bare pointer eventually + ownsRGBdata=false; //will not be necessary + w=_w; + h=_h; + return true; + /* if (w!=_w||h!=_h||!ownsRGBdata||!ownsAdata||!ownsZdata){ free(); w=_w; @@ -85,8 +105,18 @@ namespace Rotor { return true; } else return false; + */ } - bool setup_fromRGB(int _w,int _h,uint8_t *pRGBdata){ //possibility of just resetting pointer? + bool setup_fromRGB(int _w,int _h,uint8_t *pRGBdata){ + //here the data belongs to libavcodec or other + //could move to using cv::Mat there also and just passing cv:Mat over + rgb=cv::Mat(_w,_h,CV_8UC3,pRGBdata); + RGBdata=rgb.data; //can move to use the bare pointer eventually + ownsRGBdata=false; //will not be necessary + w=_w; + h=_h; + return true; + /* if (w!=_w||h!=_h||ownsRGBdata||!ownsAdata||!ownsZdata){ free(); w=_w; @@ -99,14 +129,32 @@ namespace Rotor { return true; } return false; + */ + } + bool setup_fromMat(cv::Mat& othermat){ + //here the mat belongs to another Image object + rgb=cv::Mat(othermat); + RGBdata=rgb.data; //can move to use the bare pointer eventually + ownsRGBdata=false; //will not be necessary + w=rgb.rows; + h=rgb.cols; + return true; } Image* clone(){ - Image *t=new Image(w,h); + Image *t=new Image(); + t->rgb=rgb.clone(); + t->w=w; + t->h=h; + t->RGBdata=t->rgb.data; //can move to use the bare pointer eventually + t->ownsRGBdata=false; //will not be necessary + /* for (int i=0;i<w*h*3;i++) { t->RGBdata[i]=RGBdata[i]; } + */ return t; } + //believe these still work, don't know if these optimisations are better than opencvs.. Image & operator+=(const Image &other) { if (other.w!=w||other.h!=h) { cerr<<"Rotor: cannot add images with different sizes! (wanted "<<w<<"x"<<h<<", got "<<other.w<<"x"<<other.h<<")"<<endl; @@ -126,8 +174,6 @@ namespace Rotor { else { for (int i=0;i<w*h*3;i++){ //calculate with tables - uint8_t p1=RGBdata[i]; - uint8_t p2=other.RGBdata[i]; RGBdata[i]=pixels.multiply[RGBdata[i]][other.RGBdata[i]]; } } @@ -213,5 +259,7 @@ namespace Rotor { uint16_t *Zdata; int h,w; bool ownsRGBdata,ownsAdata,ownsZdata; //better done through auto_ptr? + + cv::Mat rgb; }; }
\ No newline at end of file diff --git a/opencv/hello-opencv.cpp b/opencv/hello-opencv.cpp index ed8de6b..8f0c566 100644 --- a/opencv/hello-opencv.cpp +++ b/opencv/hello-opencv.cpp @@ -16,7 +16,6 @@ #include <stdlib.h> #include <stdio.h> #include <math.h> -#include <cv.h> #include <highgui.h> #include "cvimage.h" diff --git a/opencv/hello-opencv.d b/opencv/hello-opencv.d index eebafe9..c7b95b9 100644 --- a/opencv/hello-opencv.d +++ b/opencv/hello-opencv.d @@ -33,10 +33,10 @@ /usr/include/i386-linux-gnu/bits/nan.h \ /usr/include/i386-linux-gnu/bits/mathdef.h \ /usr/include/i386-linux-gnu/bits/mathcalls.h \ - /usr/include/i386-linux-gnu/bits/mathinline.h /usr/include/opencv/cv.h \ - /usr/include/opencv2/core/core_c.h /usr/include/opencv2/core/types_c.h \ - /usr/include/assert.h /usr/include/string.h \ - /usr/include/i386-linux-gnu/bits/string3.h \ + /usr/include/i386-linux-gnu/bits/mathinline.h \ + /usr/include/opencv/highgui.h /usr/include/opencv2/core/core_c.h \ + /usr/include/opencv2/core/types_c.h /usr/include/assert.h \ + /usr/include/string.h /usr/include/i386-linux-gnu/bits/string3.h \ /usr/lib/gcc/i686-linux-gnu/4.7/include/float.h \ /usr/lib/gcc/i686-linux-gnu/4.7/include/stdint.h /usr/include/stdint.h \ /usr/include/i386-linux-gnu/bits/wchar.h \ @@ -141,7 +141,9 @@ /usr/include/c++/4.7/bits/stl_multimap.h \ /usr/include/opencv2/core/operations.hpp \ /usr/include/opencv2/core/mat.hpp \ - /usr/include/opencv2/imgproc/imgproc_c.h \ + /usr/include/opencv2/highgui/highgui_c.h \ + /usr/include/opencv2/highgui/highgui.hpp cvimage.h \ + /usr/include/opencv/cv.h /usr/include/opencv2/imgproc/imgproc_c.h \ /usr/include/opencv2/imgproc/types_c.h \ /usr/include/opencv2/imgproc/imgproc.hpp \ /usr/include/opencv2/video/tracking.hpp \ @@ -191,6 +193,4 @@ /usr/include/opencv2/legacy/compat.hpp \ /usr/include/opencv2/core/internal.hpp \ /usr/include/i386-linux-gnu/sys/mman.h \ - /usr/include/i386-linux-gnu/bits/mman.h /usr/include/opencv/highgui.h \ - /usr/include/opencv2/highgui/highgui_c.h \ - /usr/include/opencv2/highgui/highgui.hpp cvimage.h + /usr/include/i386-linux-gnu/bits/mman.h |
