Difference between revisions of "OpenCV4"

From ESE205 Wiki
Jump to navigation Jump to search
Line 9: Line 9:
 
=== Process ===
 
=== Process ===
 
==== Install OpenCV====
 
==== Install OpenCV====
Follow these instruction<ref>Open CV instruction.:[https://www.pyimagesearch.com/2018/09/26/install-opencv-4-on-your-raspberry-pi/OpenCV Link]</ref> to install OpenCV onto your Raspberry Pi using the terminal.  
+
Follow these instruction<ref>Open CV instruction:[https://www.pyimagesearch.com/2018/09/26/install-opencv-4-on-your-raspberry-pi/ Link]</ref> to install OpenCV onto your Raspberry Pi using the terminal.  
  
 
*Important note: don't do <code>make-j4</code>. It may freeze so it best to just do <code>make</code> or <code>make-j1</code>.
 
*Important note: don't do <code>make-j4</code>. It may freeze so it best to just do <code>make</code> or <code>make-j1</code>.
Line 17: Line 17:
  
 
==== Capturing image====
 
==== Capturing image====
Following these step to set up your camera<ref>Setting up camera.:[https://www.dexterindustries.com/howto/installing-the-raspberry-pi-camera/Camera Link]</ref>
+
Following these step to set up your camera<ref>Setting up camera:[https://www.dexterindustries.com/howto/installing-the-raspberry-pi-camera/ Link]</ref>
  
 
*Note: Ignoring GoPiGo installation.
 
*Note: Ignoring GoPiGo installation.
  
  
Once the camera is set up, it is ready to take pictures. In order to capture image, follow these instruction <ref>Capturing Image:[https://medium.com/@petehouston/capture-images-from-raspberry-pi-camera-module-using-picamera-505e9788d609 Capturing Image Link]</ref>
+
Once the camera is set up, it is ready to take pictures. In order to capture image, follow these instruction <ref>Capturing Image:[https://medium.com/@petehouston/capture-images-from-raspberry-pi-camera-module-using-picamera-505e9788d609 Link]</ref>
  
 
{|style="margin: 0 auto;"
 
{|style="margin: 0 auto;"
Line 39: Line 39:
 
Once you have a picture, you may want to use edge detection to detect the chessboard region of interest.  
 
Once you have a picture, you may want to use edge detection to detect the chessboard region of interest.  
  
Follow these instruction for [https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_canny/py_canny.html Canny edge detection].
+
Follow these instruction for Canny edge detection<ref>Canny edge detection:[https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_canny/py_canny.html Link]</ref>
  
 
* Note: Scroll down to the Explanation.
 
* Note: Scroll down to the Explanation.

Revision as of 01:13, 12 December 2018

Overview

This is a tutorial on how to install OpenCV4 and use camera module.

Materials/Prerequisites

  • Raspberry Pi
  • Raspberry Pi Camera

Process

Install OpenCV

Follow these instruction[1] to install OpenCV onto your Raspberry Pi using the terminal.

  • Important note: don't do make-j4. It may freeze so it best to just do make or make-j1.


After you have successfully installed OpenCV, you will be able to use import cv2. If you do it on the terminal, you want to put in these code source ~/.profile and then workon cv.

Capturing image

Following these step to set up your camera[2]

  • Note: Ignoring GoPiGo installation.


Once the camera is set up, it is ready to take pictures. In order to capture image, follow these instruction [3]

Taking picture code


Note:

  • Use sleep (measured in seconds) to create a delay between the preview: time.sleep(seconds)
  • Another way to enable your camera is: go to the terminal → type in sudo raspi-config → select Enable Camera → press Enter → select Finish → reboot and log back on to the Raspberry Pi.

Edge Detector

Once you have a picture, you may want to use edge detection to detect the chessboard region of interest.

Follow these instruction for Canny edge detection[4]

  • Note: Scroll down to the Explanation.

In order to use build-in function in Open CV: remember to import cv2. In the instruction, the import cv2 as cv means that you can now type in cv instead of cv2 when using build function.


Use the following build-in code for Canny Detection:

Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size )

Ex: To load image:

  • src = cv.imread(filename, cv.IMREAD_GRAYSCALE)

Then use:

  • dst = cv.Canny(src, 50, 200, None, 3)

Hougline Transformation

Authors

  • Nhut Dang
  • Robert Goodloe
  • Ethan Shry(TA)

Fall 2018

Group Link

Group page

Group weekly log

References

  1. Open CV instruction:Link
  2. Setting up camera:Link
  3. Capturing Image:Link
  4. Canny edge detection:Link