Fixed typos and updated examples comments and instructions.

This commit is contained in:
edgarsilva 2014-02-26 20:41:56 -06:00
parent e6b174ccde
commit bdb0226bed
8 changed files with 51 additions and 41 deletions

View File

@ -9,7 +9,7 @@ Cylon.robot
{
name: 'camera',
driver: 'camera',
camera: 1,
camera: 0,
haarcascade: "#{ __dirname }/examples/opencv/haarcascade_frontalface_alt.xml"
} # Default camera is 0
]
@ -17,9 +17,9 @@ Cylon.robot
work: (my) ->
my.camera.once('cameraReady', ->
console.log('The camera is ready!')
# We listen for frame ready event, when triggered
# we display the frame/image passed as an argument
# and we tell the window to wait 40 milliseconds
# We listen for the frameReady event, when triggered
# we display the frame/image passed as an argument to
# the listener function, and we tell the window to wait 40 milliseconds
my.camera.on('frameReady', (err, im) ->
console.log("FRAMEREADY!")
my.window.show(im, 40)
@ -27,17 +27,19 @@ Cylon.robot
)
# Here we have two options to start reading frames from
# the camera feed.
# 1. As fast as possible triggering the next frame read
# 1. 'As fast as possible': triggering the next frame read
# in the listener for frameReady, if you need video
# as smooth as possible uncomment #my.camera.readFrame()
# in the listener above and the one below this comment.
# Also comment out the `every 50, my.camera.readFrame`
# at the end of the comments.
#
# my.camera.readFrame()
#
# 2. Use an interval of time to try and get aset amount
# of frames per second (FPS), in the next example
# 2. `Use an interval of time`: to try to get a set amount
# of frames per second (FPS), we use an `every 50, myFunction`,
# we are trying to get 1 frame every 50 milliseconds
# (20 FPS).
# (20 FPS), hence the following line of code.
#
every 50, my.camera.readFrame
)

View File

@ -12,7 +12,7 @@ Cylon.robot({
}, {
name: 'camera',
driver: 'camera',
camera: 1,
camera: 0,
haarcascade: "" + __dirname + "/examples/opencv/haarcascade_frontalface_alt.xml"
}
],
@ -26,4 +26,4 @@ Cylon.robot({
return every(50, my.camera.readFrame);
});
}
}).start();
}).start();

View File

@ -30,8 +30,8 @@ tell it what work we want to do:
my.camera.once('cameraReady', ->
console.log('The camera is ready!')
# We listen for frame ready event, when triggered
# we display the frame/image passed as an argument
# and we tell the window to wait 40 milliseconds
# we display the frame/image passed as an argument to
# the listener function, and we tell the window to wait 40 milliseconds
my.camera.on('frameReady', (err, im) ->
console.log("FRAMEREADY!")
my.window.show(im, 40)
@ -39,17 +39,19 @@ tell it what work we want to do:
)
# Here we have two options to start reading frames from
# the camera feed.
# 1. As fast as possible triggering the next frame read
# 1. 'As fast as possible': triggering the next frame read
# in the listener for frameReady, if you need video
# as smooth as possible uncomment #my.camera.readFrame()
# in the listener above and the one below this comment.
# Also comment out the `every 50, my.camera.readFrame`
# at the end of the comments.
#
# my.camera.readFrame()
#
# 2. Use an interval of time to try and get aset amount
# of frames per second (FPS), in the next example
# 2. `Use an interval of time`: to try to get a set amount
# of frames per second (FPS), we use an `every 50, myFunction`,
# we are trying to get 1 frame every 50 milliseconds
# (20 FPS).
# (20 FPS), hence the following line of code.
#
every 50, my.camera.readFrame
)

View File

@ -6,7 +6,7 @@ Cylon.robot
devices: [
{ name: 'window', driver: 'window' }
{ name: 'camera', driver: 'camera', camera: 1 }
{ name: 'camera', driver: 'camera', camera: 0 }
]
work: (my) ->

View File

@ -12,7 +12,7 @@ Cylon.robot({
}, {
name: 'camera',
driver: 'camera',
camera: 1
camera: 0
}
],
work: function(my) {
@ -24,4 +24,4 @@ Cylon.robot({
return my.camera.readFrame();
});
}
}).start();
}).start();

View File

