opencv
Computer vision with OpenCV: image processing, features, face detection, neural networks and video.
import opencv
This package binds the OpenCV library and gives most of the everyday computer vision work: color conversion, resizing, filters, edge detection and thresholds, contours, ORB and SIFT features, face detection with a cascade classifier, running DNN networks, and reading and writing video and camera frames.
It needs OpenCV and the Salam shim at run time; check with Available that the library was loaded. For simpler work with no dependency, see the image package. The examples on the site are only type-checked.
Types
VideoCapture
struct VideoCapture| Name | Type | Description |
|---|---|---|
handle | void* | The internal handle. |
import opencv
import image
func main:
mut cascade := opencv.LoadCascade("haarcascade_frontalface_default.xml")
mut photo := opencv.Read("people_en.jpg")
if cascade.ok():
each face in cascade.detect(photo.to_gray(), 1.1, 5, 100):
photo.rectangle(face.x, face.y, face.width, face.height, opencv.Green(), 2)
end
end
cascade.free()
mut net := opencv.LoadNet("MobileNetSSD_en.caffemodel", "MobileNetSSD_en.prototxt")
mut single := opencv.LoadNetSingleFile("model_en.onnx")
if net.ok():
_ := net.set_input(photo, 0.007843, opencv.RGB(127, 127, 127), false, opencv.Size { width = 300, height = 300 })
output := net.forward()
_ := net.forward_layer("detection_out")
each obj in opencv.ParseSSDDetections(output, photo.width(), photo.height(), 0.5):
println obj.class_id, obj.confidence, obj.x, obj.y, obj.width, obj.height
end
end
net.free()
single.free()
mut video := opencv.OpenVideo("clip_en.mp4")
mut camera := opencv.OpenCamera(0)
mut writer := opencv.NewVideoWriter("out_en.mp4", "mp4v", video.fps(), 640, 480)
println video.ok(), video.frame_count(), camera.ok(), writer.ok()
opencv.CreateTrackbar("threshold", "preview", 100, 255)
until video.ok():
frame := video.read()
if frame.empty():
break
end
level := opencv.GetTrackbarPos("threshold", "preview")
edges := frame.to_gray().canny(level as f64, 200.0)
_ := writer.write(frame)
opencv.Imshow("preview", edges)
if opencv.WaitKey(1) == 27:
break
end
end
opencv.SetTrackbarPos("threshold", "preview", 50)
opencv.DestroyWindow("preview")
opencv.DestroyAllWindows()
video.close()
camera.close()
writer.close()
picture := opencv.ToImage(photo)
println picture.width
_ := opencv.FromImage(image.New(8, 8))
endok
func ok(): boolThe example for this item is shown with the ones above: opencv-Detect.salam
read
func read(): MatThe example for this item is shown with the ones above: opencv-Detect.salam
fps
func fps(): f64The example for this item is shown with the ones above: opencv-Detect.salam
frame_count
func frame_count(): intThe example for this item is shown with the ones above: opencv-Detect.salam
close
func close()The example for this item is shown with the ones above: opencv-Detect.salam
VideoWriter
struct VideoWriter| Name | Type | Description |
|---|---|---|
handle | void* | The internal handle. |
The example for this item is shown with the ones above: opencv-Detect.salam
ok
func ok(): boolThe example for this item is shown with the ones above: opencv-Detect.salam
write
func write(frame: Mat): boolThe example for this item is shown with the ones above: opencv-Detect.salam
close
func close()The example for this item is shown with the ones above: opencv-Detect.salam
DetectedObject
struct DetectedObject| Name | Type | Description |
|---|---|---|
x | int = 0 | x. |
y | int = 0 | y. |
width | int = 0 | The width. |
height | int = 0 | The height. |
The example for this item is shown with the ones above: opencv-Detect.salam
CascadeClassifier
struct CascadeClassifier| Name | Type | Description |
|---|---|---|
handle | void* | The internal handle. |
The example for this item is shown with the ones above: opencv-Detect.salam
ok
func ok(): boolThe example for this item is shown with the ones above: opencv-Detect.salam
detect
func detect(m: Mat, scale_factor: f64, min_neighbors: int, max_results: int): Vector<DetectedObject>The example for this item is shown with the ones above: opencv-Detect.salam
free
func free()The example for this item is shown with the ones above: opencv-Detect.salam
Contours
struct Contours| Name | Type | Description |
|---|---|---|
handle | void* | The internal handle. |
import opencv
func main:
mut scene := opencv.Read("scene_en.jpg")
mut target := opencv.Read("object_en.jpg")
mut contours := scene.to_gray().threshold_otsu(255.0).find_contours()
println contours.ok(), contours.count()
repeat contours.count() in i:
box := contours.bounding_rect(i)
println contours.area(i), contours.point_count(i), contours.point(i, 0).x, box.x, box.y, box.width, box.height
scene.draw_contour(contours, i, opencv.Green(), 2)
end
contours.free()
corners := scene.to_gray().good_features(50, 0.01, 10.0)
println corners.len()
mut keys1 := scene.detect_orb(500)
mut keys2 := target.detect_orb(500)
mut sift := scene.detect_sift(500)
println keys1.ok(), keys1.count(), sift.count()
if keys1.count() > 0:
first := keys1.get(0)
println first.x, first.y, first.size, first.angle, first.response
end
matches := opencv.MatchDescriptors(keys1.descriptors(), keys2.descriptors(), 50, opencv.NORM_HAMMING)
each m in matches:
println m.query_idx, m.train_idx, m.distance
end
println opencv.NORM_L2
keys1.free()
keys2.free()
sift.free()
found := scene.find_template(target)
println found.found, found.x, found.y, found.score
mut quad := Vector {} as Vector<opencv.Point>
quad.push(opencv.Point { x = 0, y = 0 })
quad.push(opencv.Point { x = 400, y = 10 })
quad.push(opencv.Point { x = 410, y = 580 })
quad.push(opencv.Point { x = 5, y = 590 })
flat := scene.warp_perspective(quad, 420, 594)
_ := opencv.Write("document_en.png", flat)
endok
func ok(): boolThe example for this item is shown with the ones above: opencv-Features.salam
count
func count(): intThe example for this item is shown with the ones above: opencv-Features.salam
point_count
func point_count(idx: int): intThe example for this item is shown with the ones above: opencv-Features.salam
point
func point(idx: int, pt_idx: int): PointThe example for this item is shown with the ones above: opencv-Features.salam
area
func area(idx: int): f64The example for this item is shown with the ones above: opencv-Features.salam
bounding_rect
func bounding_rect(idx: int): RectThe example for this item is shown with the ones above: opencv-Features.salam
free
func free()The example for this item is shown with the ones above: opencv-Features.salam
Keypoint
struct Keypoint| Name | Type | Description |
|---|---|---|
x | f64 = 0 | x. |
y | f64 = 0 | y. |
size | f64 = 0 | The size. |
angle | f64 = 0 | The angle. |
response | f64 = 0 | The strength. |
The example for this item is shown with the ones above: opencv-Features.salam
Keypoints
struct Keypoints| Name | Type | Description |
|---|---|---|
handle | void* | The internal handle. |
The example for this item is shown with the ones above: opencv-Features.salam
ok
func ok(): boolThe example for this item is shown with the ones above: opencv-Features.salam
count
func count(): intThe example for this item is shown with the ones above: opencv-Features.salam
get
func get(i: int): KeypointThe example for this item is shown with the ones above: opencv-Features.salam
descriptors
func descriptors(): MatThe example for this item is shown with the ones above: opencv-Features.salam
free
func free()The example for this item is shown with the ones above: opencv-Features.salam
Match
struct Match| Name | Type | Description |
|---|---|---|
query_idx | int = 0 | The index in the first set. |
train_idx | int = 0 | The index in the second set. |
distance | f64 = 0 | The distance; lower means more alike. |
The example for this item is shown with the ones above: opencv-Features.salam
Net
struct Net| Name | Type | Description |
|---|---|---|
handle | void* | The internal handle. |
The example for this item is shown with the ones above: opencv-Detect.salam
ok
func ok(): boolThe example for this item is shown with the ones above: opencv-Detect.salam
set_input
func set_input(image: Mat, scale: f64, mean: Color, swap_rb: bool, size: Size): boolThe example for this item is shown with the ones above: opencv-Detect.salam
forward
func forward(): MatThe example for this item is shown with the ones above: opencv-Detect.salam
forward_layer
func forward_layer(layer_name: str): MatThe example for this item is shown with the ones above: opencv-Detect.salam
free
func free()The example for this item is shown with the ones above: opencv-Detect.salam
Detection
struct Detection| Name | Type | Description |
|---|---|---|
class_id | int = 0 | The class number. |
confidence | f64 = 0 | The confidence. |
x | int = 0 | x. |
y | int = 0 | y. |
width | int = 0 | The width. |
height | int = 0 | The height. |
The example for this item is shown with the ones above: opencv-Features.salam
Mat
struct Mat| Name | Type | Description |
|---|---|---|
handle | void* | The internal handle. |
import opencv
func main:
if not opencv.Available():
println "OpenCV is not available:", opencv.LastError()
ret
end
println opencv.Version()
mut photo := opencv.Read("photo_en.jpg")
if not photo.ok() or photo.empty():
photo = opencv.NewBlank(320, 240, 3, opencv.White())
end
dims := photo.size()
println photo.width(), photo.height(), photo.channels(), dims.width, dims.height, photo.step(), photo.total(), photo.data() != null
color := photo.at(10, 10)
println color.r, color.g, color.b
photo.set_pixel(0, 0, opencv.RGB(255, 128, 0))
black := opencv.Zeros(10, 10, 1)
println black.channels(), opencv.Black().r, opencv.Red().r, opencv.Green().g, opencv.Blue().b
gray := photo.to_gray()
_ := photo.to_rgb()
hsv := photo.to_hsv()
_ := hsv.hsv_to_rgb()
_ := photo.convert_color(opencv.COLOR_BGR2GRAY)
_ := gray.convert_color(opencv.COLOR_GRAY2BGR)
println opencv.COLOR_RGB2GRAY, opencv.COLOR_GRAY2RGB, opencv.COLOR_BGR2RGB, opencv.COLOR_RGB2BGR, opencv.COLOR_BGR2HSV, opencv.COLOR_HSV2BGR, opencv.COLOR_RGB2HSV, opencv.COLOR_HSV2RGB
small := photo.resize(160, 120, opencv.INTERP_AREA)
_ := photo.resize_scale(2.0, 2.0)
_ := photo.crop(10, 10, 100, 80)
_ := photo.rotate90(opencv.ROTATE_90_CW)
_ := photo.rotate(45.0, 1.0)
_ := photo.flip(opencv.FLIP_BOTH)
_ := photo.flip_horizontal()
_ := photo.flip_vertical()
println opencv.INTERP_NEAREST, opencv.INTERP_LINEAR, opencv.INTERP_CUBIC, opencv.INTERP_LANCZOS4, opencv.ROTATE_180, opencv.ROTATE_90_CCW, opencv.FLIP_VERTICAL, opencv.FLIP_HORIZONTAL
copied := small.clone()
println copied.save("small_en.png"), opencv.Write("gray_en.png", gray)
copied.free()
photo.free()
endok
func ok(): boolThe example for this item is shown with the ones above: opencv-Basics.salam
empty
func empty(): boolThe example for this item is shown with the ones above: opencv-Basics.salam
width
func width(): intThe example for this item is shown with the ones above: opencv-Basics.salam
height
func height(): intThe example for this item is shown with the ones above: opencv-Basics.salam
channels
func channels(): intThe example for this item is shown with the ones above: opencv-Basics.salam
size
func size(): SizeThe example for this item is shown with the ones above: opencv-Features.salam
clone
func clone(): MatThe example for this item is shown with the ones above: opencv-Basics.salam
free
func free()The example for this item is shown with the ones above: opencv-Basics.salam
save
func save(path: str): boolThe example for this item is shown with the ones above: opencv-Basics.salam
data
func data(): void*The example for this item is shown with the ones above: opencv-Basics.salam
step
func step(): intThe example for this item is shown with the ones above: opencv-Basics.salam
total
func total(): intThe example for this item is shown with the ones above: opencv-Basics.salam
at
func at(x: int, y: int): ColorThe example for this item is shown with the ones above: opencv-Basics.salam
set_pixel
func set_pixel(x: int, y: int, c: Color)The example for this item is shown with the ones above: opencv-Basics.salam
convert_color
func convert_color(code: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
to_gray
func to_gray(): MatThe example for this item is shown with the ones above: opencv-Basics.salam
to_rgb
func to_rgb(): MatThe example for this item is shown with the ones above: opencv-Basics.salam
to_hsv
func to_hsv(): MatThe example for this item is shown with the ones above: opencv-Basics.salam
hsv_to_rgb
func hsv_to_rgb(): MatThe example for this item is shown with the ones above: opencv-Basics.salam
resize
func resize(width: int, height: int, interpolation: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
resize_scale
func resize_scale(fx: f64, fy: f64): MatThe example for this item is shown with the ones above: opencv-Basics.salam
crop
func crop(x: int, y: int, w: int, h: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
rotate90
func rotate90(code: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
rotate
func rotate(angle_degrees: f64, scale: f64): MatThe example for this item is shown with the ones above: opencv-Basics.salam
flip
func flip(mode: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
flip_horizontal
func flip_horizontal(): MatThe example for this item is shown with the ones above: opencv-Basics.salam
flip_vertical
func flip_vertical(): MatThe example for this item is shown with the ones above: opencv-Basics.salam
blur
func blur(ksize: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
gaussian_blur
func gaussian_blur(ksize: int, sigma: f64): MatThe example for this item is shown with the ones above: opencv-Basics.salam
median_blur
func median_blur(ksize: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
canny
func canny(t1: f64, t2: f64): MatThe example for this item is shown with the ones above: opencv-Basics.salam
threshold
func threshold(thresh: f64, maxval: f64, kind: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
threshold_otsu
func threshold_otsu(maxval: f64): MatThe example for this item is shown with the ones above: opencv-Basics.salam
adaptive_threshold
func adaptive_threshold(maxval: f64, method: int, kind: int, block_size: int, c: f64): MatThe example for this item is shown with the ones above: opencv-Basics.salam
histogram_gray
func histogram_gray(): Vector<int>The example for this item is shown with the ones above: opencv-Basics.salam
line
func line(x1: int, y1: int, x2: int, y2: int, color: Color, thickness: int)The example for this item is shown with the ones above: opencv-Basics.salam
rectangle
func rectangle(x: int, y: int, w: int, h: int, color: Color, thickness: int)The example for this item is shown with the ones above: opencv-Basics.salam
circle
func circle(cx: int, cy: int, radius: int, color: Color, thickness: int)The example for this item is shown with the ones above: opencv-Basics.salam
put_text
func put_text(text: str, x: int, y: int, font_scale: f64, color: Color, thickness: int)The example for this item is shown with the ones above: opencv-Basics.salam
good_features
func good_features(max_corners: int, quality: f64, min_dist: f64): Vector<Point>The example for this item is shown with the ones above: opencv-Basics.salam
detect_orb
func detect_orb(max_features: int): KeypointsThe example for this item is shown with the ones above: opencv-Basics.salam
detect_sift
func detect_sift(max_features: int): KeypointsThe example for this item is shown with the ones above: opencv-Basics.salam
erode
func erode(ksize: int, iterations: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
dilate
func dilate(ksize: int, iterations: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
morphology
func morphology(op: int, ksize: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
blend
func blend(other: Mat, alpha: f64, beta: f64, gamma: f64): MatThe example for this item is shown with the ones above: opencv-Basics.salam
bitwise
func bitwise(other: Mat, op: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
bitwise_not
func bitwise_not(): MatThe example for this item is shown with the ones above: opencv-Basics.salam
abs_diff
func abs_diff(other: Mat): MatThe example for this item is shown with the ones above: opencv-Basics.salam
warp_perspective
func warp_perspective(src: Vector<Point>, out_width: int, out_height: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
find_template
func find_template(template: Mat): TemplateMatchThe example for this item is shown with the ones above: opencv-Basics.salam
ellipse
func ellipse(cx: int, cy: int, axis_width: int, axis_height: int, angle_degrees: f64, color: Color, thickness: int)The example for this item is shown with the ones above: opencv-Basics.salam
polylines
func polylines(pts: Vector<Point>, closed: bool, color: Color, thickness: int)The example for this item is shown with the ones above: opencv-Basics.salam
fill_poly
func fill_poly(pts: Vector<Point>, color: Color)The example for this item is shown with the ones above: opencv-Basics.salam
find_contours
func find_contours(): ContoursThe example for this item is shown with the ones above: opencv-Basics.salam
draw_contour
func draw_contour(cs: Contours, idx: int, color: Color, thickness: int)The example for this item is shown with the ones above: opencv-Basics.salam
TemplateMatch
struct TemplateMatch| Name | Type | Description |
|---|---|---|
found | bool = false | Whether it was found. |
x | int = 0 | x. |
y | int = 0 | y. |
score | f64 = 0 | The match score. |
The example for this item is shown with the ones above: opencv-Features.salam
Size
struct Size| Name | Type | Description |
|---|---|---|
width | int = 0 | The width. |
height | int = 0 | The height. |
The example for this item is shown with the ones above: opencv-Basics.salam
Point
struct Point| Name | Type | Description |
|---|---|---|
x | int = 0 | x. |
y | int = 0 | y. |
import opencv
func main:
mut photo := opencv.Read("photo_en.jpg")
gray := photo.to_gray()
_ := photo.blur(5)
_ := photo.gaussian_blur(5, 1.5)
_ := photo.median_blur(5)
edges := gray.canny(50.0, 150.0)
_ := gray.threshold(128.0, 255.0, opencv.THRESH_BINARY)
_ := gray.threshold_otsu(255.0)
_ := gray.adaptive_threshold(255.0, opencv.ADAPTIVE_GAUSSIAN, opencv.THRESH_BINARY, 11, 2.0)
println opencv.THRESH_BINARY_INV, opencv.THRESH_TRUNC, opencv.THRESH_TOZERO, opencv.THRESH_TOZERO_INV, opencv.THRESH_OTSU, opencv.ADAPTIVE_MEAN
println gray.histogram_gray().len()
_ := edges.erode(3, 1)
_ := edges.dilate(3, 2)
_ := edges.morphology(opencv.MORPH_CLOSE, 5)
println opencv.MORPH_OPEN, opencv.MORPH_GRADIENT, opencv.MORPH_TOPHAT, opencv.MORPH_BLACKHAT
white := opencv.NewBlank(photo.width(), photo.height(), 3, opencv.White())
_ := photo.blend(white, 0.7, 0.3, 0.0)
_ := photo.bitwise(white, opencv.BITWISE_AND)
_ := photo.bitwise(white, opencv.BITWISE_OR)
_ := photo.bitwise(white, opencv.BITWISE_XOR)
_ := photo.bitwise_not()
_ := photo.abs_diff(white)
photo.line(0, 0, 100, 100, opencv.Red(), 2)
photo.rectangle(10, 10, 50, 30, opencv.Green(), 1)
photo.circle(80, 80, 20, opencv.Blue(), -1)
photo.ellipse(100, 50, 40, 20, 30.0, opencv.Black(), 2)
photo.put_text("Salam", 10, 200, 1.0, opencv.White(), 2)
mut points := Vector {} as Vector<opencv.Point>
points.push(opencv.Point { x = 0, y = 0 })
points.push(opencv.Point { x = 50, y = 0 })
points.push(opencv.Point { x = 25, y = 40 })
photo.polylines(points, true, opencv.Red(), 2)
photo.fill_poly(points, opencv.Green())
_ := opencv.Write("filtered_en.png", photo)
endRect
struct Rect| Name | Type | Description |
|---|---|---|
x | int = 0 | x. |
y | int = 0 | y. |
width | int = 0 | The width. |
height | int = 0 | The height. |
The example for this item is shown with the ones above: opencv-Filters.salam
Color
struct Color| Name | Type | Description |
|---|---|---|
r | int = 0 | Red. |
g | int = 0 | Green. |
b | int = 0 | Blue. |
The example for this item is shown with the ones above: opencv-Basics.salam
Constants and variables
COLOR_BGR2GRAY
const COLOR_BGR2GRAY: i32 = 0The example for this item is shown with the ones above: opencv-Basics.salam
COLOR_GRAY2BGR
const COLOR_GRAY2BGR: i32 = 1The example for this item is shown with the ones above: opencv-Basics.salam
COLOR_RGB2GRAY
const COLOR_RGB2GRAY: i32 = 2The example for this item is shown with the ones above: opencv-Basics.salam
COLOR_GRAY2RGB
const COLOR_GRAY2RGB: i32 = 3The example for this item is shown with the ones above: opencv-Basics.salam
COLOR_BGR2RGB
const COLOR_BGR2RGB: i32 = 4The example for this item is shown with the ones above: opencv-Basics.salam
COLOR_RGB2BGR
const COLOR_RGB2BGR: i32 = 5The example for this item is shown with the ones above: opencv-Basics.salam
COLOR_BGR2HSV
const COLOR_BGR2HSV: i32 = 6The example for this item is shown with the ones above: opencv-Basics.salam
COLOR_HSV2BGR
const COLOR_HSV2BGR: i32 = 7The example for this item is shown with the ones above: opencv-Basics.salam
COLOR_RGB2HSV
const COLOR_RGB2HSV: i32 = 8The example for this item is shown with the ones above: opencv-Basics.salam
COLOR_HSV2RGB
const COLOR_HSV2RGB: i32 = 9The example for this item is shown with the ones above: opencv-Basics.salam
THRESH_BINARY
const THRESH_BINARY: i32 = 0The example for this item is shown with the ones above: opencv-Filters.salam
THRESH_BINARY_INV
const THRESH_BINARY_INV: i32 = 1The example for this item is shown with the ones above: opencv-Filters.salam
THRESH_TRUNC
const THRESH_TRUNC: i32 = 2The example for this item is shown with the ones above: opencv-Filters.salam
THRESH_TOZERO
const THRESH_TOZERO: i32 = 3The example for this item is shown with the ones above: opencv-Filters.salam
THRESH_TOZERO_INV
const THRESH_TOZERO_INV: i32 = 4The example for this item is shown with the ones above: opencv-Filters.salam
THRESH_OTSU
const THRESH_OTSU: i32 = 5The example for this item is shown with the ones above: opencv-Filters.salam
ADAPTIVE_MEAN
const ADAPTIVE_MEAN: i32 = 0The example for this item is shown with the ones above: opencv-Filters.salam
ADAPTIVE_GAUSSIAN
const ADAPTIVE_GAUSSIAN: i32 = 1The example for this item is shown with the ones above: opencv-Filters.salam
INTERP_NEAREST
const INTERP_NEAREST: i32 = 0The example for this item is shown with the ones above: opencv-Basics.salam
INTERP_LINEAR
const INTERP_LINEAR: i32 = 1The example for this item is shown with the ones above: opencv-Basics.salam
INTERP_CUBIC
const INTERP_CUBIC: i32 = 2The example for this item is shown with the ones above: opencv-Basics.salam
INTERP_AREA
const INTERP_AREA: i32 = 3The example for this item is shown with the ones above: opencv-Basics.salam
INTERP_LANCZOS4
const INTERP_LANCZOS4: i32 = 4The example for this item is shown with the ones above: opencv-Basics.salam
ROTATE_90_CW
const ROTATE_90_CW: i32 = 0The example for this item is shown with the ones above: opencv-Basics.salam
ROTATE_180
const ROTATE_180: i32 = 1The example for this item is shown with the ones above: opencv-Basics.salam
ROTATE_90_CCW
const ROTATE_90_CCW: i32 = 2The example for this item is shown with the ones above: opencv-Basics.salam
FLIP_VERTICAL
const FLIP_VERTICAL: i32 = 0The example for this item is shown with the ones above: opencv-Basics.salam
FLIP_HORIZONTAL
const FLIP_HORIZONTAL: i32 = 1The example for this item is shown with the ones above: opencv-Basics.salam
FLIP_BOTH
const FLIP_BOTH: i32 = 2The example for this item is shown with the ones above: opencv-Basics.salam
MORPH_OPEN
const MORPH_OPEN: i32 = 0The example for this item is shown with the ones above: opencv-Filters.salam
MORPH_CLOSE
const MORPH_CLOSE: i32 = 1The example for this item is shown with the ones above: opencv-Filters.salam
MORPH_GRADIENT
const MORPH_GRADIENT: i32 = 2The example for this item is shown with the ones above: opencv-Filters.salam
MORPH_TOPHAT
const MORPH_TOPHAT: i32 = 3The example for this item is shown with the ones above: opencv-Filters.salam
MORPH_BLACKHAT
const MORPH_BLACKHAT: i32 = 4The example for this item is shown with the ones above: opencv-Filters.salam
BITWISE_AND
const BITWISE_AND: i32 = 0The example for this item is shown with the ones above: opencv-Filters.salam
BITWISE_OR
const BITWISE_OR: i32 = 1The example for this item is shown with the ones above: opencv-Filters.salam
BITWISE_XOR
const BITWISE_XOR: i32 = 2The example for this item is shown with the ones above: opencv-Filters.salam
NORM_HAMMING
const NORM_HAMMING: i32 = 0The example for this item is shown with the ones above: opencv-Features.salam
NORM_L2
const NORM_L2: i32 = 1The example for this item is shown with the ones above: opencv-Features.salam
Functions
OpenVideo
func OpenVideo(path: str): VideoCaptureThe example for this item is shown with the ones above: opencv-Detect.salam
OpenCamera
func OpenCamera(index: int): VideoCaptureThe example for this item is shown with the ones above: opencv-Detect.salam
NewVideoWriter
func NewVideoWriter(path: str, fourcc: str, fps: f64, width: int, height: int): VideoWriterThe example for this item is shown with the ones above: opencv-Detect.salam
LoadCascade
func LoadCascade(path: str): CascadeClassifierThe example for this item is shown with the ones above: opencv-Detect.salam
MatchDescriptors
func MatchDescriptors(desc1: Mat, desc2: Mat, max_matches: int, norm: int): Vector<Match>The example for this item is shown with the ones above: opencv-Features.salam
LoadNet
func LoadNet(model_path: str, config_path: str): NetThe example for this item is shown with the ones above: opencv-Detect.salam
LoadNetSingleFile
func LoadNetSingleFile(path: str): NetThe example for this item is shown with the ones above: opencv-Detect.salam
ParseSSDDetections
func ParseSSDDetections(output: Mat, img_width: int, img_height: int, confidence_threshold: f64): Vector<Detection>The example for this item is shown with the ones above: opencv-Detect.salam
Imshow
func Imshow(window: str, m: Mat)The example for this item is shown with the ones above: opencv-Detect.salam
WaitKey
func WaitKey(delay_ms: int): intThe example for this item is shown with the ones above: opencv-Detect.salam
DestroyWindow
func DestroyWindow(window: str)The example for this item is shown with the ones above: opencv-Detect.salam
DestroyAllWindows
func DestroyAllWindows()The example for this item is shown with the ones above: opencv-Detect.salam
CreateTrackbar
func CreateTrackbar(name: str, window: str, initial: int, max: int): boolThe example for this item is shown with the ones above: opencv-Detect.salam
GetTrackbarPos
func GetTrackbarPos(name: str, window: str): intThe example for this item is shown with the ones above: opencv-Detect.salam
SetTrackbarPos
func SetTrackbarPos(name: str, window: str, pos: int)The example for this item is shown with the ones above: opencv-Detect.salam
LastError
func LastError(): strThe example for this item is shown with the ones above: opencv-Basics.salam
Available
func Available(): boolThe example for this item is shown with the ones above: opencv-Basics.salam
Version
func Version(): strThe example for this item is shown with the ones above: opencv-Basics.salam
RGB
func RGB(r: int, g: int, b: int): ColorThe example for this item is shown with the ones above: opencv-Basics.salam
Black
func Black(): ColorThe example for this item is shown with the ones above: opencv-Basics.salam
White
func White(): ColorThe example for this item is shown with the ones above: opencv-Basics.salam
Red
func Red(): ColorThe example for this item is shown with the ones above: opencv-Basics.salam
Green
func Green(): ColorThe example for this item is shown with the ones above: opencv-Basics.salam
Blue
func Blue(): ColorThe example for this item is shown with the ones above: opencv-Basics.salam
Read
func Read(path: str): MatThe example for this item is shown with the ones above: opencv-Basics.salam
Write
func Write(path: str, m: Mat): boolThe example for this item is shown with the ones above: opencv-Basics.salam
NewBlank
func NewBlank(width: int, height: int, channels: int, fill: Color): MatThe example for this item is shown with the ones above: opencv-Basics.salam
Zeros
func Zeros(width: int, height: int, channels: int): MatThe example for this item is shown with the ones above: opencv-Basics.salam
FromImage
func FromImage(img: image.Image): MatThe example for this item is shown with the ones above: opencv-Detect.salam
ToImage
func ToImage(m: Mat): image.ImageThe example for this item is shown with the ones above: opencv-Detect.salam