Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculating histogramm #6

Open
bitbay opened this issue Oct 21, 2012 · 2 comments
Open

calculating histogramm #6

bitbay opened this issue Oct 21, 2012 · 2 comments

Comments

@bitbay
Copy link
Contributor

bitbay commented Oct 21, 2012

My next try was to add a @Manual declaration to the legacy cv.mGet function, which is an INLINE declaration in opencv-src/modules/core/include/opencv2/core/types_c.h as:

CV_INLINE double cvmGet( const CvMat* mat, int row, int col )
{
int type;

type = CV_MAT_TYPE(mat->type);
assert( (unsigned)row < (unsigned)mat->rows &&
(unsigned)col < (unsigned)mat->cols );

if( type == CV_32FC1 )
return ((float_)(mat->data.ptr + (size_t)mat->step_row))[col];
else
{
assert( type == CV_64FC1 );
return ((double_)(mat->data.ptr + (size_t)mat->step_row))[col];
}
}

my try on the bea declaration to expose the method in opencv_manual.cpp:

v8::Handlev8::Value JOpenCV::mGet(const v8::Arguments& args) {
METHOD_BEGIN(1);
//float mGet(const Mat* mat, int row, int col)
//TODO: Enter code here
cv::Mat* mat = bea::Convertcv::Mat*::FromJS(args[0], 0);
int row = bea::Convert::FromJS(args[1], 1);
int col = bea::Convert::FromJS(args[2], 2);
THROW_IF_NOT(row > 0, "Invalid row value");
THROW_IF_NOT(col > 0, "Invalid col value");

// float or double?

float* ptr = (float_)(mat->data + (size_t)mat->step_row);
// i get negative values too -> obviously wrong pointer/bad value for color...
float result = ptr[col];
return bea::Convert::ToJS(result);
METHOD_END();
}

(as You can see i'm still no good at all in CPP / v8)

What values use this v8 port for storing colors? Floats, doubles, uchars?

@codeboost
Copy link
Owner

cvmGet seems to be an older C-Style interface to opencv.
If I'm not mistaken, you should use Mat::at to access individual elements of a matrix.

I'm currently working on calcHist and all the required dependencies, including the Mat::at() function and I should soon have an update ready.

@codeboost
Copy link
Owner

Just commited a new version of opencv-node, which includes cv.calcHist implementation and an example in the scripts directory. Let me know if that works for you

@codeboost codeboost reopened this Nov 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants