Ask Your Question

joeish80829's profile - activity

2017-08-03 12:19:38 -0600 received badge  Notable Question (source)
2016-04-18 10:41:40 -0600 received badge  Popular Question (source)
2016-02-25 11:26:01 -0600 received badge  Good Question (source)
2014-11-08 11:13:49 -0600 received badge  Taxonomist
2014-07-05 20:03:09 -0600 asked a question Getting errors writing C wrapper for a FileStorage operator?

I'm trying to write a C wrapper for this code:

FileStorage fs2("keypoint1.yml", FileStorage::READ); 
FileNode kptFileNode = fs2["keypoint"];

here is my attempt, and the error, if someone can show me what I'm doing wrong I would appreciate it.

FileNode* cv_FileNode_assignVal(FileStorage* fs, String* nodename) {
FileNode* fn = new FileNode;
*fn = *fs[*nodename];
return fn;
}

ERROR:

extra_functions.cpp: In function ‘cv::FileNode* cv_FileNode_assignVal
    (cv::FileStorage*, cv::String*)’:
extra_functions.cpp:135:14: error: no match for ‘operator[]’ 
    (operand types are ‘cv::FileStorage*’ and ‘cv::String’)
*fn = *fs[*nodename];
^
extra_functions.cpp:136:13: error: invalid user-defined conversion from ‘cv::FileNode’ 
    to ‘cv::FileNode*’ [-fpermissive]
return *fn;
^
In file included from /usr/local/include/opencv2/core.hpp:58:0,
from /usr/local/include/opencv2/opencv.hpp:46,
from /usr/local/include/opencv2/c/opencv_generated.hpp:3,
from /usr/local/include/opencv2/c/excluded_functions.hpp:19,
from extra_functions.cpp:18:
/usr/local/include/opencv2/core/persistence.hpp:857:8: note: candidate is: 
     cv::FileNode::operator int() const <near match>
inline FileNode::operator int() const { int value; read(*this, value, 0); return value; }
^
/usr/local/include/opencv2/core/persistence.hpp:857:8: note: no known conversion    
    for implicit ‘this’ parameter from ‘int’ to ‘cv::FileNode*’

here is the whole code the above snippet came from:

int main()
{
  double d = 10.0;
  cout << "omalley" <<  FileStorage::WRITE;
  Mat img = imread("/d1");
  BRISK detector;
vector<KeyPoint> keypoints;
detector.detect( img, keypoints );

FileStorage fs("/home/w/keypoints.yml", FileStorage::WRITE);
 write(fs , "keypoint",keypoints);
fs.release();
 int a[] ={1,2,3,4,5,6,7,8,9} ;
 Mat a = Mat(3,3,CV_);
  cout << a;
vector<KeyPoint> newKeypoints;
FileStorage fs2("keypoint1.yml", FileStorage::READ);
FileNode kptFileNode = fs2["keypoint"];
read(kptFileNode, newKeypoints);
fs2.release();
}

edit:

found the answer:

FileNode * cv_FileNode_assignVal(FileStorage * fs, string * nodename) {

    return new cv::FileNode(fs->operator[](*nodename));

}

2014-07-04 15:19:29 -0600 asked a question Getting error making a macro for the OpenCV Vec class.

I'm making macros for the OpenCV Vec class to convert them to C , and being new to C++ macros occurred an error, here they are. can someone help me figure ot the error. I posted the hpp/cpp contents and the error.

My HPP

#define ADD_VEC_FUNC_HEADERS_0(t) \ Vec2##t * cv_create_Vec2##t_0 (); \

extern "C" {

ADD_VEC_FUNC_HEADER_0(b);
ADD_VEC_FUNC_HEADER_0(d);}


    My CPP

#define ADD_VEC_FUNC_IMPL_0(t) \
    Vec2##t * cv_create_Vec2##t_0 () { \
        return new Vec2##t ();\
    } \


extern "C" {

ADD_VEC_FUNC_IMPL_0(b);
ADD_VEC_FUNC_IMPL_0(d);}



    ERROR:
 excluded_functions.cpp: In function ‘cv::Vec2d* cv_create_Vec2t_0()’:
excluded_functions.cpp:21:36: error: declaration of C function ‘cv::Vec2d* 
   cv_create_Vec2t_0()’ conflicts with
     Vec2##t * cv_create_Vec2##t_0 () { \
                                    ^
excluded_functions.cpp:68:1: note: in expansion of macro ‘ADD_VEC_FUNC_IMPL_0’
 ADD_VEC_FUNC_IMPL_0(d);
 ^
excluded_functions.cpp:21:15: error: previous declaration ‘cv::Vec2b* cv_create_Vec2t_0()’ here
     Vec2##t * cv_create_Vec2##t_0 () { \
               ^
excluded_functions.cpp:67:1: note: in expansion of macro ‘ADD_VEC_FUNC_IMPL_0’
 ADD_VEC_FUNC_IMPL_0(b);
 ^
mv: cannot stat ‘/home/w/Documents/opencv_contrib/modules/c/src/excluded_functions.so’: No such file or directory
2014-06-20 18:04:14 -0600 asked a question In the RNG documentation there appears to be an error...

At this link:

http://docs.opencv.org/trunk/modules/core/doc/operations_on_arrays.html?highlight=rng#RNG::RNG()

it says:

"These are the RNG constructors. The first form sets the state to some pre-defined value, equal to 2**32-1 in the current implementation. The second form sets the state to the specified value. If you passed state=0 , the constructor uses the above default value instead to avoid the singular random number sequence, consisting of all zeros."

