22 #ifndef OCTAVE_ERROR_OFFSET 23 #define OCTAVE_ERROR_OFFSET -2000 30 #define OCTAVE_NOBASE_ERROR -1+OCTAVE_ERROR_OFFSET 31 #define OCTAVE_OPENCV_TYPE_ERROR -2+OCTAVE_ERROR_OFFSET 32 #define OCTAVE_INCONSISTENT_COL_CNT_ERROR -3+OCTAVE_ERROR_OFFSET 42 errors[
OCTAVE_NOBASE_ERROR]=std::string(
"Octave: You didn't specify a global name. Global variables must start with a std::string and have sub std::strings separated by '.', e.g. 'base.name'");
52 #include <Eigen/Dense> 62 #define Octave_map octave_map 63 class octave_value_list;
101 Matrix *newMatrix(
int r,
int c);
110 void setMatrixElem(Matrix *m,
int i,
int j,
double val);
116 void deleteMatrix(Matrix *m);
127 Octave(
const vector<std::string> &args);
132 void startOctave(
const vector<std::string> &args);
149 void stopOctaveAndExit();
164 vector<vector<vector<TYPE> > > &runM(
const char* commandName,
const vector<vector<vector<TYPE> > > &in, vector<vector<vector<TYPE> > > &out);
174 vector<Eigen::Matrix<TYPE, Eigen::Dynamic, Eigen::Dynamic> > &runM(
const char* commandName,
const vector<Eigen::Matrix<TYPE, Eigen::Dynamic, Eigen::Dynamic> > &in, vector<Eigen::Matrix<TYPE, Eigen::Dynamic, Eigen::Dynamic> > &out);
180 octave_value_list runMWithInput(
const char* commandName);
185 void runM(
const char* commandName);
195 vector<cv::Mat> &runM(
const char* commandName,
const vector<cv::Mat> &in, vector<cv::Mat> &out);
210 template<
typename Derived>
212 Matrix *m=newMatrix(var.rows(),var.cols());
213 for (
int j=0; j<var.rows(); j++)
214 for (
int k=0; k<var.cols(); k++)
215 setMatrixElem(m, j, k, (
double)var(j,k));
216 int ret=setGlobalVariable(name, *m);
225 int setGlobalVariable(
const std::string &name, Matrix &m);
234 Octave_map setGlobalSubVariable(
const vector<std::string> &varNames,
const Matrix &m,
int index, octave_value &base);
242 Octave_map createGlobalSubVariable(
const vector<std::string> &varNames,
const Matrix &m,
int index,
Octave_map &base);
252 template<
typename TYPE>
253 Eigen::Matrix<TYPE, Eigen::Dynamic, 1>
str2Mat(
char *str){
254 return str2Mat<TYPE>(std::string(str));
261 template<
typename TYPE>
262 Eigen::Matrix<TYPE, Eigen::Dynamic, 1>
str2Mat(std::string str){
263 return Eigen::Map<Eigen::Matrix<char,Eigen::Dynamic,1> >((
char*)str.c_str(), str.size()).cast<TYPE>();
270 template<
typename TYPE>
273 std::copy(str.begin(), str.end(), back_inserter(vec));
Eigen::Matrix< TYPE, Eigen::Dynamic, 1 > str2Mat(char *str)
#define OCTAVE_OPENCV_TYPE_ERROR
Octave's octave_value_list class.
std::map< int, std::string > errors
This will contain a map between error numbers and descriptive std::strings for the errors...
int setGlobalVariable(const std::string &name, const Eigen::DenseBase< Derived > &var)
Eigen::Matrix< TYPE, Eigen::Dynamic, 1 > str2Mat(std::string str)
#define OCTAVE_INCONSISTENT_COL_CNT_ERROR
octave_value_list * input
The inputs to pass to the octave .m file.
virtual ~OctaveDebug()
Destructor.
#define OCTAVE_NOBASE_ERROR
vector< TYPE > str2Vec(std::string str)