Difference between revisions of "OpenCV4"
Line 57: | Line 57: | ||
==== Houghline Transformation==== | ==== Houghline Transformation==== | ||
− | [[File: | + | [[File:line.PNG|400px|thumb|left|Sample Houghline Transformation]] |
Using the Canny Edge detection to find the region of interest(edges of the image) prior to the Houghline Transformation,one can now ready to use the Hougline Tranformation. | Using the Canny Edge detection to find the region of interest(edges of the image) prior to the Houghline Transformation,one can now ready to use the Hougline Tranformation. | ||
Line 72: | Line 72: | ||
<code>lines = cv.HoughLines(dst, 1, np.pi / 180, 150, None, 0, 0)</code> | <code>lines = cv.HoughLines(dst, 1, np.pi / 180, 150, None, 0, 0)</code> | ||
− | |||
− | |||
=== Sample Projects === | === Sample Projects === |
Revision as of 18:50, 12 December 2018
Contents
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
since the raspberry pi may freeze so it best to just domake
ormake-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]
Note:
- Use
sleep
(measured in seconds) to create a delay between the preview:time.sleep(seconds)
- Use
- Another way to enable your camera is: go to the terminal → type in
sudo raspi-config
→ selectEnable Camera
→ press Enter → selectFinish
→ reboot and log back on to the Raspberry Pi.
- Another way to enable your camera is: go to the terminal → type in
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 section.
Follow this Link[5]if you want to see its parameters.(search for Canny Edge)
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-in function.
Ex: To load image:
- src =
cv.imread
(filename, cv.IMREAD_GRAYSCALE)
Then use:
- dst =
cv.Canny
(src, 50, 200, None, 3)
Houghline Transformation
Using the Canny Edge detection to find the region of interest(edges of the image) prior to the Houghline Transformation,one can now ready to use the Hougline Tranformation.
The process should be: capturing an image→Canny Edge Detection→Houghline Transformation.
Follow the following instruction for Houghline Transformation.[6]
Follow this Link[5]if you want to see its parameters.(search for Hough Line)
Example:
lines = cv.HoughLines(dst, 1, np.pi / 180, 150, None, 0, 0)
Sample Projects
- ESE205-CVChess/board_Recognition.py [7]
- DE3-ROB1-CHESS/perception.mainDetect[8]
Authors
- Nhut Dang
- Robert Goodloe
- Ethan Shry(TA)
Fall 2018