what is this statement, 2**32-1, referring to? Should it be 2*32-1, or does ** have some signigicance in c++.

2014-05-30 18:46:00 -0600 commented answer Is there any official IRC for OpenCV?

+1 it would help alot:)

2014-05-26 17:55:19 -0600 asked a question Trying to understand Mat::dot and 2d matrices, in OpenCV

Here is my code:

  uchar a[2][4] = {1,2,3,4,5,6,7,8};
  Mat b = Mat(2,4, 0, a);

  uchar c[2][4] = {1,2,3,4,5,6,7,8};
  Mat d = Mat(2,4, 0, c);

  cout<< b.dot(d);

The output is 204. Can someone show me presicly which elements have the dot product computed, and when. I didn't understand when the Documentation said "If the matrices are not single-column or single-row vectors, the top-to-bottom left-to-right scan ordering is used to treat them as 1D vectors."

2014-05-26 11:11:03 -0600 asked a question How do I update this Bytefish Neural Network to do something more interesting

I'm learning Neural Networks from this bytefish machine learning guide and code. I understand it well but I would like to update the code at the previous link to use image pixel data instead of random values as the input data. In this section of the aforementioned code:

cv::randu(trainingData,0,1);
cv::randu(testData,0,1);

the training and test matrices are filled with random data. Then label data is added to the classes matrices here:

cv::Mat trainingClasses = labelData(trainingData, eq);
cv::Mat testClasses = labelData(testData, eq);

using this function:

        // label data with equation
        cv::Mat labelData(cv::Mat points, int equation) {
          cv::Mat labels(points.rows, 1, CV_32FC1);
          for(int i = 0; i < points.rows; i++) {
            float x = points.at<float>(i,0);
            float y = points.at<float>(i,1);
            labels.at<float>(i, 0) = f(x, y, equation); 

   // the f() function used above
  //has a case statement with 5 
  //functions in it eg on of the equations is:

  //case 0:
  //return y > sin(x*10) ? -1 : 1;
  //break;
          }

          return labels;
        }

Then points are plotted in a window here:

plot_binary(trainingData, trainingClasses, "Training Data");
plot_binary(testData, testClasses, "Test Data");

with this function:

    ;; Plot Data and Class function
    void plot_binary(cv::Mat& data, cv::Mat& classes, string name) {
      cv::Mat plot(size, size, CV_8UC3);
      plot.setTo(cv::Scalar(255.0,255.0,255.0));
      for(int i = 0; i < data.rows; i++) {

        float x = data.at<float>(i,0) * size;
        float y = data.at<float>(i,1) * size;
        if(classes.at<float>(i, 0) > 0) {
          cv::circle(plot, Point(x,y), 2, CV_RGB(255,0,0),1);
        } else {
          cv::circle(plot, Point(x,y), 2, CV_RGB(0,255,0),1);
        }
      }
      imshow(name, plot);
    }

The plotted points, as I understand it, represent the input data multiplied by the equations in the f() function and is used by the predict functions to predict which point to plot in the mlp, knn, svm etc. functions. How do I update what is going on here to do something cooler. Something with Image pixel data would be good, but help on doing anything different than this would be appreciated. Even showing me how to do a simple XOR with this code would be awesome. I can fill the trainingData and testData matrices with random 0's and 1's but not exactly sure what to do after that.

2014-05-24 23:30:23 -0600 commented question Low accurracy from this CvANN_MLP in ByteFish Machine Learning Guide

@berak Thanks for the info, still trying to learn linear algebra so i can learn the coursera course. You know, all those equations.

2014-05-23 17:01:49 -0600 asked a question C wrapper for setTo gets error: checkScalar(value, type(), _value.kind(), _InputArray::MAT ) in function setTo

I'm getting weird results with C binding for setTo

        extern "C" {

        Mat* cv_Mat_setTo(Mat* self, Scalar* value) {
            Mat* m = new Mat;
            *m = *value;
            return new Mat(self->setTo(*m));
        }
        }



        my .hpp:

        extern "C" {


        Mat* cv_Mat_setTo(Mat*self, Scalar* value);

        }

It compiles fine.

This is the code I'm referring to. I'm just tring to use the C version instead of the C++.

    cv::Mat plot(200, 200, CV_8UC3);
    plot.setTo(cv::Scalar(255.0,255.0,255.0));

and this is how I'm using it:

      cv::Mat plot(200, 200, CV_8UC3);
      Scalar s = cv::Scalar(255.0,255.0,255.0);
      cv_Mat_setTo(&plot,&s);

any ideas on why it's doing this?

2014-05-23 14:57:42 -0600 commented question Low accurracy from this CvANN_MLP in ByteFish Machine Learning Guide

@berak when you say " the mlp there is quite restricted." you mean the NN classes in OpenCV or in the snippet I posted

2014-05-23 11:37:16 -0600 commented question Low accurracy from this CvANN_MLP in ByteFish Machine Learning Guide

@berak I've seen Neural Nets used in Face recognition successfully and this seems like a lesser issue than Face Reg. Is there any way to improve the NN's on this program or is it a limit of NN's in general that they can't do this with over 90% accuracy or is it a Limit of OpenCV NN's

2014-05-22 19:44:41 -0600 asked a question Low accurracy from this CvANN_MLP in ByteFish Machine Learning Guide