@ -15,7 +15,7 @@ Let's define the connections and devices:
devices: [
{ name: 'window', driver: 'window' }
{ name: 'camera', driver: 'camera', camera: 1 }
{ name: 'camera', driver: 'camera', camera: 0 }
]
Now that Cylon knows about the necessary hardware we're going to be using, we'll

View File

@ -9,29 +9,32 @@ Cylon.robot
{
name: 'camera',
driver: 'camera',
camera: 1,
camera: 0,
haarcascade: "#{ __dirname }/haarcascade_frontalface_alt.xml"
} # Default camera is 0
]
work: (my) ->
# We setup our face detection once the camera is ready to
# siplays images, we used once to make sure the event listeners
# are only registered once.
# We setup our face detection when the camera is ready to
# display images, we use `once` instead of `on` to make sure
# other event listeners are only registered once.
my.camera.once('cameraReady', ->
console.log('The camera is ready!')
# We add a listener for the facesDetected event
# here we will get (err, image/frame, faces) params.
# here, we will get (err, image/frame, faces) params back in
# the listener function that we pass.
# The faces param is an array conaining any face detected
# in the frame (im).
my.camera.on('facesDetected', (err, im, faces) ->
# We loop trhough the faces and manipulate the image
# We loop through the faces and manipulate the image
# to display a square in the coordinates for the detected
# faces.
for face in faces
im.rectangle([face.x, face.y], [face.x + face.width, face.y + face.height], [0,255,0], 2)
# The second to last param is the color of the rectangle
# as an rgb array e.g. [r,g,b].
# Once the image has been updated with rectangles around
# detected faces we display it in our window.
# the faces detected, we display it in our window.
my.window.show(im, 40)
# After displaying the updated image we trigger another
@ -41,17 +44,17 @@ Cylon.robot
my.camera.readFrame()
)
# We listen for frameReady event, when triggered
# we start the face detection passsing the frame
# that we jsut got.
# we start the face detection passing the frame
# that we just got from the camera feed.
my.camera.on('frameReady', (err, im) ->
my.camera.detectFaces(im)
)
# Here we could also try to get a set amount of processed FPS
# by setting an interval and reading frames every set amount
# of time. We could just uncomment the next line and commenting
# of time. We could just uncomment the next line, then comment
# out the my.camera.readFrame() in the facesDetected listener
# as well as the one two lines below.
# above, as well as the one two lines below.
#every 150, my.camera.readFrame
my.camera.readFrame()
)

View File

@ -27,23 +27,26 @@ Now that Cylon knows about the necessary hardware we're going to be using, we'll
tell it what work we want to do:
work: (my) ->
# We setup our face detection once the camera is ready to
# siplays images, we used once to make sure the event listeners
# are only registered once.
# We setup our face detection when the camera is ready to
# display images, we use `once` instead of `on` to make sure
# other event listeners are only registered once.
my.camera.once('cameraReady', ->
console.log('The camera is ready!')
# We add a listener for the facesDetected event
# here we will get (err, image/frame, faces) params.
# here, we will get (err, image/frame, faces) params back in
# the listener function that we pass.
# The faces param is an array conaining any face detected
# in the frame (im).
my.camera.on('facesDetected', (err, im, faces) ->
# We loop trhough the faces and manipulate the image
# We loop through the faces and manipulate the image
# to display a square in the coordinates for the detected
# faces.
for face in faces
im.rectangle([face.x, face.y], [face.x + face.width, face.y + face.height], [0,255,0], 2)
# The second to last param is the color of the rectangle
# as an rgb array e.g. [r,g,b].
# Once the image has been updated with rectangles around
# detected faces we display it in our window.
# the faces detected, we display it in our window.
my.window.show(im, 40)
# After displaying the updated image we trigger another
@ -53,17 +56,17 @@ tell it what work we want to do:
my.camera.readFrame()
)
# We listen for frameReady event, when triggered
# we start the face detection passsing the frame
# that we jsut got.
# we start the face detection passing the frame
# that we just got from the camera feed.
my.camera.on('frameReady', (err, im) ->
my.camera.detectFaces(im)
)
# Here we could also try to get a set amount of processed FPS
# by setting an interval and reading frames every set amount
# of time. We could just uncomment the next line and commenting
# of time. We could just uncomment the next line, then comment
# out the my.camera.readFrame() in the facesDetected listener
# as well as the one two lines below.
# above as well as the one two lines below.
#every 150, my.camera.readFrame
my.camera.readFrame()
)