mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Add test for inc/Matrix.h
This commit is contained in:
parent
c457310497
commit
38d19a6236
57
binding.gyp
57
binding.gyp
@ -72,6 +72,63 @@
|
||||
}]
|
||||
]
|
||||
},
|
||||
{
|
||||
"target_name": "test_nativemat",
|
||||
|
||||
"sources": [
|
||||
"test/nativemat.cc",
|
||||
],
|
||||
|
||||
"libraries": [
|
||||
"<!@(node utils/find-opencv.js --libs)"
|
||||
],
|
||||
# For windows
|
||||
|
||||
"include_dirs": [
|
||||
"<!@(node utils/find-opencv.js --cflags)",
|
||||
"<!(node -e \"require('nan')\")",
|
||||
"<!(node -e \"require('./include_dirs')\")"
|
||||
],
|
||||
|
||||
"cflags!" : [ "-fno-exceptions"],
|
||||
"cflags_cc!": [ "-fno-rtti", "-fno-exceptions"],
|
||||
|
||||
"conditions": [
|
||||
[ "OS==\"linux\"", {
|
||||
"cflags": [
|
||||
"<!@(pkg-config --cflags \"opencv >= 2.3.1\" )",
|
||||
"-Wall"
|
||||
]
|
||||
}],
|
||||
[ "OS==\"win\"", {
|
||||
"cflags": [
|
||||
"-Wall"
|
||||
],
|
||||
"defines": [
|
||||
"WIN"
|
||||
],
|
||||
"msvs_settings": {
|
||||
"VCCLCompilerTool": {
|
||||
"ExceptionHandling": "2",
|
||||
"DisableSpecificWarnings": [ "4530", "4506", "4244" ],
|
||||
},
|
||||
}
|
||||
}],
|
||||
[ # cflags on OS X are stupid and have to be defined like this
|
||||
"OS==\"mac\"", {
|
||||
"xcode_settings": {
|
||||
"OTHER_CFLAGS": [
|
||||
"-mmacosx-version-min=10.7",
|
||||
"-std=c++11",
|
||||
"-stdlib=libc++",
|
||||
"<!@(pkg-config --cflags opencv)"
|
||||
],
|
||||
"GCC_ENABLE_CPP_RTTI": "YES",
|
||||
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
|
||||
}
|
||||
}]
|
||||
]
|
||||
},
|
||||
{
|
||||
"target_name": "action_after_build",
|
||||
"type": "none",
|
||||
|
||||
20
test/nativemat.cc
Normal file
20
test/nativemat.cc
Normal file
@ -0,0 +1,20 @@
|
||||
#include <nan.h>
|
||||
#include <Matrix.h>
|
||||
|
||||
void Size(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
// Unwrap the node-opencv Matrix object into a normal cv::Mat
|
||||
cv::Mat mat = Nan::ObjectWrap::Unwrap<node_opencv::Matrix>(info[0]->ToObject())->mat;
|
||||
|
||||
v8::Local < v8::Array > arr = Nan::New<v8::Array>(2);
|
||||
arr->Set(0, Nan::New<v8::Number>(mat.size().height));
|
||||
arr->Set(1, Nan::New<v8::Number>(mat.size().width));
|
||||
|
||||
info.GetReturnValue().Set(arr);
|
||||
}
|
||||
|
||||
void Init(v8::Local<v8::Object> exports) {
|
||||
exports->Set(Nan::New("size").ToLocalChecked(),
|
||||
Nan::New<v8::FunctionTemplate>(Size)->GetFunction());
|
||||
}
|
||||
|
||||
NODE_MODULE(test_nativemat, Init)
|
||||
10
test/unit.js
10
test/unit.js
@ -326,6 +326,16 @@ test('LDA Wrap', function(assert) {
|
||||
assert.end();
|
||||
})
|
||||
|
||||
|
||||
test('Native Matrix', function(assert) {
|
||||
var nativemat = require('../build/Release/test_nativemat.node');
|
||||
var mat = new cv.Matrix(42, 8);
|
||||
|
||||
assert.deepEqual(mat.size(), nativemat.size(mat), 'nativemat');
|
||||
assert.end();
|
||||
})
|
||||
|
||||
|
||||
// Test the examples folder.
|
||||
require('./examples')()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user