I got the code from this link under the top answer. I whittled it down to what is below. In the pdf the code's author wrote he was getting over 90% accuracy. You can see it in this pdf on page 11. I was wondering If someone can tell me how to improve the accuracy of this program to get the over 90% accuracy the author was getting.

            #include <iostream>
            #include <math.h>
            #include <string>
            #include "cv.h"
            #include "ml.h"
            #include "highgui.h"
            #include "opencv2/imgproc.hpp"
            #include "opencv2/highgui.hpp"
            #include "opencv2/core.hpp"
            #include <iostream>
            #include <stdlib.h>

            using namespace std;
            using namespace cv;

            bool plotSupportVectors=true;
            int numTrainingPoints=200;
            int numTestPoints=2000;
            int size=200;
            int eq=0;

            // accuracy
            float evaluate(cv::Mat& predicted, cv::Mat& actual) {
            assert(predicted.rows == actual.rows);
            int t = 0;
            int f = 0;
            for(int i = 0; i < actual.rows; i++) {
            float p = predicted.at<float>(i,0);
            float a = actual.at<float>(i,0);
            if((p >= 0.0 && a >= 0.0) || (p <= 0.0 && a <= 0.0)) {
            t++;
            } else {
            f++;
            }
            }
            return (t * 1.0) / (t + f);
            }

            // plot data and class
            void plot_binary(cv::Mat& data, cv::Mat& classes, string name) {
            cv::Mat plot(size, size, CV_8UC3);
            plot.setTo(cv::Scalar(255.0,255.0,255.0));
            for(int i = 0; i < data.rows; i++) {

            float x = data.at<float>(i,0) * size;
            float y = data.at<float>(i,1) * size;

            if(classes.at<float>(i, 0) > 0) {
            cv::circle(plot, Point(x,y), 2, CV_RGB(255,0,0),1);
            } else {
            cv::circle(plot, Point(x,y), 2, CV_RGB(0,255,0),1);
            }
            }
            imshow(name, plot);
            }

            // function to learn
            int f(float x, float y, int equation) {
            switch(equation) {
            case 0:
            return y > sin(x*10) ? -1 : 1;
            break;
            case 1:
            return y > cos(x * 10) ? -1 : 1;
            break;
            case 2:
            return y > 2*x ? -1 : 1;
            break;
            case 3:
            return y > tan(x*10) ? -1 : 1;
            break;
            default:
            return y > cos(x*10) ? -1 : 1;
            }
            }

            // label data with equation
            cv::Mat labelData(cv::Mat points, int equation) {
            cv::Mat labels(points.rows, 1, CV_32FC1);
            for(int i = 0; i < points.rows; i++) {
            float x = points.at<float>(i,0);
            float y = points.at<float>(i,1);
            labels.at<float>(i, 0) = f(x, y, equation);
            }
            return labels;
            }


            void mlp(cv::Mat& trainingData, cv::Mat& trainingClasses, cv::Mat& testData, cv::Mat& testClasses) {

            cv::Mat layers = cv::Mat(4, 1, CV_32SC1);

            layers.row(0) = cv::Scalar(2);
            layers.row(1) = cv::Scalar(10);
            layers.row(2) = cv::Scalar(15);
            layers.row(3) = cv::Scalar(1);

            CvANN_MLP mlp;
            CvANN_MLP_TrainParams params;
            CvTermCriteria criteria;
            criteria.max_iter = 100;
            criteria.epsilon = 0.00001f;
            criteria.type = CV_TERMCRIT_ITER | CV_TERMCRIT_EPS;
            params.train_method = CvANN_MLP_TrainParams::BACKPROP;
            params.bp_dw_scale = 0.05f;
            params.bp_moment_scale = 0.05f;
            params.term_crit = criteria;

            mlp.create(layers);

            // train
            mlp.train(trainingData, trainingClasses, cv::Mat(), cv::Mat(), params);

            cv::Mat response(1, 1, CV_32FC1);
            cv::Mat predicted(testClasses.rows, 1, CV_32F);
            for(int i = 0; i < testData.rows; i ...
(more)
2014-05-22 17:36:55 -0600 commented question Weird results with seamlessCloning sample MIXED_CLONE section with provided images

@berak Thanks: )

2014-05-22 13:19:11 -0600 asked a question Weird results with seamlessCloning sample MIXED_CLONE section with provided images

Below is the code I'm referring to it is part of the OpenCV cloning example here and I'm getting bad reults with these test images. I think I got the correct test images that were designed for this code sample. Here is the result I'm getting. Can someone help me figure out why the result has a blur over half of it. I changed the Point position but it didn't help. I'm using the MIXED_CLONE(2) version of seamlessClone, If I try the NORMAL_CLONE(1) version I get this as a result, still not good because of the blur. I'd like to figure out how to master the MIXED_CLONE version and get a good result from it e.g perfect writing on a brick wall.

          else if(num == 2)
            {
                string folder = "cloning/Mixed_Cloning/";
                string original_path1 = folder + "source1.png";
                string original_path2 = folder + "destination1.png";
                string original_path3 = folder + "mask.png";

                Mat source = imread(original_path1, IMREAD_COLOR);
                Mat destination = imread(original_path2, IMREAD_COLOR);
                Mat mask = imread(original_path3, IMREAD_COLOR);

                if(source.empty())
                {
                    cout << "Could not load source image " << original_path1 << endl;
                    exit(0);
                }
                if(destination.empty())
                {
                    cout << "Could not load destination image " << original_path2 << endl;
                    exit(0);
                }
                if(mask.empty())
                {
                    cout << "Could not load mask image " << original_path3 << endl;
                    exit(0);
                }

                Mat result;
                Point p;
                p.x = destination.size().width/2;
                p.y = destination.size().height/2;

                seamlessClone(source, destination, mask, p, result, 2);

                imshow("Output",result);
                imwrite(folder + "cloned.png", result);
            }
2014-05-22 03:42:19 -0600 commented question Hook up a lage amount of GPU's to create a Supercomputer...is it possible?

It does concern setting up your environment for CUDA module in an AWESOME way. Power loving users like myself can really benefit from this if a cool answer is supplied. Can I reword the ? maybe to fit site guidelines better. I'd like to be able to run a ton of cuda::detectMultiScales on a 1280x1024 video feed, and the matchTemplate/norm combination could use speeding up so the more the merrier if you get my meaning.

2014-05-21 23:36:20 -0600 asked a question Hook up a lage amount of GPU's to create a Supercomputer...is it possible?

My goal is to hook up a lage amount of Nvidia GPU's into some sort of Supercomputer to drastically increase the power I get from the CUDA module. I would like to start with a 1 TFLOP+ Nvidia CUDA enabled GPU for about 150 dollars and then buy more of the same type of video card every month and hook them together one by one to eventually create a supercomputer. I like the idea of increasing my computing power a TFLOP at a time and I would like no limit to how many times I can do this. I know I can get a MB with 4 pci-e slots but some sort of inexpensive pci-e hubs I can interlink or detailed(and inexpensive) DIY project to make this happen would be better. Is there a better/cheaper way to do what I am trying to do or can someone give advice on how to make this happen. Thank you.

2014-05-13 19:29:07 -0600 asked a question Getting EXECINFO_LIB-NOTFOUND trying to install VTK on Ubunt 14.04, so I can install VIZ module

II followed the instructions at this page to build I doenloaded the source and the data from here http://www.vtk.org/VTK/resources/software.html

The VTK-6.1.0.zip for source and the VTKData-6.1.0.zip for data

I extracted source to /home/w/Documents/VTK-6.1.0 and data to /home/w/Documents/VTK-6.1.0/ExternalData

I cd into source directory like this cd ~/Documents/VTK-6.1.0$

and ran ccmake .

then I hit "c" for configure and got

BUILD_DOCUMENTATION OFF
BUILD_EXAMPLES OFF
BUILD_SHARED_LIBS ON
BUILD_TESTING OFF
CMAKE_BUILD_TYPE Debug
CMAKE_INSTALL_PREFIX /usr/local
EXECINFO_LIB EXECINFO_LIB-NOTFOUND
VTK_EXTRA_COMPILER_WARNINGS OFF
VTK_Group_Imaging OFF
VTK_Group_MPI OFF
VTK_Group_Qt OFF
VTK_Group_Rendering ON
VTK_Group_StandAlone ON
VTK_Group_Tk OFF

I think that is the reason I can't build OpenCV with Viz...any help is appreciated

2013-12-25 07:41:58 -0600 asked a question How do I wrap the OpenCV InputArray class method getMat in C?

Here is my attempt:

my .cpp

#include "opencv_generated.hpp"
using namespace cv;
using namespace std;
using namespace flann;
using namespace cvflann;
extern "C" {

Mat* cv_InputArray_getMat(Mat* self) {
    return new Mat(self->getMat);
}
}

my .hpp

#include <opencv2/opencv.hpp>
#include <vector>
#ifndef __OPENCV_GENERATED_HPP
#define __OPENCV_GENERATED_HPP
using namespace cv;
using namespace std;
using namespace flann;
using namespace cvflann;
extern "C" {
Mat* cv_InputArray_getMat(Mat* self);

}

I compile it with this

 g++ -Wall -shared -fPIC -o libcl-opencv-glue.so cl-opencv-glue.cpp

I get this error:

root@w-VirtualBox:/home/w/opencv-master/glue# 
g++ -Wall -shared -fPIC -o libopencv-glue.so opencv-glue.cpp
opencv-glue.cpp: In function ‘cv::Mat* cv_InputArray_getMat(cv::Mat*)’:
opencv-glue.cpp:9:30: error: ‘class cv::Mat’ has no member named ‘getMat’
         return new Mat(self->getMat);
                              ^
opencv-glue.cpp:10:5: warning: control reaches end of non-void function 
[-Wreturn-type]
     }
     ^

