use github flavored markdown for javascript and bash
Esse commit está contido em:
+36
-14
@@ -13,21 +13,21 @@ You'll need OpenCV 2.3.1 installed.
|
||||
|
||||
Then:
|
||||
|
||||
|
||||
npm install opencv
|
||||
|
||||
```bash
|
||||
$ npm install opencv
|
||||
```
|
||||
|
||||
Or to build the repo:
|
||||
|
||||
|
||||
node-gyp rebuild
|
||||
|
||||
```bash
|
||||
$ node-gyp rebuild
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Face Detection
|
||||
|
||||
|
||||
```javascript
|
||||
cv.readImage("./examples/test.jpg", function(err, im){
|
||||
im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){
|
||||
for (var i=0;i<faces.length; i++){
|
||||
@@ -37,7 +37,7 @@ Or to build the repo:
|
||||
im.save('./out.jpg');
|
||||
});
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
|
||||
## API Documentation
|
||||
@@ -49,14 +49,19 @@ base datastructure in OpenCV. Things like images are just matrices of pixels.
|
||||
|
||||
#### Creation
|
||||
|
||||
```javascript
|
||||
new Matrix(rows, cols)
|
||||
```
|
||||
|
||||
Or if you're thinking of a Matrix as an image:
|
||||
|
||||
```javascript
|
||||
new Matrix(height, width)
|
||||
```
|
||||
|
||||
Or you can use opencv to read in image files. Supported formats are in the OpenCV docs, but jpgs etc are supported.
|
||||
|
||||
```javascript
|
||||
cv.readImage(filename, function(mat){
|
||||
...
|
||||
})
|
||||
@@ -64,9 +69,11 @@ Or you can use opencv to read in image files. Supported formats are in the OpenC
|
||||
cv.readImage(buffer, function(mat){
|
||||
...
|
||||
})
|
||||
```
|
||||
|
||||
If you need to pipe data into an image, you can use an ImageDataStream:
|
||||
|
||||
```javascript
|
||||
var s = new cv.ImageDataStream()
|
||||
|
||||
s.on('load', function(matrix){
|
||||
@@ -74,10 +81,12 @@ If you need to pipe data into an image, you can use an ImageDataStream:
|
||||
})
|
||||
|
||||
fs.createReadStream('./examples/test.jpg').pipe(s);
|
||||
```
|
||||
|
||||
If however, you have a series of images, and you wish to stream them into a
|
||||
stream of Matrices, you can use an ImageStream. Thus:
|
||||
|
||||
```javascript
|
||||
var s = new cv.ImageStream()
|
||||
|
||||
s.on('data', function(matrix){
|
||||
@@ -85,6 +94,7 @@ stream of Matrices, you can use an ImageStream. Thus:
|
||||
})
|
||||
|
||||
ardrone.createPngStream().pipe(s);
|
||||
```
|
||||
|
||||
Note: Each 'data' event into the ImageStream should be a complete image buffer.
|
||||
|
||||
@@ -92,36 +102,42 @@ Note: Each 'data' event into the ImageStream should be a complete image buffer.
|
||||
|
||||
#### Accessing Data
|
||||
|
||||
```javascript
|
||||
var mat = new cv.Matrix.Eye(4,4); // Create identity matrix
|
||||
|
||||
mat.get(0,0) // 1
|
||||
|
||||
mat.row(0) // [1,0,0,0]
|
||||
mat.col(4) // [0,0,0,1]
|
||||
|
||||
```
|
||||
|
||||
##### Save
|
||||
|
||||
```javascript
|
||||
mat.save('./pic.jpg')
|
||||
```
|
||||
|
||||
or:
|
||||
|
||||
```javascript
|
||||
var buff = mat.toBuffer()
|
||||
|
||||
```
|
||||
|
||||
#### Image Processing
|
||||
|
||||
```javascript
|
||||
im.convertGrayscale()
|
||||
im.canny(5, 300)
|
||||
im.houghLinesP()
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### Simple Drawing
|
||||
|
||||
```javascript
|
||||
im.ellipse(x, y)
|
||||
im.line([x1,y1], [x2, y2])
|
||||
|
||||
```
|
||||
|
||||
#### Object Detection
|
||||
|
||||
@@ -129,21 +145,25 @@ There is a shortcut method for
|
||||
[Viola-Jones Haar Cascade](http://www.cognotics.com/opencv/servo_2007_series/part_2/sidebar.html) object
|
||||
detection. This can be used for face detection etc.
|
||||
|
||||
|
||||
```javascript
|
||||
mat.detectObject(haar_cascade_xml, opts, function(err, matches){})
|
||||
```
|
||||
|
||||
For convenience in face recognition, cv.FACE_CASCADE is a cascade that can be used for frontal face recognition.
|
||||
|
||||
Also:
|
||||
|
||||
```javascript
|
||||
mat.goodFeaturesToTrack
|
||||
|
||||
```
|
||||
|
||||
#### Contours
|
||||
|
||||
```javascript
|
||||
mat.findCountours
|
||||
mat.drawContour
|
||||
mat.drawAllContours
|
||||
```
|
||||
|
||||
### Using Contours
|
||||
|
||||
@@ -151,6 +171,7 @@ Also:
|
||||
functions for accessing, computing with, and altering the contours contained in it.
|
||||
See [relevant source code](src/Contours.cc) and [examples](examples/)
|
||||
|
||||
```javascript
|
||||
var contours = im.findContours;
|
||||
|
||||
# Count of contours in the Contours object
|
||||
@@ -178,6 +199,7 @@ See [relevant source code](src/Contours.cc) and [examples](examples/)
|
||||
# Destructively alter contour `index`
|
||||
contours.approxPolyDP(index, epsilon, isClosed);
|
||||
contours.convexHull(index, clockwise);
|
||||
```
|
||||
|
||||
## MIT License
|
||||
The library is distributed under the MIT License - if for some reason that
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário