mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Still trying to track down why cv::imread isn't working...
This commit is contained in:
parent
428bfb6784
commit
388dbcec23
2
smoketest.js
Normal file → Executable file
2
smoketest.js
Normal file → Executable file
@ -11,4 +11,4 @@ assert.equal(Math.round(new opencv.Point(1.2, 2.75).y *100), 275)
|
||||
|
||||
|
||||
|
||||
console.log(opencv.Image("./examples/mona.jpg"))
|
||||
console.log(new opencv.Image("./examples/mona.jpg").width, "!!")
|
||||
33
src/Image.cc
33
src/Image.cc
@ -15,11 +15,12 @@ Image::Init(Handle<Object> target) {
|
||||
// Prototype
|
||||
Local<ObjectTemplate> proto = constructor->PrototypeTemplate();
|
||||
|
||||
proto->SetAccessor(String::NewSymbol("width"), GetWidth);
|
||||
proto->SetAccessor(String::NewSymbol("height"), GetHeight);
|
||||
|
||||
/*proto->SetAccessor(String::NewSymbol("source"), GetSource, SetSource);
|
||||
proto->SetAccessor(String::NewSymbol("complete"), GetComplete);
|
||||
proto->SetAccessor(String::NewSymbol("width"), GetWidth);
|
||||
proto->SetAccessor(String::NewSymbol("height"), GetHeight);
|
||||
|
||||
proto->SetAccessor(String::NewSymbol("onload"), GetOnload, SetOnload);
|
||||
proto->SetAccessor(String::NewSymbol("onerror"), GetOnerror, SetOnerror);*/
|
||||
target->Set(String::NewSymbol("Image"), constructor->GetFunction());
|
||||
@ -27,18 +28,20 @@ Image::Init(Handle<Object> target) {
|
||||
|
||||
Handle<Value>
|
||||
Image::New(const Arguments &args) {
|
||||
HandleScope scope;
|
||||
|
||||
Image *img;
|
||||
int width, height;
|
||||
|
||||
|
||||
if (args[0]->IsNumber() && args[1]->IsNumber()){
|
||||
width = args[0]->Uint32Value();
|
||||
height = args[1]->Uint32Value();
|
||||
img = new Image(width, height);
|
||||
width = args[0]->Uint32Value();
|
||||
height = args[1]->Uint32Value();
|
||||
img = new Image(width, height);
|
||||
} else {
|
||||
img = new Image(*args[0]);
|
||||
img = new Image(*args[0]);
|
||||
}
|
||||
|
||||
|
||||
img->Wrap(args.This());
|
||||
return args.This();
|
||||
};
|
||||
@ -50,8 +53,22 @@ Image::Image(int width, int height): ObjectWrap() {
|
||||
};
|
||||
|
||||
|
||||
|
||||
Image::Image(v8::Value* fileName): ObjectWrap() {
|
||||
filename = std::string(*v8::String::AsciiValue(fileName->ToString()));
|
||||
image = cv::imread(filename, -1);
|
||||
//image = cv::imread(filename, -1);
|
||||
};
|
||||
|
||||
|
||||
Handle<Value>
|
||||
Image::GetWidth(Local<String>, const AccessorInfo &info) {
|
||||
HandleScope scope;
|
||||
return scope.Close(Number::New(5));
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
Image::GetHeight(Local<String>, const AccessorInfo &info) {
|
||||
HandleScope scope;
|
||||
return scope.Close(Number::New(5));
|
||||
}
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
class Image: public node::ObjectWrap {
|
||||
public:
|
||||
std::string filename;
|
||||
cv::Mat image;
|
||||
std::string filename;
|
||||
cv::Mat image;
|
||||
|
||||
static Persistent<FunctionTemplate> constructor;
|
||||
static void Init(Handle<Object> target);
|
||||
|
||||
@ -34,7 +34,7 @@ Point::New(const Arguments &args) {
|
||||
double x = 0, y = 0;
|
||||
if (args[0]->IsNumber()) x = args[0]->NumberValue();
|
||||
if (args[1]->IsNumber()) y = args[1]->NumberValue();
|
||||
Point *pt = new Point(x, y);
|
||||
Point *pt = new Point(x, y);
|
||||
pt->Wrap(args.This());
|
||||
return args.This();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user