Normally when i wrap c++ opencv functions in c i use a opaque Mat* pointer to stand in for the InputArray function parameters im wrapping. I tried substituting a opaque InputArray* pointer for the Mat* in every different combination but got longer error message list the more InputArray* substitutions I made.....Any advice is much valued

Thank you.

2013-11-20 20:36:50 -0600 asked a question Can I wrap these OpenCV C++ CvStatModel Methods in C successfully?

Kiril on of the main OpenCV developers is in talks with Arjun Comar to include his Autogenerated C wrappers for the C++ OpenCV functions in the next release of OpenCV 3.0.0. Arjun Comar has a buildable fork of 3.0.0 here https://github.com/arjuncomar/opencv that creates a file in the "build" folder called opencv_generated.cpp when you build his release. in that file are 500 or so C wrappers for C++ functions...but I noticed only two of the CvStatModel Class methods from the Machine Learning part of opencv are included in that file....load and save....I pasted the contents on past bucket here:http://pastebucket.com/22680. for reference but below are the 2 CvStatModel wrappers from opencv_generated.cpp

void cv_CvStatModel_save2(CvStatModel* self, c_string filename, c_string name) {
    self->save(filename, name);
}    

void cv_CvStatModel_load2(CvStatModel* self, c_string filename, c_string name) {
    self->load(filename, name);
}

i was hoping someone could take a look at the above 2 wrappers and compare them with the 10 or so methods (CvStatModel) here in opencv documentation http://docs.opencv.org/modules/ml/doc/statistical_models.html#cvstatmodel

