Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
daca1a1
commit 1322e58
Showing
5 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,77 @@ | |||
#include "VideoWriter.h" | |||
#include "Matrix.h" | |||
#include "OpenCV.h" | |||
|
|||
v8::Persistent<FunctionTemplate> VideoWriterWrap::constructor; | |||
|
|||
void | |||
VideoWriterWrap::Init(Handle<Object> target) { | |||
HandleScope scope; | |||
|
|||
// Constructor | |||
constructor = Persistent<FunctionTemplate>::New( | |||
FunctionTemplate::New(VideoWriterWrap::New)); | |||
constructor->InstanceTemplate()->SetInternalFieldCount(1); | |||
constructor->SetClassName(String::NewSymbol("VideoWriter")); | |||
|
|||
// Prototype | |||
//Local<ObjectTemplate> proto = constructor->PrototypeTemplate(); | |||
|
|||
NODE_SET_PROTOTYPE_METHOD(constructor, "write", Write); | |||
|
|||
target->Set(String::NewSymbol("VideoWriter"), constructor->GetFunction()); | |||
}; | |||
|
|||
|
|||
|
|||
Handle<Value> | |||
VideoWriterWrap::New(const Arguments &args) { | |||
HandleScope scope; | |||
|
|||
if (args.This()->InternalFieldCount() == 0) | |||
return v8::ThrowException( | |||
v8::Exception::TypeError(v8::String::New("Cannot Instantiate without new"))); | |||
|
|||
VideoWriterWrap *v; | |||
std::string filename; | |||
int codec = CV_FOURCC('M','J','P','G'); // Default mjpg | |||
double fps = 24.0; | |||
cv::Size framesize = cv::Size(640, 320); | |||
//bool isColor; // TODO | |||
|
|||
filename = std::string(*v8::String::AsciiValue(args[0]->ToString())); | |||
|
|||
|
|||
|
|||
v = new VideoWriterWrap(filename, codec, fps, framesize); | |||
v->Wrap(args.This()); | |||
|
|||
return args.This(); | |||
} | |||
|
|||
|
|||
|
|||
VideoWriterWrap::VideoWriterWrap(const std::string& filename, int codec, | |||
double fps, cv::Size framesize){ | |||
|
|||
writer = cv::VideoWriter(filename, codec, fps, framesize); | |||
|
|||
|
|||
if (!writer.isOpened()){ | |||
std::cout << "VideoWriter: Could not be opened!" | |||
} | |||
|
|||
} | |||
|
|||
|
|||
Handle<Value> | |||
VideoWriterWrap::Write(const Arguments &args) { | |||
SETUP_FUNCTION(VideoWriterWrap) | |||
|
|||
Matrix *im = ObjectWrap::Unwrap<Matrix>(args[0]->ToObject()); | |||
|
|||
self->writer << im->mat; | |||
|
|||
return scope.Close(v8::Undefined()); | |||
} | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,15 @@ | |||
#include "OpenCV.h" | |||
|
|||
class VideoWriterWrap: public node::ObjectWrap { | |||
public: | |||
cv::VideoWriter writer; | |||
|
|||
static Persistent<FunctionTemplate> constructor; | |||
static void Init(Handle<Object> target); | |||
static Handle<Value> New(const Arguments &args); | |||
|
|||
VideoWriterWrap(const std::string& filename, int codec, | |||
double fps, cv::Size framesize); | |||
|
|||
static Handle<Value> Write(const v8::Arguments&); | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1322e58
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, what is the status of this branch? If there is a list of TODOs, i'll be happy to contribute.