mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
don't think my video will work because I built opencv without ffmpeg :(
This commit is contained in:
parent
a82c66fa25
commit
c24b662b37
@ -17,4 +17,4 @@ im.save('./out.jpg');
|
||||
|
||||
var cam = new cv.VideoCapture(0);
|
||||
|
||||
console.log(cam.getFrame());
|
||||
console.log(cam.getFrame().save("out.jpg"));
|
||||
10
src/Image.cc
10
src/Image.cc
@ -116,13 +116,3 @@ Image::Ellipse(const v8::Arguments& args){
|
||||
cv::ellipse(self->mat, cv::Point(x, y), cv::Size(width, height), 0, 0, 360, cv::Scalar( 255, 0, 255 ), 4, 8, 0);
|
||||
return scope.Close(v8::Null());
|
||||
}
|
||||
|
||||
|
||||
v8::Handle
|
||||
Image::Wrap() {
|
||||
v8::HandleScope scope;
|
||||
v8::Handle cons = constructor->GetFunction();
|
||||
v8::Handle external = v8::External::New(value);
|
||||
v8::Handle result = cons->NewInstance(1, &external);
|
||||
return scope.Close(result);
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ class Image: public node::ObjectWrap {
|
||||
static Handle<Value> Save(const v8::Arguments&);
|
||||
static Handle<Value> Ellipse(const v8::Arguments&);
|
||||
|
||||
|
||||
private:
|
||||
~Image();
|
||||
};
|
||||
|
||||
@ -43,9 +43,9 @@ VideoCaptureWrap::VideoCaptureWrap(int device){
|
||||
|
||||
cv::VideoCapture cap(device);
|
||||
|
||||
if(!cap.isOpened())
|
||||
if(!cap.isOpened()){
|
||||
ThrowException(Exception::Error(String::New("Camera could not be opened")));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -56,11 +56,15 @@ VideoCaptureWrap::GetFrame(const Arguments &args) {
|
||||
VideoCaptureWrap *v = ObjectWrap::Unwrap<VideoCaptureWrap>(args.This());
|
||||
|
||||
cv::Mat frame;
|
||||
v->cap >> frame;
|
||||
v->cap.retrieve(frame);
|
||||
|
||||
Handle<Value> im = Image::New();
|
||||
|
||||
return scope.Close(im);
|
||||
|
||||
|
||||
Local<Object> im_h = Image::constructor->GetFunction()->NewInstance();
|
||||
Image *im = ObjectWrap::Unwrap<Image>(im_h);
|
||||
im->mat = frame;
|
||||
printf("* %i * %i * %i : open %i", im->mat.empty(), frame.empty(), v->cap.get(CV_CAP_PROP_FPS), v->cap.isOpened());
|
||||
return scope.Close(im_h);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user