and tell me why the other 8 or so CvStatModel methods werent included in opencv_generated.cpp....was it my build...too hard to wrap i/e

a method from the prev documentation link has trailing periods in its parameter declarations i/e below

float CvStatModel::predict(const Mat& sample, ...) const 
// what do the trailing dots mean....Is that what it predicts?

so that seems hard to wrap.....If some one can give me a clue as to whether or not its possible to wrap all the CvStatModel Methods in c before I get started that could save time in the long run and help me learn this soon to be added important part of OpenCV...thx in advance to any takers=).....and an addendum extra question would learning neural networks and applying them to opencv code be more advantageous than learning the Machine Learning part of OpenCV....like is the Machine Learning part of OpenCV so, excuse my french=), badass, that it would trump any neural network.

2013-11-20 20:32:57 -0600 asked a question Why do some of the functions in the OpenCV C++ interface have struct declarations in them?

new to c++ interface i saw these two similiar/same functions on this page

http://docs.opencv.org/modules/ml/doc/support_vector_machines.html?highlight=cvsvm#bool%20CvSVM::train%28const%20CvMat%20trainData,%20const%20CvMat%20responses,%20const%20CvMat%20varIdx,%20const%20CvMat%20sampleIdx,%20CvSVMParams%20params%29

under the CvSVM::train heading

C++:

bool CvSVM::train(const Mat& trainData, const Mat& responses, const Mat& varIdx=Mat(), const Mat& sampleIdx=Mat(), CvSVMParams params=CvSVMParams() )

C++:

 bool CvSVM::train(const CvMat* trainData, const CvMat* responses,  const CvMat* varIdx=0, const CvMat* sampleIdx=0, CvSVMParams params=CvSVMParams() )

they are the same but one uses the 'const Mat& ' and the other CvMat* Im writing a wrapper for opencv and I was wondering if, to make it complete would I need to include all the C structs ...or can C++ use the C structs or is CvMat and other structs both C and C++...I was under the impression that C++ used classes and C structs in opencv but if someone could shed light on this I would appreciate that....Also in the opencv cpp samples folder letter_recog.cpp there is alot of CvMat* in it....is that code just old and hasnt been updated yet. Opencv doc. says CvMat is deprecated so of the two above functions I guess i would just use the const Mat& one right and assume OpenCv documentation though posted on website is still maybe a bit "in proccess" . Any light shed on these queries is much appreciated

2013-11-14 19:01:50 -0600 asked a question How do i create a .so file that contains only C++ code wrapped in C code - OpenCV related

On Ubuntu Saucy 64bit in termial using g++ Im attempting to wrap OpenCV in a language without a strong C++ ffi so im attempting to use C++ to C wrappers to aid in doing this... Here is the small peice of the files Im trying to convert just to get a feel for it(opencv_generated.hpp and opencv_generated.cpp at this link https://github.com/arjuncomar/opencv-raw)

opencv_generated hpp:

#include "cxcore.h"
#include "cv.h"
#include <opencv2/core/core.hpp>

#include <opencv2/opencv.hpp>
#include <vector>
#ifndef __OPENCV_GENERATED_HPP
#define __OPENCV_GENERATED_HPP
using namespace cv;
using namespace std;
using namespace flann;
using namespace cvflann;
extern "C" {
Mat* cv_imread(String* filename, int flags);
void cv_imshow(String* winname, Mat* mat);
bool cv_imwrite(String* filename, Mat* img, vector_int* params);}

opencv_generated.cpp:

#include "opencv_generated.hpp"
using namespace cv;
using namespace std;
using namespace flann;
using namespace cvflann;
extern "C" {

Mat* cv_imread(String* filename, int flags) {
return new Mat(cv::imread(*filename, flags));
}
void cv_imshow(String* winname, Mat* mat) {
    cv::imshow(*winname, *mat);
}
bool cv_imwrite(String* filename, Mat* img, vector_int* params) {
    return cv::imwrite(*filename, *img, *params);
}}

Am new to C wrappers for C++ and am trying to compile with

g++ -Wall -dynamiclib -I/home/w/test/opencv_generated.hpp -I/home/w/test/opencv_generated.cpp -o test.so

im getting error:

g++: fatal error: no input files

...im in the directory my opencv_generated.cpp and opencv_generated.hpp files are in so what am i doing wrong??....any help == greatly valued=)

2013-11-14 18:03:58 -0600 asked a question How to compile the Raw Haskell bindings to OpenCV aka GitHub member arjuncomar's OpenCV-Raw repo

Arjuncomar states in the OpenCV-Raw readme.md at this link https://github.com/arjuncomar/opencv-raw/blob/master/README.md "Compilation / Installation

Compiling this package might be a little tricky at the moment since I've only had the chance to test it on my machine so far. First, you need to generate C wrappers for the version of OpenCV on your machine -- this repo holds the wrappers for OpenCV 3.0 (HEAD) only. You can generate these wrappers (and the corresponding Haskell bindings) via:

./setup.sh <path to opencv headers>

e.g.

./setup.sh /usr/local/include"

I ran './setup.sh /usr/local/include', in the root directory of Opencv-Raw, btw I have OpenCV 2.4.7 installed on Ubuntu Saucy 64-bit and i get this error

   Traceback (most recent call last):
   File "cbits/genhsc.py", line 161, in <module>
   cgen.gen(header_dir, headers, dstdir)
   File "/home/w/Documents/opencv-raw-master/cbits/genc.py", line 367, in gen
   self.readHeaders(header_dir, srcfiles)
   File "/home/w/Documents/opencv-raw-master/cbits/genc.py", line 350, in readHeaders
   decls = parser.parse(header_dir + hdr)
   File "/home/w/Documents/opencv-raw-master/cbits/hdr_parser.py",
   line 732, in      parse f = open(hname, "rt")
   IOError: [Errno 2] No such file or directory: '/usr/local/include/opencv2/core.hpp'

