From bdb0226bed542c0293f9f79479ebc73bb21e4da0 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Wed, 26 Feb 2014 20:41:56 -0600 Subject: [PATCH] Fixed typos and updated examples comments and instructions. --- .../display-camera-feed.coffee | 18 +++++++------ .../display-camera-feed.js | 4 +-- .../display-camera-feed.litcoffee | 14 ++++++----- .../display-image-from-camera.coffee | 2 +- .../display-image-from-camera.js | 4 +-- .../display-image-from-camera.litcoffee | 2 +- .../face-detection.coffee | 25 +++++++++++-------- .../face-detection.litcoffee | 23 +++++++++-------- 8 files changed, 51 insertions(+), 41 deletions(-) diff --git a/examples/opencv_display_camera/display-camera-feed.coffee b/examples/opencv_display_camera/display-camera-feed.coffee index 6a37a5e..106c32e 100644 --- a/examples/opencv_display_camera/display-camera-feed.coffee +++ b/examples/opencv_display_camera/display-camera-feed.coffee @@ -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 ) diff --git a/examples/opencv_display_camera/display-camera-feed.js b/examples/opencv_display_camera/display-camera-feed.js index 962f7de..aa1945e 100644 --- a/examples/opencv_display_camera/display-camera-feed.js +++ b/examples/opencv_display_camera/display-camera-feed.js @@ -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(); \ No newline at end of file +}).start(); diff --git a/examples/opencv_display_camera/display-camera-feed.litcoffee b/examples/opencv_display_camera/display-camera-feed.litcoffee index 7e3fc3a..247d78a 100644 --- a/examples/opencv_display_camera/display-camera-feed.litcoffee +++ b/examples/opencv_display_camera/display-camera-feed.litcoffee @@ -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 ) diff --git a/examples/opencv_display_image/display-image-from-camera.coffee b/examples/opencv_display_image/display-image-from-camera.coffee index b42a599..b64dec6 100644 --- a/examples/opencv_display_image/display-image-from-camera.coffee +++ b/examples/opencv_display_image/display-image-from-camera.coffee @@ -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) -> diff --git a/examples/opencv_display_image/display-image-from-camera.js b/examples/opencv_display_image/display-image-from-camera.js index aeb3f8d..5594253 100644 --- a/examples/opencv_display_image/display-image-from-camera.js +++ b/examples/opencv_display_image/display-image-from-camera.js @@ -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(); \ No newline at end of file +}).start(); diff --git a/examples/opencv_display_image/display-image-from-camera.litcoffee b/examples/opencv_display_image/display-image-from-camera.litcoffee index eff97d1..b9c4ccd 100644 --- a/examples/opencv_display_image/display-image-from-camera.litcoffee +++ b/examples/opencv_display_image/display-image-from-camera.litcoffee @@ -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 diff --git a/examples/opencv_face_detection/face-detection.coffee b/examples/opencv_face_detection/face-detection.coffee index 577c556..6ef7876 100644 --- a/examples/opencv_face_detection/face-detection.coffee +++ b/examples/opencv_face_detection/face-detection.coffee @@ -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() ) diff --git a/examples/opencv_face_detection/face-detection.litcoffee b/examples/opencv_face_detection/face-detection.litcoffee index 5cdc0e9..48d908c 100644 --- a/examples/opencv_face_detection/face-detection.litcoffee +++ b/examples/opencv_face_detection/face-detection.litcoffee @@ -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() )