/** * This file is part of DSO. * * Copyright 2016 Technical University of Munich and Intel. * Developed by Jakob Engel , * for more information see . * If you use this code, please cite the respective publications as * listed on the above website. * * DSO is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DSO is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DSO. If not, see . */ #pragma once #include "util/NumType.h" #include "algorithm" namespace dso { template class MinimalImage { public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW int w; int h; T* data; /* * creates minimal image with own memory */ inline MinimalImage(int w_, int h_) : w(w_), h(h_) { data = new T[w*h]; ownData=true; } /* * creates minimal image wrapping around existing memory */ inline MinimalImage(int w_, int h_, T* data_) : w(w_), h(h_) { data = data_; ownData=false; } inline ~MinimalImage() { if(ownData) delete [] data; } inline MinimalImage* getClone() { MinimalImage* clone = new MinimalImage(w,h); memcpy(clone->data, data, sizeof(T)*w*h); return clone; } inline T& at(int x, int y) {return data[(int)x+((int)y)*w];} inline T& at(int i) {return data[i];} inline void setBlack() { memset(data, 0, sizeof(T)*w*h); } inline void setConst(T val) { for(int i=0;i Vec3b; typedef MinimalImage MinimalImageF; typedef MinimalImage MinimalImageF3; typedef MinimalImage MinimalImageB; typedef MinimalImage MinimalImageB3; typedef MinimalImage MinimalImageB16; }