Arjuncomar states "this repo holds the wrappers for OpenCV 3.0 (HEAD) only." so i tried to find an OpenCV 3.0 download but no luck and I've never seen a core.hpp file in /usr/local/include so dont really understand error. Im trying to incoroporate the code arjuncomar wrote in his haskell bindings into my own OpenCV wrapper and I felt this might be a good first step but if I can just make a make file for this code i/e

the cpp file

void cv_imshow(String* winname, Mat* mat) {
    cv::imshow(*winname, *mat);
}

the hpp file

 void cv_imshow(String* winname, Mat* mat);

and expect it to be a perfect C wrapper for C++ OpenCV code pls let me know...and if posible a link regarding how to make such a make file posted here would aid greatly....Im used to C but new to C++/ C++ MakeFiles and would rather do this perfect on my first try so I can output volume more quickly without worrying about making an error...

....Any help is appreciated...A good day=) to you All...

2013-11-14 16:10:29 -0600 asked a question Downloading/Finding the Autogenerated Haskell/OpenCV C to C++ wrappers on GitHub

Id like to contribute to the OpenCV pull by arjuncomar described at this link https://github.com/Itseez/opencv/pull/1600 by first finding the latest updates to his repository and then downloading them....arjuncomar talks about his autogenerated C wrappers for the C++ Opencv interface at that link by saying i/e

"The automatically generated portions of these wrappers are provided in opencv_generated.hpp and opencv_generated.cpp for headers and source respectively. Some major classes are not parsed correctly by hdr_parser.py so these types are manually wrapped and show up in explicitly named headers and source files (e.g. mat.hpp/mat.cpp). A header called opencv.h includes both the automatically generated header and the manual headers and is located at include/opencv2/opencv.h. The other headers are installed to include/opencv2/c/"

so i searched online for the file opencv_generated.cpp he talked about above to find it and did at this link https://github.com/arjuncomar/opencv-raw/tree/master/cbits

but at goes on to talk about his "(now-defunct) opencv-raw repository" in the text at the first link i provided.. so im wondering if this is the latest and greatest version of his pull or if someone could help me find a better one ....Id like to be sure i have the right one before i start editing my contribution....Any help is greatly valued...Cheers!

2013-11-10 03:35:15 -0600 asked a question Representing images as graphs based on pixels using OpenCV's CvGraph

Need to use c for a project and i saw this screenshot in a pdf which gave me the idea http://i983.photobucket.com/albums/ae313/edmoney777/Screenshotfrom2013-11-10015540_zps3f09b5aa.png

It say's you can treat each pixel of an image as a graph node(or vertex i guess) so i was wondering how
i would do this using OpenCV and the CvGraph set of functions. Im trying to do this to learn about and how to use graphs in computer vision and i think this would be a good starting point.

I know i can add a vetex to a graph with

int cvGraphAddVtx(CvGraph* graph, const CvGraphVtx* vtx=NULL, CvGraphVtx** inserted_vtx=NULL )

and the documentation says for the above functions vtx parameter

"Optional input argument used to initialize the added vertex (only user-defined fields beyond sizeof(CvGraphVtx) are copied)"

is this how i would represent a pixel as a graph vertex or am i barking up the wrong tree...I would love to learn more about graphs so if someone could help me by maybe posting code, links, or good ol' fashioned advice...Id be grateful=)

2013-11-10 01:52:27 -0600 commented question Could use help editing this C OpenCV code so it will run ....uses CvGraph

@berak thx for the info that helped me get started... any way you can post a piece of your old code that uses Cvgraph...maybe something thats easy to grasp for a CvGraph noob:)

2013-11-09 21:12:21 -0600 asked a question How do variable decclarations pertaining to struct members work in OpenCV C interface

This is the code it uses imageData to set all the pixels in FRAME to red... i could use help understand it though so i can get a better view of opencv and c in general Note : need to use the c interface for project im working on

In the code below it seems FRAME->imageData is added to y multiplied by FRAME->WidthsTEP inthe top for loop and then PTR is altered in the bottom for loop ie ' ptr[3*x+2] = 255;' and that changes the image FRAME to all red but imageData is set to PTR not the other way around so how can changing PTR even effect FRAME->imageData. because when i do this

int a=1; int b=a; b=4;

cout << "a = " << endl << " " << a << endl << endl; // A ends up equaling 1

so it doesnt seem this should happen

#include "cv.h"  
#include "highgui.h"  
using namespace std;

