mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Tidy up lib
This commit is contained in:
parent
b9fbf5f526
commit
862a31eb2a
@ -4,8 +4,13 @@ var Stream = require('stream').Stream
|
||||
, path = require('path');
|
||||
|
||||
var cv = module.exports = require('./bindings');
|
||||
var Matrix = cv.Matrix, VideoCapture = cv.VideoCapture,
|
||||
ImageStream, ImageDataStream, ObjectDetectionStream, VideoStream;
|
||||
|
||||
var Matrix = cv.Matrix
|
||||
, VideoCapture = cv.VideoCapture
|
||||
, ImageStream
|
||||
, ImageDataStream
|
||||
, ObjectDetectionStream
|
||||
, VideoStream;
|
||||
|
||||
|
||||
Matrix.prototype.detectObject = function(classifier, opts, cb){
|
||||
@ -29,8 +34,7 @@ Matrix.prototype.inspect = function(){
|
||||
}
|
||||
|
||||
|
||||
ImageStream =
|
||||
cv.ImageStream = function(){
|
||||
ImageStream = cv.ImageStream = function(){
|
||||
this.writable = true;
|
||||
}
|
||||
util.inherits(ImageStream, Stream);
|
||||
@ -45,8 +49,7 @@ ImageStream.prototype.write = function(buf){
|
||||
}
|
||||
|
||||
|
||||
ImageDataStream =
|
||||
cv.ImageDataStream = function(){
|
||||
ImageDataStream = cv.ImageDataStream = function(){
|
||||
this.data = Buffers([]);
|
||||
this.writable = true;
|
||||
}
|
||||
@ -71,8 +74,7 @@ ImageDataStream.prototype.end = function(b){
|
||||
}
|
||||
|
||||
|
||||
ObjectDetectionStream =
|
||||
cv.ObjectDetectionStream = function(cascade, opts){
|
||||
ObjectDetectionStream = cv.ObjectDetectionStream = function(cascade, opts){
|
||||
this.classifier = new cv.CascadeClassifier(cascade);
|
||||
this.opts = opts || {};
|
||||
this.readable = true;
|
||||
@ -94,8 +96,7 @@ ObjectDetectionStream.prototype.write = function(m){
|
||||
}
|
||||
|
||||
|
||||
VideoStream =
|
||||
cv.VideoStream = function(src){
|
||||
VideoStream = cv.VideoStream = function(src){
|
||||
if (!(src instanceof VideoCapture)) src = new VideoCapture(src);
|
||||
this.video = src;
|
||||
this.readable = true;
|
||||
@ -134,5 +135,19 @@ VideoCapture.prototype.toStream = function(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Provide cascade data for faces etc.
|
||||
cv.FACE_CASCADE = path.resolve(__dirname, '../data/haarcascade_frontalface_alt.xml')
|
||||
var CASCADES = {
|
||||
FACE_CASCADE: 'haarcascade_frontalface_alt.xml'
|
||||
, EYE_CASCADE: 'haarcascade_eye.xml'
|
||||
, EYEGLASSES_CASCADE: 'haarcascade_eye_tree_eyeglasses.xml'
|
||||
, FULLBODY_CASCADE: 'haarcascade_fullbody.xml'
|
||||
, CAR_SIDE_CASCADE: 'hogcascade_cars_sideview.xml'
|
||||
}
|
||||
|
||||
Object.keys(CASCADES).forEach(function(k){
|
||||
cv[k] = path.resolve(__dirname, '../data', CASCADES[k])
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user