[shotwell/wip/phako/enhanced-faces: 3/136] WIP faces enhancements
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/phako/enhanced-faces: 3/136] WIP faces enhancements
- Date: Thu, 11 Oct 2018 09:55:40 +0000 (UTC)
commit 7640b6e6bc889144d04ba6b68907c4b406ea3a37
Author: NarendraMA <narendra_m_a yahoo com>
Date: Fri Jun 22 14:23:38 2018 +0530
WIP faces enhancements
.gitignore | 84 +++
facedetect/shotwell-facedetect.cpp | 38 +-
src/AppDirs.vala | 3 +-
src/faces/FacesTool.vala | 19 +-
src/faces_opencv/faces_opencv.cpp | 80 +++
src/faces_opencv/faces_opencv.h | 18 +
src/faces_opencv/meson.build | 9 +
src/meson.build | 16 +-
vapi/faces.vapi | 38 ++
vapi/opencv.vapi | 1116 ++++++++++++++++++++++++++++++++++++
10 files changed, 1392 insertions(+), 29 deletions(-)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..fcea052f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,84 @@
+
+# Hide sublime text stuff
+*.sublime-project
+*.sublime-workspace
+
+# Hide some OS X stuff
+.DS_Store
+.AppleDouble
+.LSOverride
+Icon
+
+# Thumbnails
+._*
+
+.idea
+
+# pytest
+.cache
+
+# GITHUB Proposed Python stuff:
+*.py[cod]
+
+# C extensions
+*.so
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+eggs
+.eggs
+parts
+bin
+var
+sdist
+develop-eggs
+.installed.cfg
+lib
+lib64
+
+# Logs
+*.log
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+nosetests.xml
+
+# Translations
+*.mo
+
+# Mr Developer
+.mr.developer.cfg
+.project
+.pydevproject
+
+.python-version
+
+# emacs auto backups
+*~
+*#
+*.orig
+
+# venv stuff
+pyvenv.cfg
+pip-selfcheck.json
+venv
+.venv
+
+# vimmy stuff
+*.swp
+*.swo
+
+ctags.tmp
+
+# vagrant stuff
+virtualization/vagrant/setup_done
+virtualization/vagrant/.vagrant
+virtualization/vagrant/config
+
+# Visual Studio Code
+.vscode
diff --git a/facedetect/shotwell-facedetect.cpp b/facedetect/shotwell-facedetect.cpp
index 1b093797..378a9059 100644
--- a/facedetect/shotwell-facedetect.cpp
+++ b/facedetect/shotwell-facedetect.cpp
@@ -32,31 +32,31 @@ void help() {
}
void detectFaces(Mat &img, CascadeClassifier &cascade, double scale) {
+ UMat uimg, gray;
+ img.copyTo(uimg);
+ cvtColor(uimg, gray, CV_BGR2GRAY);
- Mat gray;
- cvtColor(img, gray, CV_BGR2GRAY);
+ UMat smallImg(cvRound(img.rows / scale), cvRound(img.cols / scale), CV_8UC1);
+ Size smallImgSize = smallImg.size();
- Mat smallImg(cvRound(img.rows / scale), cvRound(img.cols / scale), CV_8UC1);
- Size smallImgSize = smallImg.size();
+ resize(gray, smallImg, smallImgSize, 0, 0, INTER_LINEAR);
+ equalizeHist(smallImg, smallImg);
- resize(gray, smallImg, smallImgSize, 0, 0, INTER_LINEAR);
- equalizeHist(smallImg, smallImg);
+ vector<Rect> faces;
+ cascade.detectMultiScale(smallImg, faces, 1.1, 2, CV_HAAR_SCALE_IMAGE, Size(30, 30));
- vector<Rect> faces;
- cascade.detectMultiScale(smallImg, faces, 1.1, 2, CV_HAAR_SCALE_IMAGE, Size(30, 30));
+ int i = 0;
+ for (vector<Rect>::const_iterator r = faces.begin(); r != faces.end(); r++, i++) {
- int i = 0;
- for (vector<Rect>::const_iterator r = faces.begin(); r != faces.end(); r++, i++) {
+ printf(
+ "face;x=%f&y=%f&width=%f&height=%f\n",
+ (float) r->x / smallImgSize.width,
+ (float) r->y / smallImgSize.height,
+ (float) r->width / smallImgSize.width,
+ (float) r->height / smallImgSize.height
+ );
- printf(
- "face;x=%f&y=%f&width=%f&height=%f\n",
- (float) r->x / smallImgSize.width,
- (float) r->y / smallImgSize.height,
- (float) r->width / smallImgSize.width,
- (float) r->height / smallImgSize.height
- );
-
- }
+ }
}
diff --git a/src/AppDirs.vala b/src/AppDirs.vala
index 74b045f1..1515f05a 100644
--- a/src/AppDirs.vala
+++ b/src/AppDirs.vala
@@ -330,6 +330,7 @@ class AppDirs {
}
#if ENABLE_FACES
+/*
public static File get_facedetect_bin() {
const string filename = "shotwell-facedetect";
File f = AppDirs.get_libexec_dir().get_parent().get_child("facedetect").get_child (filename);
@@ -338,7 +339,7 @@ class AppDirs {
}
return f;
}
-
+ */
public static File get_haarcascade_file() {
File f =
File.new_for_path(AppDirs.get_exec_dir().get_parent().get_parent().get_child("facedetect").get_child("facedetect-haarcascade.xml").get_path());
if (f.query_exists()) {//testing meson builddir
diff --git a/src/faces/FacesTool.vala b/src/faces/FacesTool.vala
index cf53736d..7ff3e52c 100644
--- a/src/faces/FacesTool.vala
+++ b/src/faces/FacesTool.vala
@@ -314,7 +314,7 @@ public class FacesTool : EditingTools.EditingTool {
private class FaceDetectionJob : BackgroundJob {
private Gee.Queue<string> faces = null;
private string image_path;
- private string output;
+ //private string output;
public SpawnError? spawnError;
public FaceDetectionJob(FacesToolWindow owner, string image_path,
@@ -326,7 +326,18 @@ public class FacesTool : EditingTools.EditingTool {
}
public override void execute() {
- try {
+ Faces.FaceRect[] rects;
+ debug("checking faces");
+ Faces.detect_faces(image_path, AppDirs.get_haarcascade_file().get_path(), 4, out rects);
+ faces = new Gee.PriorityQueue<string>();
+ string serialized = "%s;%s".printf(
+ FaceRectangle.SHAPE_TYPE,
+ parse_serialized_geometry("x=%s&y=%s&width=%s&height=%s".printf(
+ rects[0].x.to_string(), rects[0].y.to_string(), rects[0].width.to_string(),
rects[0].height.to_string())));
+ debug("saw face %s", serialized);
+ faces.add(serialized);
+
+ /* try {
string[] argv = {
AppDirs.get_facedetect_bin().get_path(),
"--cascade=" + AppDirs.get_haarcascade_file().get_path(),
@@ -342,7 +353,6 @@ public class FacesTool : EditingTools.EditingTool {
return;
}
- faces = new Gee.PriorityQueue<string>();
string[] lines = output.split("\n");
foreach (string line in lines) {
if (line.length == 0)
@@ -375,7 +385,7 @@ public class FacesTool : EditingTools.EditingTool {
default:
assert_not_reached();
}
- }
+ } */
}
private string parse_serialized_geometry(string serialized_geometry) {
@@ -905,7 +915,6 @@ public class FacesTool : EditingTools.EditingTool {
private void detect_faces() {
faces_tool_window.detection_button.set_sensitive(false);
faces_tool_window.set_editing_phase(EditingPhase.DETECTING_FACES);
-
workers.enqueue(face_detection);
}
diff --git a/src/faces_opencv/faces_opencv.cpp b/src/faces_opencv/faces_opencv.cpp
new file mode 100644
index 00000000..dc04c1d3
--- /dev/null
+++ b/src/faces_opencv/faces_opencv.cpp
@@ -0,0 +1,80 @@
+/* Copyright 2016 Software Freedom Conservancy Inc.
+ *
+ * Copyright 2011 ValentÃn Barros Puertas <valentin(at)sanva(dot)net>
+ * Copyright 2018 Ricardo Fantin da Costa <ricardofantin(at)gmail(dot)com>
+ * Copyright 2018 Narendra Acharya <narendra_m_a(at)yahoo(dot)com>
+ *
+ * This software is licensed under the GNU LGPL (version 2.1 or later).
+ * See the COPYING file in this distribution.
+ */
+
+#include "opencv2/objdetect/objdetect.hpp"
+#include "opencv2/highgui/highgui.hpp"
+#include "opencv2/imgproc/imgproc.hpp"
+extern "C" {
+#include "faces_opencv.h"
+}
+#include <iostream>
+#include <stdio.h>
+
+using namespace std;
+using namespace cv;
+
+// OpenCV calls in C++
+vector<FaceRect> ocvDetectFaces(Mat &img, CascadeClassifier &cascade, double scale) {
+ Mat gray;
+ cvtColor(img, gray, CV_BGR2GRAY);
+
+ Mat smallImg(cvRound(img.rows / scale), cvRound(img.cols / scale), CV_8UC1);
+ Size smallImgSize = smallImg.size();
+
+ resize(gray, smallImg, smallImgSize, 0, 0, INTER_LINEAR);
+ equalizeHist(smallImg, smallImg);
+
+ vector<Rect> faces;
+ cascade.detectMultiScale(smallImg, faces, 1.1, 2, CV_HAAR_SCALE_IMAGE, Size(30, 30));
+ vector<FaceRect> ret;
+ for (vector<Rect>::const_iterator r = faces.begin(); r != faces.end(); r++) {
+ FaceRect rect;
+ rect.x = ((float)r->x / smallImgSize.width);
+ rect.y = ((float)r->y / smallImgSize.height);
+ rect.width = ((float)r->width / smallImgSize.width);
+ rect.height = ((float)r->height / smallImgSize.height);
+ ret.push_back(rect);
+ }
+
+ return ret;
+}
+
+// Exported interface to C with simple operands
+extern "C" {
+ int detectFaces(const char *inputName, const char *cascadeName, double scale,
+ FaceRect **rects, int *numFaces) {
+ CascadeClassifier cascade;
+
+ *numFaces = 0; // Zero length array
+ if (!cascade.load(cascadeName)) {
+ cout << "error;Could not load classifier cascade. Filename: \"" << cascadeName << "\"" << endl;
+ return -1;
+ }
+
+ Mat image = imread(inputName, 1);
+ if (image.empty()) {
+ cout << "error;Could not load the file to process. Filename: \"" << inputName << "\"" << endl;
+ return -1;
+ }
+
+ vector<FaceRect> faces;
+ faces = ocvDetectFaces(image, cascade, scale);
+ *rects = (FaceRect *)malloc(sizeof(FaceRect) * faces.size());
+
+ int i = 0;
+ for (vector<FaceRect>::const_iterator r = faces.begin(); r != faces.end(); r++, i++) {
+ (*rects)[i].x = r->x; (*rects)[i].y = r->y;
+ (*rects)[i].width = r->width; (*rects)[i].height = r->height;
+ }
+ *numFaces = i;
+
+ return 0;
+ }
+}
diff --git a/src/faces_opencv/faces_opencv.h b/src/faces_opencv/faces_opencv.h
new file mode 100644
index 00000000..16284c55
--- /dev/null
+++ b/src/faces_opencv/faces_opencv.h
@@ -0,0 +1,18 @@
+/* Copyright 2016 Software Freedom Conservancy Inc.
+ *
+ * Copyright 2018 Narendra Acharya <narendra_m_a(at)yahoo(dot)com>
+ *
+ * This software is licensed under the GNU LGPL (version 2.1 or later).
+ * See the COPYING file in this distribution.
+ */
+
+typedef struct {
+ float x;
+ float y;
+ float width;
+ float height;
+} FaceRect;
+
+int detectFaces(const char *inputName, const char *cascadeName, double scale,
+ FaceRect **rects, int *numFaces);
+
diff --git a/src/faces_opencv/meson.build b/src/faces_opencv/meson.build
new file mode 100644
index 00000000..da43f8a5
--- /dev/null
+++ b/src/faces_opencv/meson.build
@@ -0,0 +1,9 @@
+subproject = ('faces_opencv')
+add_languages('cpp')
+opencv_dep = dependency('opencv', version : ['>= 2.3.0'], required : true)
+
+faces_lib = shared_library('faces_opencv',
+ 'faces_opencv.cpp',
+ dependencies : opencv_dep)
+faces_vapi = meson.get_compiler('vala').find_library('faces', dirs: join_paths(meson.source_root(), 'vapi'))
+faces_dep = declare_dependency(dependencies: [opencv_dep, faces_vapi])
diff --git a/src/meson.build b/src/meson.build
index c452a986..b537438e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -17,8 +17,17 @@ processor = executable('shotwell-graphics-processor',
dependencies: [gio, gdk, gee],
link_with: sw_graphics_processor)
+shotwell_deps = [gio, gee, sqlite, gtk, sqlite, posix, gphoto2,
+ gstreamer_pbu, gio_unix, gudev, gexiv2, gmodule,
+ libraw, libexif, sw_plugin]
+
+shotwell_libs = [sw_graphics_processor]
+
face_sources = []
+face_obj = ''
+
if get_option('face-detection')
+ subdir('faces_opencv')
face_sources = (['faces/FacesBranch.vala',
'faces/FaceLocation.vala',
'faces/FacePage.vala',
@@ -28,11 +37,10 @@ if get_option('face-detection')
'db/FaceLocationTable.vala',
'db/FaceTable.vala',
'faces/FacesTool.vala'])
+ shotwell_deps += [faces_dep]
+ shotwell_libs += [faces_lib]
endif
-shotwell_deps = [gio, gee, sqlite, gtk, sqlite, posix, gphoto2,
- gstreamer_pbu, gio_unix, gudev, gexiv2, gmodule,
- libraw, libexif, sw_plugin]
if unity_available
shotwell_deps += [unity]
endif
@@ -249,5 +257,5 @@ executable('shotwell',
join_paths(meson.source_root(),
'org.gnome.Shotwell.gresource.xml')
],
- link_with: [sw_graphics_processor],
+ link_with: shotwell_libs,
install : true)
diff --git a/vapi/faces.vapi b/vapi/faces.vapi
new file mode 100644
index 00000000..7e0a51b2
--- /dev/null
+++ b/vapi/faces.vapi
@@ -0,0 +1,38 @@
+/**
+ * Face detection and recognition functions
+ * Copyright 2018 Narendra A (narendra_m_a(at)yahoo(dot)com)
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+[CCode (cheader_filename = "faces_opencv/faces_opencv.h")]
+namespace Faces {
+ [SimpleType, CCode (cname = "FaceRect", has_type_id = false, destroy_function = "")]
+ public struct FaceRect {
+ public float x;
+ public float y;
+ public float width;
+ public float height;
+ }
+
+ [CCode (cname = "detectFaces", free_function = "free")]
+ public int detect_faces(string inputName, string cascadeName, double scale, out FaceRect[] rects);
+}
diff --git a/vapi/opencv.vapi b/vapi/opencv.vapi
new file mode 100644
index 00000000..b811f4a5
--- /dev/null
+++ b/vapi/opencv.vapi
@@ -0,0 +1,1116 @@
+/**
+ * OpenCV Vala Bindings
+ * Copyright 2010 Evan Nemerson <evan coeus-group com>
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* Status:
+ * Core is mostly done, as is HighGUI. Auxiliary is almost
+ * completely unbound. I'm not sure when, or if, I will have time to
+ * finish these.
+ */
+
+[CCode (cheader_filename = "cv.h", cprefix = "Cv", lower_case_cprefix = "cv")]
+namespace OpenCV {
+ [Compact, CCode (cname = "CvArr", has_type_id = false)]
+ public class Array {
+ [CCode (cname = "cvGetCol")]
+ public OpenCV.Matrix get_col (OpenCV.Matrix submat, int col);
+ [CCode (cname = "cvGetCols")]
+ public OpenCV.Matrix get_cols (OpenCV.Matrix submat, int start_col, int end_col);
+ [CCode (cname = "cvGetDiag")]
+ public OpenCV.Matrix get_diagonal (OpenCV.Matrix submat, int diag = 0);
+ [CCode (cname = "cvGetDimSize")]
+ public int get_dimension_size (int index);
+ [CCode (cname = "cvGetDims")]
+ public int get_dimensions (int[]? sizes = null);
+ [CCode (cname = "cvGetElemType")]
+ public OpenCV.Type get_elem_type ();
+ [CCode (cname = "cvGetImage")]
+ public OpenCV.IPL.Image get_image (OpenCV.IPL.Image header);
+ [CCode (cname = "cvGetMat")]
+ public OpenCV.Matrix get_matrix (OpenCV.Matrix header, int[]? coi = null, int allowND = 0);
+ [CCode (cname = "cvGetRow")]
+ public OpenCV.Matrix get_row (OpenCV.Matrix submat, int row);
+ [CCode (cname = "cvGetRows")]
+ public OpenCV.Matrix get_rows (OpenCV.Matrix submat, int start_row, int end_Row, int
delta_row = 1);
+ [CCode (cname = "cvGetSubRect")]
+ public OpenCV.Matrix get_subrectangle (OpenCV.Matrix submat, OpenCV.Rectangle rect);
+
+ [CCode (cname = "cvAdd")]
+ public void add (OpenCV.Array src2, OpenCV.Array dst, OpenCV.Array? mask = null);
+ [CCode (cname = "cvAddS")]
+ public void add_scalar (OpenCV.Scalar value, OpenCV.Array dst, OpenCV.Array? mask = null);
+ [CCode (cname = "cvSub")]
+ public void subtract (OpenCV.Array src2, OpenCV.Array dst, OpenCV.Array? mask = null);
+ [CCode (cname = "cvSubS")]
+ public void subtract_scalar (OpenCV.Scalar value, OpenCV.Array dst, OpenCV.Array? mask =
null);
+ [CCode (cname = "cvSubRS")] // what is "R"? "subtract_r_scalar" sucks
+ public void subtract_r_scalar (OpenCV.Scalar value, OpenCV.Array dst, OpenCV.Array? mask =
null);
+ [CCode (cname = "cvMul")]
+ public void multiply (OpenCV.Array src2, OpenCV.Array dst, double scale = 1.0);
+ [CCode (cname = "cvDiv")]
+ public void divide (OpenCV.Array src2, OpenCV.Array dst, double scale = 1.0);
+ [CCode (cname = "cvScaleAdd")]
+ public void scale_add (OpenCV.Scalar scale, OpenCV.Array src2, OpenCV.Array dst);
+ [CCode (cname = "cvAddWeighted")]
+ public void add_weighted (double alpha, OpenCV.Array src2, double beta, double gamma,
OpenCV.Array dst);
+ [CCode (cname = "cvDotProduct")]
+ public double dot_product (OpenCV.Array src2);
+ [CCode (cname = "cvAnd")]
+ public void and (OpenCV.Array src2, OpenCV.Array dst, OpenCV.Array? mask = null);
+ [CCode (cname = "cvAndS")]
+ public void and_scalar (OpenCV.Scalar value, OpenCV.Array dst, OpenCV.Array? mask = null);
+ [CCode (cname = "cvOr")]
+ public void or (OpenCV.Array src2, OpenCV.Array dst, OpenCV.Array? mask = null);
+ [CCode (cname = "cvOrS")]
+ public void or_scalar (OpenCV.Scalar value, OpenCV.Array dst, OpenCV.Array? mask = null);
+ [CCode (cname = "cvXor")]
+ public void xor (OpenCV.Array src2, OpenCV.Array dst, OpenCV.Array? mask = null);
+ [CCode (cname = "cvXorS")]
+ public void xor_scalar (OpenCV.Scalar value, OpenCV.Array dst, OpenCV.Array? mask = null);
+ [CCode (cname = "cvNot")]
+ public void not (OpenCV.Array dst);
+ [CCode (cname = "cvInRange")]
+ public void in_range (OpenCV.Array lower, OpenCV.Array upper, OpenCV.Array dst);
+ [CCode (cname = "cvInRangeS")]
+ public void in_range_scalar (OpenCV.Scalar lower, OpenCV.Scalar upper, OpenCV.Array dst);
+ [CCode (cname = "cvCmp")]
+ public void compare (OpenCV.Array src2, OpenCV.Array dst, OpenCV.ComparisonOperator cmp_op =
OpenCV.ComparisonOperator.EQUAL);
+ [CCode (cname = "cvCmpS")]
+ public void compare_scalar (double value, OpenCV.Array dst, OpenCV.ComparisonOperator cmp_op
= OpenCV.ComparisonOperator.EQUAL);
+ [CCode (cname = "cvMin")]
+ public void min (OpenCV.Array src2, OpenCV.Array dst);
+ [CCode (cname = "cvMax")]
+ public void max (OpenCV.Array src2, OpenCV.Array dst);
+ [CCode (cname = "cvMinS")]
+ public void min_scalar (double value, OpenCV.Array dst);
+ [CCode (cname = "cvMaxS")]
+ public void max_scalar (double value, OpenCV.Array dst);
+ [CCode (cname = "cvAbsDiff")]
+ public void abs_diff (OpenCV.Array src2, OpenCV.Array dst);
+ [CCode (cname = "cvAbsDiffS")]
+ public void abs_diff_scalar (OpenCV.Array dst, OpenCV.Scalar value);
+ [CCode (cname = "cvAbs")]
+ public void abs (OpenCV.Array dst);
+
+ [CCode (cname = "cvCartToPolar")]
+ public static void cartesian_to_polar (OpenCV.Array x, OpenCV.Array y, OpenCV.Array
magnitude, OpenCV.Array? angle = null, int angle_in_degrees = 0);
+ [CCode (cname = "cvPolarToCart")]
+ public static void polar_to_cartesian (OpenCV.Array magnitude, OpenCV.Array angle,
OpenCV.Array x, OpenCV.Array y, int angle_in_degress = 0);
+ [CCode (cname = "cvPow")]
+ public void pow (OpenCV.Array dst, double power);
+ [CCode (cname = "cvExp")]
+ public void exp (OpenCV.Array dst);
+ [CCode (cname = "cv")]
+ public void log (OpenCV.Array dst);
+ [CCode (cname = "cvCheckArr")]
+ public int check_array (OpenCV.Check flags = 0, double min_val = 0.0, double max_val = 0.0);
+ [CCode (cname = "cvSort")]
+ public void sort (OpenCV.Array? dst = null, OpenCV.Array? idxmat = null, OpenCV.Sort flags =
OpenCV.Sort.EVERY_ROW | OpenCV.Sort.ASCENDING);
+ [CCode (cname = "cvCrossProduct")]
+ public void cross_product (OpenCV.Array src2, OpenCV.Array dst);
+ [CCode (cname = "cvMatMulAdd")]
+ public void matrix_multiply_add (OpenCV.Array src2, OpenCV.Array? src3, OpenCV.Array dst);
+ [CCode (cname = "cvMatMul")]
+ public void matrix_multiply (OpenCV.Array src2, OpenCV.Array dst);
+ [CCode (cname = "cvGEMM")]
+ public void GEMM (OpenCV.Array src2, double alpha, OpenCV.Array src3, double beta,
OpenCV.Array dst, OpenCV.GEMMTranspose tABC = 0);
+ [CCode (cname = "cvTransform")]
+ public void transform (OpenCV.Array dst, OpenCV.Matrix transmat, OpenCV.Matrix? shiftvec =
null);
+ [CCode (cname = "cvPerspectiveTransform")]
+ public void perspective_transform (OpenCV.Array dst, OpenCV.Matrix mat);
+ [CCode (cname = "cvMulTransposed")]
+ public void multiply_transposed (OpenCV.Array dst, int order, OpenCV.Array? delta = null,
double scale = 1.0);
+ [CCode (cname = "cvTranspose")]
+ public void transpose (OpenCV.Array? dst = null);
+ [CCode (cname = "cvFlip")]
+ public void flip (OpenCV.Array? dst = null, OpenCV.FlipMode flip_mode =
OpenCV.FlipMode.HORIZONTAL);
+ [CCode (cname = "cvSVD")]
+ public void SVD (OpenCV.Array w, OpenCV.Array? u = null, OpenCV.Array? v = null,
OpenCV.SVDFlag flags = 0);
+ [CCode (cname = "cvSVBkSb")]
+ public static void SVBkSb (OpenCV.Array W, OpenCV.Array U, OpenCV.Array V, OpenCV.Array B,
OpenCV.Array X, OpenCV.SVDFlag flags = 0);
+
+ [CCode (cname = "cvLine")]
+ public void line (OpenCV.Point pt1, OpenCV.Point pt2, OpenCV.Scalar color, int thickness = 1);
+ [CCode (cname = "cvRectangle")]
+ public void rectangle (OpenCV.Point pt1, OpenCV.Point pt2, OpenCV.Scalar color, int thickness
= 1, int line_type = 8, int shift = 0);
+ [CCode (cname = "cvCircle")]
+ public void circle (OpenCV.Point center, int radius, OpenCV.Scalar color, int thickness = 1,
int line_type = 8, int shift = 0);
+ [CCode (cname = "cvEllipse")]
+ public void ellipse (OpenCV.Point center, OpenCV.Size axes, double angle, double start_angle,
double end_angle, OpenCV.Scalar color, int thickness = 1);
+ [CCode (cname = "cvEllipseBox")]
+ public void ellipse_box (OpenCV.Box2D box, OpenCV.Scalar color, int thickness = 1, int
line_type = 8, int shift = 0);
+ [CCode (cname = "cvFillConvexPoly")]
+ public void fill_convex_polygon (OpenCV.Point[] pts, OpenCV.Scalar color, int line_type = 8,
int shift = 0);
+ [CCode (cname = "cvFillPoly")]
+ public void fill_polygon ([CCode (array_length = false)] OpenCV.Point[][] pts, [CCode
(array_length = false)] int[] npts, int contours, OpenCV.Scalar color, int line_type = 8, int shift = 0);
+ [CCode (cname = "cvPolyLine")]
+ public void poly_line ([CCode (array_length = false)] OpenCV.Point[][] pts, [CCode
(array_length = false)] int[] npts, int contours, int is_closed, OpenCV.Scalar color, int thickness = 1, int
line_type = 8, int shift = 0);
+ [CCode (cname = "cvSegmentImage", cheader_filename = "cvaux.h")]
+ public OpenCV.Sequence segment_image (OpenCV.Array dstarr, double canny_threshhold, double
ffill_threshhold, OpenCV.Memory.Storage storage);
+ [CCode (cname = "cvConvert")]
+ public void convert (OpenCV.Array dst);
+ }
+
+ [SimpleType, CCode (cname = "CvBox2D", has_type_id = false)]
+ public struct Box2D {
+ public OpenCV.Point2D32f center;
+ public OpenCV.Size2D32f size;
+ public float angle;
+ }
+
+ [Flags, CCode (cname = "int", has_type_id = false, lower_case_cprefix = "CV_CHECK_")]
+ public enum Check {
+ RANGE,
+ QUIET
+ }
+
+ [CCode (cname = "int", has_type_id = false, lower_case_cprefix = "CV_CMP_")]
+ public enum ComparisonOperator {
+ EQ,
+ GT,
+ GE,
+ LT,
+ LE,
+ NE,
+
+ [CCode (cname = "CV_CMP_EQ")]
+ EQUAL,
+ [CCode (cname = "CV_CMP_GT")]
+ GREATER_THAN,
+ [CCode (cname = "CV_CMP_GE")]
+ GRATER_THAN_OR_EQUAL,
+ [CCode (cname = "CV_CMP_LT")]
+ LESS_THAN,
+ [CCode (cname = "CV_CMP_LE")]
+ LESS_THAN_OR_EQUAL,
+ [CCode (cname = "CV_CMP_NE")]
+ NOT_EQUAL
+ }
+
+ [Compact, CCode (cname = "CvEHMM", cheader_filename = "cvaux.h", free_function = "cvRelease2DHMM",
free_function_address_of = true)]
+ public class EHMM {
+ [CCode (cname = "cvCreate2DHMM")]
+ public EHMM.2D ([CCode (array_length = false)] int[] stateNumber, [CCode (array_length =
false)] int[] numMix, int obsSize);
+
+ [CCode (cname = "cvUniformImgSegm", instance_pos = -1)]
+ public void uniform_image_segment (OpenCV.EHMM.ImageObservationInfo obs);
+ [CCode (cname = "cvInitMixSegm", instance_pos = -1)]
+ public void init_mix_segment (OpenCV.EHMM.ImageObservationInfo[] obs_info_array);
+ [CCode (cname = "cvEstimateHMMStateParams", instance_pos = -1)]
+ public void estimate_state_params (OpenCV.EHMM.ImageObservationInfo[] obs_info_array);
+ [CCode (cname = "cvEstimateTransProb", instance_pos = -1)]
+ public void estimate_transition_probability (OpenCV.EHMM.ImageObservationInfo[]
obs_info_array);
+ [CCode (cname = "cvEstimateObsProb", instance_pos = -1)]
+ public void estimate_observation_probability (OpenCV.EHMM.ImageObservationInfo obs_info);
+ [CCode (cname = "cvEViterbi", instance_pos = -1)]
+ public void viterbi (OpenCV.EHMM.ImageObservationInfo obs_info);
+ [CCode (cname = "cvMixSegmL2", instance_pos = -1)]
+ public void mix_segm_l2 (OpenCV.EHMM.ImageObservationInfo[] obs_info_array);
+
+ public int level;
+ [CCode (array_length_cname = "num_states")]
+ public float[] transP;
+ [CCode (array_length = false)]
+ public float[][] obsProb;
+ public OpenCV.EHMM.StateInfo u;
+
+ [Compact, CCode (cname = "CvEHMMState")]
+ public class State {
+ [CCode (array_length_cname = "num_mix")]
+ public float[] mu;
+ [CCode (array_length_cname = "num_mix")]
+ public float[] inv_var;
+ [CCode (array_length_cname = "num_mix")]
+ public float[] log_var_val;
+ [CCode (array_length_cname = "num_mix")]
+ public float[] weight;
+ }
+
+ public struct StateInfo {
+ public OpenCV.EHMM.State state;
+ public OpenCV.EHMM ehmm;
+ }
+
+ [Compact, CCode (cname = "CvImgObsInfo", free_function = "cvReleaseObsInfo",
free_function_address_of = true)]
+ public class ImageObservationInfo {
+ public ImageObservationInfo (OpenCV.Size numObs, int obsSize);
+
+ // [CCode (cname = "CV_COUNT_OBS", instance_pos = -1)]
+ // public void count (roi, win, delta);
+ }
+ }
+
+ [CCode (cname = "int", has_type_id = false)]
+ public enum FlipMode {
+ [CCode (cname = "0")]
+ HORIZONTAL,
+ [CCode (cname = "1")]
+ VERTICAL,
+ [CCode (cname = "-1")]
+ BOTH
+ }
+
+ [CCode (cname = "int", has_type_id = false, cprefix = "CV_FONT_")]
+ public enum FontFace {
+ HERSHEY_SIMPLEX,
+ HERSHEY_PLAIN,
+ HERSHEY_DUPLEX,
+ HERSHEY_COMPLEX,
+ HERSHEY_TRIPLEX,
+ HERSHEY_COMPLEX_SMALL,
+ HERSHEY_SCRIPT_SIMPLEX,
+ HERSHEY_SCRIPT_COMPLEX,
+ ITALIC,
+ VECTOR0
+ }
+
+ [Flags, CCode (cname = "int", has_type_id = false)]
+ public enum GEMMTranspose {
+ [CCode (cname = "CV_GEMM_A_T")]
+ A,
+ [CCode (cname = "CV_GEMM_B_T")]
+ B,
+ [CCode (cname = "CV_GEMM_C_T")]
+ C
+ }
+
+ [CCode (cname = "CvLineIterator", has_type_id = false)]
+ public struct LineIterator {
+ [CCode (cname = "cvInitLineIterator")]
+ public LineIterator (OpenCV.Array image, OpenCV.Point pt1, OpenCV.Point pt2, int connectivity
= 8, int left_to_right = 0);
+
+ public int err;
+ public int plus_delta;
+ public int minus_delta;
+ public int plus_step;
+ public int minus_step;
+ }
+
+ [Flags, CCode (cname = "int", has_type_id = false, lower_case_cprefix = "CV_SORT_")]
+ public enum Sort {
+ EVERY_ROW,
+ EVERY_COLUMN,
+ ASCENDING,
+ DESCENDING
+ }
+
+ [Flags, CCode (cname = "int", has_type_id = false, lower_case_cprefix = "CV_SVD_")]
+ public enum SVDFlag {
+ MODIFY_A,
+ U_T,
+ V_T
+ }
+
+ [CCode (cname = "int", has_type_id = false)]
+ public enum Type {
+ [CCode (cname = "CV_8U")]
+ U8,
+ [CCode (cname = "CV_8S")]
+ S8,
+ [CCode (cname = "CV_16U")]
+ U16,
+ [CCode (cname = "CV_16S")]
+ S16,
+ [CCode (cname = "CV_32S")]
+ S32,
+ [CCode (cname = "CV_32F")]
+ F32,
+ [CCode (cname = "CV_64F")]
+ F64,
+ [CCode (cname = "CV_USRTYPE1")]
+ USR1,
+
+ [CCode (cname = "CV_CV_8UC1")]
+ UC8_1,
+ [CCode (cname = "CV_8UC2")]
+ UC8_2,
+ [CCode (cname = "CV_8UC3")]
+ UC8_3,
+ [CCode (cname = "CV_8UC4")]
+ UC8_4,
+
+ [CCode (cname = "CV_8SC1")]
+ SC8_1,
+ [CCode (cname = "CV_8SC2")]
+ SC8_2,
+ [CCode (cname = "CV_8SC3")]
+ SC8_3,
+ [CCode (cname = "CV_8SC4")]
+ SC8_4,
+
+ [CCode (cname = "CV_16UC1")]
+ UC16_1,
+ [CCode (cname = "CV_16UC2")]
+ UC16_2,
+ [CCode (cname = "CV_16UC3")]
+ UC16_3,
+ [CCode (cname = "CV_16UC4")]
+ UC16_4,
+
+ [CCode (cname = "CV_16SC1")]
+ SC16_1,
+ [CCode (cname = "CV_16SC2")]
+ SC16_2,
+ [CCode (cname = "CV_16SC3")]
+ SC16_3,
+ [CCode (cname = "CV_16SC4")]
+ SC16_4,
+
+ [CCode (cname = "CV_32SC1")]
+ SC32_1,
+ [CCode (cname = "CV_32SC2")]
+ SC32_2,
+ [CCode (cname = "CV_32SC3")]
+ SC32_3,
+ [CCode (cname = "CV_32SC4")]
+ SC32_4,
+
+ [CCode (cname = "CV_32FC1")]
+ FC32_1,
+ [CCode (cname = "CV_32FC2")]
+ FC32_2,
+ [CCode (cname = "CV_32FC3")]
+ FC32_3,
+ [CCode (cname = "CV_32FC4")]
+ FC32_4,
+
+ [CCode (cname = "CV_64FC1")]
+ FC64_1,
+ [CCode (cname = "CV_64FC2")]
+ FC64_2,
+ [CCode (cname = "CV_64FC3")]
+ FC64_3,
+ [CCode (cname = "CV_64FC4")]
+ FC64_4
+ }
+
+ [CCode (cname = "CvFont", has_type_id = false, destroy_function = "", has_copy_function = false)]
+ public struct Font {
+ [CCode (cname = "cvInitFont")]
+ public Font (OpenCV.FontFace font_face, double hscale, double vscale, double shear = 0.0, int
thickness = 1, int line_type = 8);
+
+ [CCode (cname = "cvGetTextSize", instance_pos = 1.9)]
+ public void get_text_size (string text_string, out OpenCV.Size text_size, out int baseline);
+
+ public OpenCV.FontFace font_face;
+ [CCode (array_length = false, array_null_terminated = true)]
+ public int[] ascii;
+ [CCode (array_length = false, array_null_terminated = true)]
+ public int[] greek;
+ [CCode (array_length = false, array_null_terminated = true)]
+ public int[] cyrillic;
+ public float hscale;
+ public float vscale;
+ public int thickness;
+ public float dx;
+ public int line_type;
+ }
+
+ [Compact, CCode (cname = "CvHaarClassifierCascade")]
+ public class HaarClassifierCascade {
+ [CCode (cname = "cvLoad", type = "void*")]
+ public static unowned HaarClassifierCascade? load (string filename, OpenCV.Memory.Storage
storage, string? name = null, out string? real_name = null);
+
+ [CCode (cname = "cvHaarDetectObjects", instance_pos = 1.9)]
+ public unowned OpenCV.Sequence<OpenCV.Rectangle?> detect_objects (OpenCV.Array image,
OpenCV.Memory.Storage storage, double scale_factor = 1.0, int min_neighbors = 3,
OpenCV.HaarClassifierCascade.Flags flags = 0, OpenCV.Size min_size = OpenCV.Size (0, 0));
+ [CCode (cname = "cvSetImagesForHaarClassifierCascade")]
+ public void set_images (OpenCV.Array sum, OpenCV.Array sqsum, OpenCV.Array tilted_sum, double
scale);
+ [CCode (cname = "cvRunHaarClassifierCascade")]
+ public int run (OpenCV.Point pt, int start_stage = 0);
+
+ [Flags, CCode (cname = "int", has_type_id = false, cprefix = "CV_HAAR_")]
+ public enum Flags {
+ DO_CANNY_PRUNING,
+ SCALE_IMAGE,
+ FIND_BIGGEST_OBJECT,
+ DO_ROUGH_SEARCH
+ }
+ }
+
+ [SimpleType, CCode (cname = "CvInput")]
+ public struct Input {
+ public OpenCV.Callback @callback;
+ public void* data;
+ }
+
+ [Compact, CCode (cname = "CvMat", has_type_id = false, free_function = "cvReleaseMat",
free_function_address_of = true, copy_function = "cvCloneMat")]
+ public class Matrix : OpenCV.Array {
+ [CCode (cname = "cvCreateMat")]
+ public Matrix (int rows, int cols, int type);
+ [CCode (cname = "cvCreateMatHeader")]
+ public Matrix.header (int rows, int cols, int type);
+
+ [CCode (cname = "cvCloneMat")]
+ public Matrix clone ();
+ [CCode (cname = "cvCompleteSymm")]
+ public void complete_symmetric (int LtoR);
+ [CCode (cname = "cvIplDepth")]
+ public static int depth (int type);
+ [CCode (cname = "cvmGet")]
+ public double get (int row, int col);
+ [CCode (cname = "cvmSet")]
+ public void set (int row, int col, double value);
+ [CCode (cname = "cvSolveCubic")]
+ public int solve_cubic (OpenCV.Matrix roots);
+ [CCode (cname = "cvSolvePoly")]
+ public void solve_polynomial (OpenCV.Matrix roots2, int maxiter = 20, int fig = 100);
+
+ public OpenCV.Type type;
+ public int step;
+ public int rows;
+ public int cols;
+ public OpenCV.Matrix.Data data;
+
+ [CCode (cname = "union { uchar* ptr; short* s; int* i; float* fl; double* db; }", has_type_id
= false)]
+ public struct Data {
+ public void* ptr;
+ public short* s;
+ public int* i;
+ public float* fl;
+ public double* db;
+ }
+
+ [Compact, CCode (cname = "cvMatND", has_type_id = false, free_function = "cvReleaseMatND",
free_function_address_of = true, copy_function = "cvCloneMatND")]
+ public class ND {
+ [CCode (cname = "cvCreateMatND")]
+ public ND (int dims, [CCode (array_length = false, array_null_terminated = true)]
int[] sizes, int type);
+
+ [CCode (cname = "cvCloneMatND")]
+ public ND clone ();
+
+ public OpenCV.Type type;
+ public int dims;
+ public OpenCV.Matrix.Data data;
+ // TODO: s/32/OpenCV.MAX_DIM/ when b.g.o. #624507 is resolved
+ public OpenCV.Matrix.ND.Dimension dim[32];
+
+ public struct Dimension {
+ public int size;
+ public int step;
+ }
+ }
+
+ [Compact, CCode (cname = "cvSparseMat", has_type_id = false, free_function =
"cvReleaseSparseMat", free_function_address_of = true, copy_function = "cvCloneSparseMat")]
+ public class Sparse {
+ [CCode (cname = "cvCreateSparseMat")]
+ public Sparse (int dims, [CCode (array_length = false, array_null_terminated = true)]
int[] sizes, int type);
+
+ [CCode (cname = "cvCloneSparseMat")]
+ public Sparse clone ();
+
+ public OpenCV.Type type;
+ public int dims;
+ // public struct CvSet* heap;
+ // public void** hashtable;
+ // public int hashsize;
+ [CCode (cname = "valoffset")]
+ public int value_offset;
+ [CCode (cname = "idxoffset")]
+ public int index_offset;
+ // TODO: s/32/OpenCV.MAX_DIM/ when b.g.o. #624507 is resolved
+ public int size[32];
+
+ [CCode (cname = "CvSparseNode", has_type_id = false)]
+ public struct Node {
+ [CCode (cname = "hashval")]
+ public uint hash_value;
+ public Node* next;
+ }
+
+ [CCode (cname = "CvSparseMatIterator", has_type_id = false)]
+ public struct Iterator {
+ [CCode (cname = "mat")]
+ public OpenCV.Matrix.Sparse matrix;
+ public Node* node;
+ [CCode (cname = "curidx")]
+ public int current_index;
+ }
+ }
+ }
+
+ [CCode (cname = "CvString")]
+ public class String {
+ [CCode (cname = "cvMemStorageAllocString")]
+ public String (OpenCV.Memory.Storage storage, string str, int len = -1);
+
+ public int len;
+ public string ptr;
+ }
+
+ namespace Math {
+ [CCode (cname = "cvCeil")]
+ public static int ceil (double value);
+ [CCode (cname = "cvCbrt")]
+ public static float cubic_root (float value);
+ [CCode (cname = "cvFastArctan")]
+ public static float fast_arctan (float x, float y);
+ [CCode (cname = "cvFloor")]
+ public static int floor (double value);
+ [CCode (cname = "cvInvSqrt")]
+ public static float inv_sqrt ();
+ [CCode (cname = "cvIsInf")]
+ public static int is_inf (double value);
+ [CCode (cname = "cvIsNaN")]
+ public static int is_nan (double value);
+ [CCode (cname = "cvRound")]
+ public static int round (double value);
+ [CCode (cname = "cvSqrt")]
+ public static float sqrt (double value);
+ }
+
+ namespace Memory {
+ [Compact, CCode (cname = "CvMemBlock")]
+ public struct Block {
+ public OpenCV.Memory.Block? prev;
+ public OpenCV.Memory.Block? next;
+ }
+
+ [Compact, CCode (cname = "CvMemStorage", free_function = "cvReleaseMemStorage",
free_function_address_of = true)]
+ public class Storage {
+ [CCode (cname = "cvCreateMemStorage")]
+ public Storage (int block_size = 0);
+ [CCode (cname = "cvCreateChildMemStorage")]
+ public Storage.from_parent (OpenCV.Memory.Storage parent);
+
+ [CCode (cname = "cvClearMemStorage")]
+ public void clear ();
+ [CCode (cname = "cvSaveMemStoragePos")]
+ public void save_position (OpenCV.Memory.Storage.Position pos);
+ [CCode (cname = "cvRestoreMemStoragePos")]
+ public void restore_position (OpenCV.Memory.Storage.Position pos);
+ [CCode (cname = "cvMemStorageAlloc")]
+ public void* alloc (size_t size);
+ [CCode (cname = "cvMemStorageAllocString")]
+ public OpenCV.String alloc_string (string ptr, int len = -1);
+
+ [CCode (cname = "cvLoad", instance_pos = 1.9)]
+ public void* load (string filename, string name, out string? real_name = null);
+
+ public int signature;
+ public OpenCV.Memory.Block bottom;
+ public OpenCV.Memory.Block top;
+ public OpenCV.Memory.Storage parent;
+ public int block_size;
+ public int free_space;
+
+ [CCode (cname = "CvMemStoragePos")]
+ public struct Position {
+ public OpenCV.Memory.Block top;
+ public int free_space;
+ }
+ }
+
+ [CCode (cname = "cvAlloc")]
+ public static void* alloc ();
+ [CCode (cname = "cvFree")]
+ public static void free (void* ptr);
+ }
+
+ [SimpleType, CCode (cname = "CvPoint", has_type_id = false)]
+ public struct Point {
+ [CCode (cname = "cvPoint")]
+ public Point (int x, int y);
+ [CCode (cname = "cvPointFrom32f")]
+ public Point.from_32f (OpenCV.Point2D32f point);
+
+ [CCode (cname = "cvPointTo32f")]
+ public Point to_32f ();
+
+ public int x;
+ public int y;
+ }
+
+ [CCode (cname = "CvPoint2D32f", has_type_id = false)]
+ public struct Point2D32f {
+ public float x;
+ public float y;
+
+ [CCode (cname = "cvPoint2D32f")]
+ public Point2D32f (float x, float y);
+ [CCode (cname = "cvPointTo32f")]
+ public Point2D32f.from_point (OpenCV.Point point);
+
+ [CCode (cname = "cvPointFrom32f")]
+ public Point to_point (OpenCV.Point2D32f point);
+ }
+
+ [CCode (cname = "CvPoint2D32f", has_type_id = false)]
+ public struct Point2D64f {
+ [CCode (cname = "cvPoint2D64f")]
+ public Point2D64f (double x, double y);
+
+ public double x;
+ public double y;
+ }
+
+ [CCode (cname = "CvPoint3D32f", has_type_id = false)]
+ public struct Point3D32f {
+ [CCode (cname = "cvPoint3D32f")]
+ public Point3D32f (float x, float y, float z);
+
+ public float x;
+ public float y;
+ public float z;
+ }
+
+ [CCode (cname = "CvPoint3D64f")]
+ public struct Point3D64f {
+ [CCode (cname = "cvPoint3D64f")]
+ public Point3D64f (double x, double y, double z);
+
+ public double x;
+ public double y;
+ public double z;
+ }
+
+ [SimpleType, CCode (cname = "CvRect", has_type_id = false, destroy_function = "")]
+ public struct Rectangle {
+ [CCode (cname = "cvRect")]
+ public Rectangle (int x, int y, int width, int height);
+ [CCode (cname = "cvRectToROI")]
+ public OpenCV.IPL.ROI to_roi (int coi);
+
+ public int x;
+ public int y;
+ public int width;
+ public int height;
+ }
+
+ [SimpleType, CCode (cname = "CvScalar", has_type_id = false, destroy_function = "")]
+ public struct Scalar {
+ [CCode (cname = "cvScalar")]
+ public Scalar (double val0, double val1 = 0.0, double val2 = 0.0, double val3 = 0.0);
+ [CCode (cname = "cvScalarAll")]
+ public Scalar.all (double val0123);
+ [CCode (cname = "cvRawDataToScalar")]
+ public Scalar.from_raw_data ([CCode (array_length = false)] uint8[] data, int type);
+ [CCode (cname = "cvColorToScalar")]
+ public Scalar.from_color (double packed_color, int arrtype);
+ [CCode (cname = "CV_RGB")]
+ public Scalar.from_rgb (double red, double green, double blue);
+
+ [CCode (cname = "cvScalarToRawData")]
+ public void to_raw_data ([CCode (array_length = false)] uint8[] data, int type, int
extend_to_12 = 0);
+
+ public double val[4];
+ }
+
+ [Compact, CCode (cname = "CvSeq", free_function = "")]
+ public class Sequence<T> {
+ [CCode (cname = "cvCreateSeq")]
+ public Sequence (int seq_flags, int header_size, int elem_size, OpenCV.Memory.Storage
storage);
+
+ [CCode (cname = "cvSetSeqBlockSize")]
+ public void set_block_size (int delta_elems);
+ [CCode (cname = "cvSeqPush")]
+ public unowned T push (T element);
+ [CCode (cname = "cvSeqPushFront")]
+ public unowned T push_front (T element);
+ [CCode (cname = "cvSeqPop")]
+ public void pop (T element = null);
+ [CCode (cname = "cvSeqPopFront")]
+ public void pop_front (T element = null);
+ [CCode (cname = "cvGetSeqElem")]
+ public unowned T? get (int index);
+ [CCode (cname = "cvSeqPushMulti")]
+ public void push_multi (T[] elements, bool in_front = false);
+ [CCode (cname = "cvSeqPopMulti")]
+ public void pop_multi (T[] elements, bool in_front = false);
+ [CCode (cname = "cvSeqInsert")]
+ public void insert (int before_index, T element);
+ [CCode (cname = "cvSeqRemove")]
+ public void remove (int index);
+ [CCode (cname = "cvClearSeq")]
+ public void clear (int index);
+ [CCode (cname = "cvCvtSeqToArray", array_length_pos = 1.9)]
+ public T[]? to_array (OpenCV.Slice slice = OpenCV.Slice.WHOLE_ARRAY);
+
+ public int total;
+ }
+
+ [SimpleType, CCode (cname = "CvSize", has_type_id = false)]
+ public struct Size {
+ public int width;
+ public int height;
+
+ [CCode (cname = "cvSize")]
+ public Size (int width, int height);
+ }
+
+ public struct Size2D32f {
+ [CCode (cname = "cvSize2D32f")]
+ public Size2D32f (double width, double heigh);
+
+ public float width;
+ public float height;
+ }
+
+ [SimpleType, CCode (cname = "CvSlice")]
+ public struct Slice {
+ public int start_index;
+ public int end_index;
+
+ [CCode (cname = "cvSlice")]
+ public Slice (int start, int end);
+ [CCode (cname = "cvSliceLength")]
+ public int length (OpenCV.Sequence seq);
+
+ [CCode (cname = "CV_WHOLE_ARR")]
+ public const OpenCV.Slice WHOLE_ARRAY;
+ }
+
+ [SimpleType, CCode (cname = "CvTermCriteria", has_type_id = false)]
+ public struct TermCriteria {
+ public OpenCV.Type type;
+ public int max_iter;
+ public double epsilon;
+
+ [CCode (cname = "cvTermCriteria")]
+ public TermCriteria (int type, int max_iter, double epsilon);
+ }
+
+ [CCode (cheader_filename = "highgui.h")]
+ namespace Window {
+ [CCode (cname = "cvNamedWindow")]
+ public static int create_named (string window_name, OpenCV.Window.Flags flags =
OpenCV.Window.Flags.AUTO_SIZE);
+ [CCode (cname = "cvShowImage")]
+ public static void show_image (string window_name, OpenCV.Array arr);
+ [CCode (cname = "cvDestroyWindow")]
+ public static void destroy (string window_name);
+ [CCode (cname = "cvGetWindowProperty")]
+ public static void get_property (string window_name, OpenCV.Window.Property prop_id);
+ [CCode (cname = "cvSetWindowProperty")]
+ public static void set_property (string window_name, OpenCV.Window.Property prop_id, double
value);
+ [CCode (cname = "cvResizeWindow")]
+ public static void resize (string window_name, int width, int height);
+ [CCode (cname = "cvMoveWindow")]
+ public static void move (string window_name, int x, int y);
+ [CCode (cname = "cvDestroyAllWindows")]
+ public static void destroy_all ();
+ [CCode (cname = "cvGetWindowHandle")]
+ public static void* get_handle (string window_name);
+ [CCode (cname = "cvGetWindowName")]
+ public static unowned string get_name (void* handle);
+ [CCode (cname = "cvSetMouseCallback")]
+ public static void set_mouse_callback (string window_name, OpenCV.MouseCallback on_mouse);
+
+ [Flags, CCode (cname = "int", has_type_id = false, cprefix = "CV_WINDOW_")]
+ public enum Flags {
+ [CCode (cname = "CV_WINDOW_AUTOSIZE")]
+ AUTO_SIZE
+ }
+
+ [CCode (cname = "int", has_type_id = false, cprefix = "CV_WND_PROP_")]
+ public enum Property {
+ FULLSCREEN,
+ AUTOSIZE
+ }
+ }
+
+ [CCode (cheader_filename = "highgui.h")]
+ namespace Trackbar {
+ [CCode (cname = "CvTrackBarCallback2")]
+ public delegate void Callback (int pos);
+
+ [CCode (cname = "cvCreateTrackbar2")]
+ public int create (string trackbar_name, string window_name, ref int value, int count,
OpenCV.Trackbar.Callback on_change);
+ [CCode (cname = "cvGetTrackbarPos")]
+ public int get_position (string trackbar_name, string window_name);
+ [CCode (cname = "cvSetTrackbarPos")]
+ public void set_position (string trackbar_name, string window_name, int pos);
+ }
+
+ [CCode (cname = "int", has_type_id = false, cprefix = "CV_EVENT_", cheader_filename = "highgui.h")]
+ public enum EventType {
+ [CCode (cname = "CV_EVENT_MOUSEMOVE")]
+ MOUSE_MOVE,
+ [CCode (cname = "CV_EVENT_LBUTTONDOWN")]
+ LEFT_BUTTON_DOWN,
+ [CCode (cname = "CV_EVENT_RBUTTONDOWN")]
+ RIGHT_BUTTON_DOWN,
+ [CCode (cname = "CV_EVENT_MBUTTONDOWN")]
+ MIDDLE_BUTTON_DOWN,
+ [CCode (cname = "CV_EVENT_LBUTTONUP")]
+ LEFT_BUTTON_UP,
+ [CCode (cname = "CV_EVENT_RBUTTONUP")]
+ RIGHT_BUTTON_UP,
+ [CCode (cname = "CV_EVENT_MBUTTONUP")]
+ MIDDLE_BUTTON_UP,
+ [CCode (cname = "CV_EVENT_LBUTTONDBLCLK")]
+ LEFT_BUTTON_DOUBLE_CLICK,
+ [CCode (cname = "CV_EVENT_RBUTTONDBLCLK")]
+ RIGHT_BUTTON_DOUBLE_CLICK,
+ [CCode (cname = "CV_EVENT_MBUTTONDBLCLK")]
+ MIDDLE_BUTTON_DOUBLE_CLICK,
+
+ MOUSEMOVE,
+ LBUTTONDOWN,
+ RBUTTONDOWN,
+ MBUTTONDOWN,
+ LBUTTONUP,
+ RBUTTONUP,
+ MBUTTONUP,
+ LBUTTONDBLCLK,
+ RBUTTONDBLCLK,
+ MBUTTONDBLCLK,
+ }
+
+ [Flags, CCode (cname = "int", has_type_id = false, cprefix = "CV_EVENT_FLAG_", cheader_filename =
"highgui.h")]
+ public enum EventFlag {
+ [CCode (cname = "CV_EVENT_FLAG_LBUTTON")]
+ LEFT_BUTTON,
+ [CCode (cname = "CV_EVENT_FLAG_RBUTTON")]
+ RIGHT_BUTTON,
+ [CCode (cname = "CV_EVENT_FLAG_MBUTTON")]
+ MIDDLE_BUTTON,
+ [CCode (cname = "CV_EVENT_FLAG_CTRLKEY")]
+ CONTROL_KEY,
+ [CCode (cname = "CV_EVENT_FLAG_SHIFTKEY")]
+ SHIFT_KEY,
+ [CCode (cname = "CV_EVENT_FLAG_ALTKEY")]
+ ALT_KEY,
+
+ LBUTTON,
+ RBUTTON,
+ MBUTTON,
+ CTRLKEY,
+ SHIFTKEY,
+ ALTKEY
+ }
+
+ [Compact, CCode (cname = "CvCapture", free_function = "cvReleaseCapture", free_function_address_of =
true, has_type_id = false, cheader_filename = "highgui.h")]
+ public class Capture {
+ [CCode (cname = "cvCreateFileCapture")]
+ public Capture.from_file (string filename);
+ [CCode (cname = "cvCreateCameraCapture")]
+ public Capture.from_camera (int index);
+
+ [CCode (cname = "cvGrabFrame")]
+ public bool grab_frame ();
+ [CCode (cname = "cvRetrieveFrame")]
+ public unowned OpenCV.IPL.Image retrieve_frame (int stream_index = 0);
+ [CCode (cname = "cvQueryFrame")]
+ public unowned OpenCV.IPL.Image query_frame ();
+ [CCode (cname = "cvGetCaptureProperty")]
+ public double get_property (OpenCV.Capture.Property property_id);
+ [CCode (cname = "cvSetCaptureProperty")]
+ public int set_property (OpenCV.Capture.Property property_id, double value);
+ [CCode (cname = "cvGetCaptureDomain")]
+ public OpenCV.Capture.Domain get_domain ();
+
+ [CCode (cname = "int", has_type_id = false, cprefix = "CV_CAP_")]
+ public enum Domain {
+ ANY,
+ MIL,
+ VFW,
+ V4L,
+ V4L2,
+ FIREWARE,
+ FIREWIRE,
+ IEEE1394,
+ DC1394,
+ CMU1394,
+ STEREO,
+ TYZX,
+ [CCode (cname = "CV_TYZX_LEFT")]
+ TYZX_LEFT,
+ [CCode (cname = "CV_TYZX_RIGHT")]
+ TYZX_RIGHT,
+ [CCode (cname = "CV_TYZX_COLOR")]
+ TYZX_COLOR,
+ [CCode (cname = "CV_TYZX_Z")]
+ TYZX_Z,
+ QT,
+ UNICAP,
+ DSHOW,
+ PVAPI
+ }
+
+ [CCode (cname = "int", has_type_id = false, cprefix = "CV_CAP_PROP_")]
+ public enum Property {
+ POS_MSEC,
+ POS_FRAMES,
+ POS_AVI_RATIO,
+ FRAME_WIDTH,
+ FRAME_HEIGHT,
+ FPS,
+ FOURCC,
+ FRAME_COUNT,
+ FORMAT,
+ MODE,
+ BRIGHTNESS,
+ CONTRAST,
+ SATURATION,
+ HUE,
+ GAIN,
+ EXPOSURE,
+ CONVERT_RGB,
+ WHITE_BALANCE,
+ RECTIFICATION,
+ }
+ }
+
+ [CCode (cname = "CV_MAX_DIM")]
+ public const int MAX_DIM;
+
+ [CCode (cname = "CvCallback")]
+ public delegate void Callback (int index, void* buffer);
+ [CCode (cname = "CvMouseCallback")]
+ public delegate void MouseCallback (OpenCV.EventType ev, int x, int y, OpenCV.EventFlag flags);
+
+ [CCode (cname = "cvWaitKey")]
+ public static void wait_key (int delay = 0);
+
+ [CCode (cheader_filename = "cvaux.h")]
+ namespace Eigen {
+ [CCode (cname = "cvCalcCovarMatrixEx")]
+ public static void calculate_covariation_matrix (int nObjects, void* input, int ioFlags,
[CCode (array_length_pos = 3.9)] uint8[] buffer, void* user_data, OpenCV.IPL.Image avg, [CCode (array_length
= false)] float[] covar_matrix);
+ [CCode (cname = "cvCalcEigenObjects")]
+ public static void calculate_objects (int nObjects, void* input, void* output, int ioFlags,
int ioBufSize, void* userData, OpenCV.TermCriteria calc_limit, OpenCV.IPL.Image avg, [CCode (array_length =
false)] float[] eigenvals);
+ [CCode (cname = "cvClacDecompCoeff")]
+ public static double calculate_decomposition_coefficient (OpenCV.IPL.Image obj,
OpenCV.IPL.Image eigObj, OpenCV.IPL.Image avg);
+ [CCode (cname = "cvEigenDecomposite")]
+ public static void eigen_decomposite (OpenCV.IPL.Image obj, int nEigObjs, void* eigInput, int
ioFlags, void* userData, OpenCV.IPL.Image avg, [CCode (array_length = false)] float[] coeffs);
+ [CCode (cname = "cvEigenProjection")]
+ public static void eigen_projection (void* eigInput, int nEigObjs, int ioFlags, void*
userData, [CCode (array_length = false)] float[] coeffs, OpenCV.IPL.Image avg, OpenCV.IPL.Image proj);
+ }
+
+ [CCode (cprefix = "Ipl")]
+ namespace IPL {
+ [Compact, CCode (cname = "IplImage", has_type_id = false, free_function = "cvReleaseImage",
free_function_address_of = true, copy_function = "cvCloneImage")]
+ public class Image : OpenCV.Array {
+ [CCode (cname = "cvCreateImage")]
+ public Image (OpenCV.Size size, int depth, int channels);
+ [CCode (cname = "cvLoadImage", cheader_filename = "highgui.h")]
+ public Image.load (string filename, OpenCV.IPL.Image.LoadType type =
OpenCV.IPL.Image.LoadType.COLOR);
+
+ [CCode (cname = "cvCloneImage")]
+ public Image clone ();
+ [CCode (cname = "cvInitImageHeader")]
+ public void init_header (OpenCV.Size size, int depth, int channels, int origin = 0,
int align = 4);
+ [CCode (cname = "cvGetImageCOI")]
+ public int get_coi ();
+ [CCode (cname = "cvGetImageROI")]
+ public OpenCV.Rectangle get_roi ();
+ [CCode (cname = "cvResetImageROI")]
+ public int reset_roi ();
+ [CCode (cname = "cvSetImageROI")]
+ public void set_roi (OpenCV.Rectangle roi);
+ [CCode (cname = "cvSetImageCOI")]
+ public void set_coi (int coi);
+
+ [CCode (cname = "nSize")]
+ public int n_size;
+ [CCode (cname = "ID")]
+ public int id;
+ [CCode (cname = "nChannels")]
+ public int n_channels;
+ [CCode (cname = "alphaChannel")]
+ public int alpha_channel;
+ public int depth;
+ [CCode (cname = "colorModel")]
+ public char color_model[4];
+ [CCode (cname = "channelSeq")]
+ public char channel_sequence[4];
+ [CCode (cname = "dataOrder")]
+ public int data_order;
+ public int origin;
+ public int align;
+ public int width;
+ public int height;
+ public OpenCV.IPL.ROI* roi;
+ [CCode (cname = "maskROI")]
+ public Image mask_roi;
+ [CCode (cname = "imageId")]
+ public void* image_id;
+ // [CCode (cname = "tileInfo")]
+ // public TileInfo tile_info;
+ [CCode (cname = "imageData", array_length_cname = "imageSize")]
+ public uint8[] image_data;
+ [CCode (cname = "widthStep")]
+ public int width_step;
+ [CCode (cname = "BorderMode")]
+ public int border_mode[4];
+ [CCode (cname = "BorderConst")]
+ public int border_const[4];
+ // [CCode (cname = "imageDataOrigin")]
+ // public ? image_data_origin;
+
+ [CCode (cname = "int", has_type_id = false, cprefix = "CV_LOAD_IMAGE_")]
+ public enum LoadType {
+ UNCHANGED,
+ GRAYSCALE,
+ COLOR,
+ [CCode (cname = "CV_LOAD_IMAGE_ANYDEPTH")]
+ ANY_DEPTH,
+ [CCode (cname = "CV_LOAD_IMAGE_ANYCOLOR")]
+ ANY_COLOR
+ }
+ }
+
+ [SimpleType, CCode (cname = "IplROI", has_type_id = false)]
+ public struct ROI {
+ public int coi;
+ [CCode (cname = "xOffset")]
+ public int x_offset;
+ [CCode (cname = "yOffset")]
+ public int y_offset;
+ public int width;
+ public int height;
+
+ [CCode (cname = "cvROIToRect")]
+ public OpenCV.Rectangle to_rectangle ();
+ }
+
+ [CCode (cname = "IplConvKernel", has_type_id = false)]
+ public struct ConvKernel {
+ [CCode (cname = "nCols")]
+ public int n_cols;
+ [CCode (cname = "nRows")]
+ public int n_rows;
+ [CCode (cname = "anchorX")]
+ public int anchor_x;
+ [CCode (cname = "anchorY")]
+ public int anchor_y;
+ [CCode (array_length = false)]
+ public int[] values;
+ [CCode (cname = "nShiftR")]
+ public int n_shift_r;
+ }
+
+ [CCode (cname = "IplConvKernelFP", has_type_id = false)]
+ public struct ConvKernelFP {
+ [CCode (cname = "nCols")]
+ public int nCols;
+ [CCode (cname = "nRows")]
+ public int nRows;
+ [CCode (cname = "anchorX")]
+ public int anchorX;
+ [CCode (cname = "anchorY")]
+ public int anchorY;
+ [CCode (array_length = false)]
+ public float[] values;
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]