int main (int argc, const char * argv[]) {

IplImage *frame = cvCreateImage(cvSize(41, 41), IPL_DEPTH_8U, 3);

for( int y=0; y<frame->height; y++ ) { 
    uchar* ptr = (uchar*) ( frame->imageData + y * frame->widthStep );

cout << "M = " << endl << " " << frame->imageData+ frame->widthStep << endl << endl; for( int x=0; x<frame->width; x++ ) { ptr[3*x+2] = 255; //Set red to max (BGR format) } }

cvNamedWindow("window", CV_WINDOW_AUTOSIZE);
cvShowImage("window", frame);
cvWaitKey(0);
cvReleaseImage(&frame);
cvDestroyWindow("window");
return 0;

}

2013-11-09 09:54:34 -0600 commented question Could use help editing this C OpenCV code so it will run ....uses CvGraph

@berak what do you mean by good luck porting that into c ...isnt what you provided the correct translation of the new operator line in c...thx btw 4 that =) ....also can you help me with the Edges_addr part of my ?

2013-11-08 19:58:35 -0600 asked a question Could use help editing this C OpenCV code so it will run ....uses CvGraph

I could use help getting the code here to run http://blog.csdn.net/honpey/article/details/8795228 directly underneath the three typdef structs and the and the graph picture... Im trying to run it to learn about CvGraph struct and related functions. when i run it i get error:

error: ‘Edges_addr’ was not declared in this scope cvGraphAddEdge(graph,edge_start[i],edge_end[i],&Edges[i],&Edges_addr[i]);

I dont want to edit it myself because i wouldnt know how to edit but still preserve the authors intention ....so i could use help just declaring edges_addr correctly and understanding what the new operator is doing on this line(line 22)

CvGraphEdge *Edges = new CvGraphEdge[EdgeNum];

I know CvGraphEdge is a struct so is it essentially doing this :

 (CvGraphEdge)malloc(sizeof(CvGraphEdge*EdgeNum)) ?

any help on this is greatly valued=)

Cheers!

ps need to use C for a project is why =)

2013-11-02 23:16:47 -0600 asked a question Help writing a glue function to house a c OpenCV preprocessor macro?

Im writing a glue function to house this macro(CV_GET_SEQ_ELEM) because im building an opencv wrapper

here it is defined

#define  CV_SEQ_ELEM( seq, elem_type, index )                    \
/* assert gives some guarantee that <seq> parameter is valid */  \
(   assert(sizeof((seq)->first[0]) == sizeof(CvSeqBlock) &&      \
    (seq)->elem_size == sizeof(elem_type)),                      \
    (elem_type*)((seq)->first && (unsigned)index <               \
    (unsigned)((seq)->first->count) ?                            \
    (seq)->first->data + (index) * sizeof(elem_type) :           \
    cvGetSeqElem( (CvSeq*)(seq), (index) )))
#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) )

i know how it works ie replace

 CV_SEQ_ELEM(mytype,int,1)

 with

 ( assert(sizeof((mytype)->first[0]) == sizeof(CvSeqBlock) &&
   (mytype)->elem_size == sizeof(int)), (int*)((mytype)->first &&
 (unsigned)1 < (unsigned)((mytype)->first->count) ? (mytype)->first->data +
 (1) * sizeof(int) : cvGetSeqElem( (CvSeq*)(mytype), (1) )))

but what do i cast the return value to for CV_GET_SEQ_ELEM when I write my glue function because the documentation for it says...."The macro checks first whether the desired element belongs to the first block of the sequence and returns it if it does; otherwise the macro calls the main function GetSeqElem" the documentation for cvGetSeqElem says "Returns a pointer to a sequence element according to its index." so the macro seems to have ability to return 2 separate values but the function cvGetseqElem does not....cvGetSeqElems return is usually cast to other types when its used though....I was hoping you could help me figure out how to cast its return and how to get by the parameters not being declared here i/e to int or double etc

  #define CV_GET_SEQ_ELEM( elem_type, seq, index ) 
      CV_SEQ_ELEM( (seq), elem_type, (index) )

I know what these variables are i/e elem_type is an int and seq is a CvSeq*, index is an int....but i have alot glue code to write for macros like this....so if i didnt know what the variables should be declared as ....what do i do.....this will help me master this part of writing my library(glue code for macros) if you could answer this for me... Cheers!=)

2013-10-30 07:17:16 -0600 commented answer How do I help OpenCV Developers autogenerate C wrappers for C++ code?

Thanks @Adi I really appreciate that

2013-10-30 03:52:24 -0600 received badge  Nice Question (source)
2013-10-30 01:31:08 -0600 received badge  Student (source)
2013-10-29 22:50:53 -0600 asked a question How do I help OpenCV Developers autogenerate C wrappers for C++ code?

at this link http://answers.opencv.org/question/17546/opencv-will-drop-c-api-support-soon/

a opencv developer said this:

"At the same time in the long term C API may return to the OpenCV, so it can be used from the C code (e.g. low-level or embedded programming). But the plan is to autogenerate C wrappers for C++ code, as we do for Java and Python. This way C API will be always up-to-date, since it is generated from the C++ headers automatically. But this is a long-term dream, not for OpenCV 3.0, and if you want to work on that, please let us know (http://opencv.org/contribute.html)."

I would like to know how I can help Autogenerate the wrappers...I can spend many hours a day 7 days a week on this . but It seems there is no email link on that page but i think I should talk to somebody...so I would have the information I need so i can make precise worthwhile contributions and never risk sending duplicate code....How would I go about doing this? If they would can send me projects to do I can get them done

2013-10-29 05:24:26 -0600 asked a question What does this mean in Opencv Documentation

Im trying to understand goodFeaturesToTrack and in the documention at this link:

http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=goodf#goodfeaturestotrack

it says "

Note

If the function is called with different values A and B of the parameter qualityLevel , and A > {B}, the vector of returned corners with qualityLevel=A will be the prefix of the output vector with qualityLevel=B . "

is A > {B} just a is greater than b or does it mean something else

2013-10-24 16:03:11 -0600 asked a question What is this in this OpenCV code for C, Is it a function or a struct declaration?

Here is what i'm talking about i got the code from here

 CvHistogram* hist;
 {
     int hist_size[] = { h_bins, s_bins };
     float h_ranges[] = { 0, 180 };
     float s_ranges[] = { 0, 255 };
     float* ranges[] = { h_ranges, s_ranges };
     hist = cvCreateHist( 2, hist_size, CV_HIST_ARRAY, ranges, 1 );
 }

