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

Populate a matrix manually #15

Open
claudebossy opened this issue Sep 24, 2013 · 2 comments
Open

Populate a matrix manually #15

claudebossy opened this issue Sep 24, 2013 · 2 comments

Comments

@claudebossy
Copy link

Hello,

I've tried to populate a matrix myself, for example have a matrix 3x3:
1 3 5
2 4 6
7 8 9

But I couldn't find a way to do it, in C++ we can use mat.at(0,0) = 1 for example, to change a value in the matrix.
Is it already possible to do it and I'm missing something or is it something not implemented?
Ideally doing something like:
var mat = new cv.Mat(3, 3, type, [1,3,5,2,4,6,7,8,9])
or
mat.at(i,j,value)

Also my goal was then to use cv::calibrateCamera, cv::solvePnP and cv::Rodrigues which are not implemented yet. So once I understand how to populate a matrix I can try to implement myself those new functions unless you can do it fast (I've already spent 1 and a half days trying to do it unsuccessfully...)

Thanks in advance.

@codeboost
Copy link
Owner

Mat::at() should work in Javascript as well. Are you getting an error ?

I have not worked on this in a long time and I cannot dedicate much time to it now, as there hasn't been too much interest in the project from the public at large.

But I can try and guide you on how to implement more extensions - it's fairly easy. I have used a generator to generate most of the functions, but I think it's ok to just implement them manually from now on, as there's not so much work to do.

To implement the constructor you want, check out opencvjs.cpp and look at how other constructors for cv.Mat work (JMat::__constructor methods), then you can write your own in a similar fashion.

@claudebossy
Copy link
Author

Yes I'm getting an error, I've tried for example:
var mat = new cv.Mat(3,3,cv.CV_64FC3);
mat.at(0,0) = 1;

And I get:
ReferenceError: Invalid left-hand side in assignment

I think I can manage to add new functions, at least I could try if I manage to at least populate a simple 3x3 matrix first =)

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