mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Merge pull request #595 from eric-radiant/master
Add support for scale param in mul, update goodFeaturesToTrack a bit
This commit is contained in:
commit
48a4fc35e8
@ -1683,14 +1683,21 @@ NAN_METHOD(Matrix::GoodFeaturesToTrack) {
|
|||||||
int maxCorners = info.Length() >= 1 ? info[0]->IntegerValue() : 500;
|
int maxCorners = info.Length() >= 1 ? info[0]->IntegerValue() : 500;
|
||||||
double qualityLevel = info.Length() >= 2 ? (double) info[1]->NumberValue() : 0.01;
|
double qualityLevel = info.Length() >= 2 ? (double) info[1]->NumberValue() : 0.01;
|
||||||
double minDistance = info.Length() >= 3 ? (double) info[2]->NumberValue() : 10;
|
double minDistance = info.Length() >= 3 ? (double) info[2]->NumberValue() : 10;
|
||||||
|
int blockSize = info.Length() >= 4 ? info[3]->IntegerValue() : 3;
|
||||||
|
bool useHarrisDetector = info.Length() >= 5 ? info[4]->BooleanValue() : false;
|
||||||
|
double k = info.Length() >= 6 ? (double) info[5]->NumberValue() : 0.04;
|
||||||
|
|
||||||
std::vector<cv::Point2f> corners;
|
std::vector<cv::Point2f> corners;
|
||||||
cv::Mat gray;
|
cv::Mat gray;
|
||||||
|
|
||||||
cvtColor(self->mat, gray, CV_BGR2GRAY);
|
if (self->mat.channels() == 1) {
|
||||||
equalizeHist(gray, gray);
|
gray = self->mat;
|
||||||
|
} else {
|
||||||
|
cvtColor(self->mat, gray, CV_BGR2GRAY);
|
||||||
|
equalizeHist(gray, gray);
|
||||||
|
}
|
||||||
|
|
||||||
cv::goodFeaturesToTrack(gray, corners, maxCorners, qualityLevel, minDistance);
|
cv::goodFeaturesToTrack(gray, corners, maxCorners, qualityLevel, minDistance, cv::noArray(), blockSize, useHarrisDetector, k);
|
||||||
v8::Local<v8::Array> arr = Nan::New<Array>(corners.size());
|
v8::Local<v8::Array> arr = Nan::New<Array>(corners.size());
|
||||||
|
|
||||||
for (unsigned int i=0; i<corners.size(); i++) {
|
for (unsigned int i=0; i<corners.size(); i++) {
|
||||||
@ -3112,7 +3119,11 @@ NAN_METHOD(Matrix::Mul) {
|
|||||||
|
|
||||||
Matrix *other = Nan::ObjectWrap::Unwrap<Matrix>(info[0]->ToObject());
|
Matrix *other = Nan::ObjectWrap::Unwrap<Matrix>(info[0]->ToObject());
|
||||||
|
|
||||||
cv::Mat res = self->mat.mul(other->mat);
|
double scale = 1;
|
||||||
|
if (info.Length() > 1) scale = info[1]->NumberValue();
|
||||||
|
|
||||||
|
cv::Mat res = self->mat.mul(other->mat, scale);
|
||||||
|
|
||||||
Local<Object> out = Nan::NewInstance(Nan::GetFunction(Nan::New(Matrix::constructor)).ToLocalChecked()).ToLocalChecked();
|
Local<Object> out = Nan::NewInstance(Nan::GetFunction(Nan::New(Matrix::constructor)).ToLocalChecked()).ToLocalChecked();
|
||||||
Matrix *m_out = Nan::ObjectWrap::Unwrap<Matrix>(out);
|
Matrix *m_out = Nan::ObjectWrap::Unwrap<Matrix>(out);
|
||||||
m_out->mat = res;
|
m_out->mat = res;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user