-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from maix import image | ||
|
||
# 1. load image | ||
src_img = image.load("test.jpg") | ||
|
||
# 2. binarize the image | ||
thresholds = ((0, 100, 20, 80, 10, 80)) | ||
img = src_img.copy() | ||
img.binary(thresholds) | ||
img.save("binary.jpg") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from maix import camera, display, image | ||
from maix.image import ApriltagFamilies | ||
|
||
cam = camera.Camera(160, 120) | ||
disp = display.Display() | ||
|
||
families = ApriltagFamilies.TAG36H11 | ||
|
||
while 1: | ||
img = cam.read() | ||
|
||
apriltags = img.find_apriltags(families=ApriltagFamilies.TAG36H11) | ||
for a in apriltags: | ||
corners = a.corners() | ||
for i in range(4): | ||
img.draw_line(corners[i][0], corners[i][1], corners[(i + 1) % 4][0], corners[(i + 1) % 4][1], image.COLOR_GREEN, 2) | ||
|
||
disp.show(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from maix import camera, display, image | ||
|
||
cam = camera.Camera(320, 240) | ||
disp = display.Display() | ||
|
||
|
||
while 1: | ||
img = cam.read() | ||
|
||
barcodes = img.find_barcodes() | ||
for b in barcodes: | ||
rect = b.rect() | ||
img.draw_rect(rect[0], rect[1], rect[2], rect[3], image.COLOR_BLUE, 2) | ||
img.draw_string(0, 0, "payload: " + b.payload(), image.COLOR_GREEN) | ||
|
||
disp.show(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from maix import camera, display, image | ||
|
||
cam = camera.Camera(320, 240) | ||
disp = display.Display() | ||
|
||
area_threshold = 1000 | ||
pixels_threshold = 1000 | ||
# thresholds = [[0, 80, 40, 80, 10, 80]] # red | ||
thresholds = [[0, 80, -120, -10, 0, 30]] # green | ||
# thresholds = [[0, 80, 30, 100, -120, -60]] # blue | ||
while 1: | ||
img = cam.read() | ||
|
||
blobs = img.find_blobs(thresholds, area_threshold = 1000, pixels_threshold = 1000) | ||
for b in blobs: | ||
corners = b.corners() | ||
for i in range(4): | ||
img.draw_line(corners[i][0], corners[i][1], corners[(i + 1) % 4][0], corners[(i + 1) % 4][1], image.COLOR_RED) | ||
|
||
disp.show(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from maix import camera, display | ||
from maix.image import EdgeDetector | ||
|
||
cam = camera.Camera(320, 240) | ||
disp = display.Display() | ||
|
||
edge_type = EdgeDetector.EDGE_CANNY | ||
|
||
while 1: | ||
img = cam.read() | ||
img.find_edges(edge_type, threshold=[50, 100]) | ||
disp.show(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from maix import camera, display, image | ||
import math | ||
|
||
cam = camera.Camera(320, 240) | ||
disp = display.Display() | ||
|
||
threshold = 2000 | ||
|
||
while 1: | ||
img = cam.read() | ||
|
||
lines = img.find_lines(threshold=2000) | ||
for a in lines: | ||
img.draw_line(a.x1(), a.y1(), a.x2(), a.y2(), image.COLOR_RED, 2) | ||
theta = a.theta() | ||
rho = a.rho() | ||
angle_in_radians = math.radians(theta) | ||
x = int(math.cos(angle_in_radians) * rho) | ||
y = int(math.sin(angle_in_radians) * rho) | ||
img.draw_line(0, 0, x, y, image.COLOR_GREEN, 2) | ||
img.draw_string(x, y, "theta: " + str(theta) + "," + "rho: " + str(rho), image.COLOR_GREEN) | ||
|
||
disp.show(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from maix import camera, display, image | ||
|
||
cam = camera.Camera(320, 240) | ||
disp = display.Display() | ||
|
||
while 1: | ||
img = cam.read() | ||
qrcodes = img.find_qrcodes() | ||
for q in qrcodes: | ||
corners = q.corners() | ||
for i in range(4): | ||
img.draw_line(corners[i][0], corners[i][1], corners[(i + 1) % 4][0], corners[(i + 1) % 4][1], image.COLOR_RED) | ||
img.draw_string(0, 0, "payload: " + q.payload(), image.COLOR_BLUE) | ||
|
||
disp.show(img) |