Opencv4nodejs: Missing functions and more

Created on 11 Mar 2018  路  9Comments  路  Source: justadudewhohacks/opencv4nodejs

Howdy. Any intent to add support for any of the missing cv features?

I'm sure there are more, these are just the ones I found from my usage:

Mat::push_back
merge
split - Moved to Mat::splitChannels ?
cartToPolar
polarToCart
resize - Seems to be comparable alternative under Mat::resize
cvtColor - Seems to be comparable alternative under Mat::cvtColor

Seems many root level cv:: functions were moved to classes. Not sure if it was preference or necessity, but makes translating existing cv code more difficult since opencv.org has all the docs. Suggestions?

Most helpful comment

cv::exp should be available. Will add cv::log and cv::goodFeaturesToTrack next time I find the time.

All 9 comments

Hi,

I will answer your second question first:

Yes indeed, the API slightly differs from the original opencv API, such that a signature like: cv.functionName(inputMat, outputMat, foo, bar) becomes: outputMat = inputMat.functionName(foo, bar). This is mainly a design decision I made initially, as some concepts do not translate well into the javascript world in my opinion (for example passing pointers to return values as arguments to a function calls)

Furthermore, this allows you to conveniently chain function calls. Instead of writing code like this:

cv.cvtColor(in, out1, ...)
cv.threshold(out1, out2, ...)
cv.blur(out2, result, ...)

You can chain operations:

const result = in.cvtColor(...).threshold(...).blur(...)

I agree, that this might make it inconvenient to convert existing OpenCV code from C++ or python to javascript, but by simply looking up the method signature in the docs it should be possible easily, in my opinion.

To the first question:

splitChannels (should of probably just called it split), resize and cvtColor are accessible from the Mat object, as you figured out already.

merge is equivalent to calling the constructor with new Mat([channel1, channel2, channel3]) (see Mat constructor: Mat : new Mat ( [ Mat ] channels ).

cartToPolar , polarToCart and push_back are apparently not implemented yet (as mentioned in the other issue, the package is not complete). INTER_LINEAR_EXACT is a flag I guess? Looks like the flag has just been added in one of the previously released OpenCV versions (probably 3.4.1) and needs to be added to the package.

Makes sense, I'm quickly finding through usage it works quite well. I'll work around the other items for now as I'm hopeful this library will become the defacto opencv node package. Many thanks for the detailed response and great work!

Just added INTER_LINEAR_EXACT, cartToPolar, polarToCart, Mat::push_back.

You rock, thanks much!

Looks like cv::log and cv::exp are harder to map to js Math functions than I expected as their behavior seems specific to Mat class. If you get a chance...

Hi!
I feel like i'm piggybacking on this issue, but by any chance, do you have any plans to also add cv::goodFeaturesToTrack? 馃槃

cv::exp should be available. Will add cv::log and cv::goodFeaturesToTrack next time I find the time.

Closing. Thanks to @legraphista cv::log and cv::goodFeaturesToTrack have been added with #217 and #218 :)

merge is equivalent to calling the constructor with new Mat([channel1, channel2, channel3]) (see Mat constructor: Mat : new Mat ( [ Mat ] channels ).

I just landed here while searching for cv.merge

Perhaps an alias to that constructor would make sense to address the expected method and that solution?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YaronHershkovitz picture YaronHershkovitz  路  6Comments

SatoshiKawabata picture SatoshiKawabata  路  5Comments

developer239 picture developer239  路  5Comments

djipco picture djipco  路  5Comments

OluAgunloye picture OluAgunloye  路  3Comments