After I saw it i researched and from the c struct wiki it doesnt appear to be anything like a struct because struct isnt mentioned any where and it doesn't appear to be a function because it has curly braces and and a semi-colon in the wrong place....still a little new to opencv....so could use advice...Cheers

2013-10-21 21:38:31 -0600 commented question Using ROI from camera feed as Template for cvMatchTemplate

@berak thanks for the help your ideas led me to the right answer

2013-10-21 15:16:23 -0600 commented question Using ROI from camera feed as Template for cvMatchTemplate

@berak I use the ROI in cvSetImageROI ....and i said in my post "I I took out the trackbars and windows to keep it short per guidelines ...." I took out the release images too to make the long code shorter can you help me get past that error

2013-10-21 14:50:55 -0600 asked a question Using ROI from camera feed as Template for cvMatchTemplate

This is code that im rewriting that i wrote successfully before.

its suppose to use a a roi from a webcam and match it with cvMatchTemplate against other webcam frames...I took out the trackbars and windows to keep it short per guidelines but in the original you could move the trackbars to select a section of the frame in the top left window and in the bottom left window you saw your template here is a picture of what it looked like:

http://i983.photobucket.com/albums/ae313/edmoney777/Screenshotfrom2013-10-21112021_zpsae11e3f0.png

Here is the error im getting I tried changing the depth of src to 32F with no luck...read the templmatch.cpp line 384 the error mssg gave me but no help there

OpenCV Error: Assertion failed (result.size() == cv::Size(std::abs (img.cols - templ.cols) + 1, std::abs(img.rows - templ.rows) + 1) && result.type() == CV_32F) in cvMatchTemplat

Im new to opencv and could use a little help debugging the code below

 #include <cv.h>
 #include <highgui.h>
 using namespace std;


 int main(){
   CvCapture* capture =0;       

   capture = cvCaptureFromCAM(0);
   if(!capture){
    printf("Capture failure\n");
    return -1;
 }

   IplImage* frame=0;
   double width=640.0;
   double height=480.0;
   cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width);
   cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height);

   while(true){

 frame = cvQueryFrame(capture);           
 if(!frame) break;

 frame=cvCloneImage(frame); 
 IplImage *src, *templ, *ftmp[6]; // ftmp will hold results
 int i;
 CvRect roi;
 int rectx = 0;
 int recty = 0;
 int rectwidth = frame->width /10;
 int rectheight = frame->height /10;
 IplImage* img = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3);

 // Read in the source image to be searched
 src = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3);

 roi=cvRect(rectx, recty, rectwidth, rectheight);

 img = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3);
 src = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3);
 cvCopy(frame, img);
 cvSetImageROI(frame, roi);

 cvShowImage( "b", img );
 cvReleaseImage(&img);
  // Allocate Output Images:
 int iwidth = src->width - frame->width + 1;
 int iheight = src->height - frame->height + 1;

 for(i = 0; i < 6; ++i){
   ftmp[i]= cvCreateImage( cvSize( iwidth, iheight ), 32, 1 );
 }

 // Do the matching of the template with the image
 for( i = 0; i < 6; ++i ){
   cvMatchTemplate( src, frame, ftmp[i], i );
   cvNormalize( ftmp[i], ftmp[i], 1, 0, CV_MINMAX );
 }       
 // DISPLAY

 cvReleaseImage(&src);                 
 cvResetImageROI(frame);
 cvReleaseImage(&frame);


 //Wait 50mS
 int c = cvWaitKey(10);
 //If 'ESC' is pressed, break the loop
 if((char)c==27 ) break;

}

 cvDestroyAllWindows() ;
 cvReleaseCapture(&capture);     

 return 0;

}

I am new to OpenCV and really don't know what to do with this error-message. Anyone an idea/pointer what to do? Your help is very appreciated! Cheers,

Edit: figured it out! here is some pretty neat code.....any ideas on how to improve it pls post back

  #include <cv.h>
  #include <highgui.h>
  using namespace std;


  int main(){
    CvCapture* capture =0;       

    capture = cvCaptureFromCAM(0);
    if(!capture){
      printf("Capture failure\n");
      return -1;
    }

    int rectx = 0;
    int recty = 0;
    int rectwidth = 64;
    int rectheight = 48;

    IplImage* frame=0;
    double width=640.0;
    double height=480.0;
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width);
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height);
    cvNamedWindow("a" , CV_WINDOW_NORMAL);     
    cvNamedWindow("b ...
(more)
2013-10-19 22:44:54 -0600 asked a question Using cvLoad I get Unspecified error (The node does not represent a user object (unknown type?)) error

0 down vote favorite

here is the full error message:

OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /home/abe/Documents/opencv-2.4.6.1/modules/core/src/persistence.cpp, line 4997

I saw on google that this might be a bug here

http://opencv-users.1802565.n2.nabble.com/face-detection-cvLoad-td4467872.html

here is how im running it

#include <cv.h>
#include <highgui.h>
using namespace std;

int main()
{


 cvLoad("/home/abe/Documents/opencv-2.4.6.1/data/haarcascades/haarcascade_frontalface_alt2.xml");

    return 0;
}

many programs load xml files with this function and this file is from opencv directory so i know its good I tried the workaround using cvErode in the above link but still got same error any help is appreciated

btw compile on ubuntu raring with this which works for every other program

g++ b.cpp -o b pkg-config --cflags --libs opencv