Java API generator improvements:
- fixed return of complex types (Scalar, Point, etc) - partial implementation of vector<> support (empty stubs for CPP-side converters)
This commit is contained in:
@@ -1,3 +1,102 @@
|
||||
#include "utils.h"
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv;
|
||||
|
||||
// vector_int
|
||||
|
||||
void Mat_to_vector_int(Mat& mat, vector<int>& v_int)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void vector_int_to_Mat(vector<int>& v_int, Mat& mat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//vector_double
|
||||
|
||||
void Mat_to_vector_double(Mat& mat, vector<double>& v_double)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void vector_double_to_Mat(vector<double>& v_double, Mat& mat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// vector_float
|
||||
|
||||
void Mat_to_vector_float(Mat& mat, vector<float>& v_float)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void vector_float_to_Mat(vector<float>& v_float, Mat& mat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//vector_uchar
|
||||
|
||||
void Mat_to_vector_uchar(cv::Mat& mat, std::vector<uchar>& v_uchar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//vector_Rect
|
||||
|
||||
void Mat_to_vector_Rect(Mat& mat, vector<Rect>& v_rect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void vector_Rect_to_Mat(vector<Rect>& v_rect, Mat& mat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//vector_Point
|
||||
void Mat_to_vector_Point(Mat& mat, vector<Point>& v_point)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void vector_Point_to_Mat(vector<Point>& v_point, Mat& mat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//vector_KeyPoint
|
||||
void Mat_to_vector_KeyPoint(Mat& mat, vector<KeyPoint>& v_kp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void vector_KeyPoint_to_Mat(vector<KeyPoint>& v_kp, Mat& mat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//vector_Mat
|
||||
void Mat_to_vector_Mat(cv::Mat& mat, std::vector<cv::Mat>& v_mat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,42 @@
|
||||
#include <jni.h>
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
|
||||
|
||||
void Mat_to_vector_int(cv::Mat& mat, std::vector<int>& v_int);
|
||||
|
||||
void vector_int_to_Mat(std::vector<int>& v_int, cv::Mat& mat);
|
||||
|
||||
|
||||
void Mat_to_vector_double(cv::Mat& mat, std::vector<double>& v_double);
|
||||
|
||||
void vector_double_to_Mat(std::vector<double>& v_double, cv::Mat& mat);
|
||||
|
||||
|
||||
void Mat_to_vector_float(cv::Mat& mat, std::vector<float>& v_float);
|
||||
|
||||
void vector_float_to_Mat(std::vector<float>& v_float, cv::Mat& mat);
|
||||
|
||||
|
||||
void Mat_to_vector_uchar(cv::Mat& mat, std::vector<uchar>& v_uchar);
|
||||
|
||||
|
||||
void Mat_to_vector_Rect(cv::Mat& mat, std::vector<cv::Rect>& v_rect);
|
||||
|
||||
void vector_Rect_to_Mat(std::vector<cv::Rect>& v_rect, cv::Mat& mat);
|
||||
|
||||
|
||||
void Mat_to_vector_Point(cv::Mat& mat, std::vector<cv::Point>& v_point);
|
||||
|
||||
void vector_Point_to_Mat(std::vector<cv::Point>& v_point, cv::Mat& mat);
|
||||
|
||||
|
||||
void Mat_to_vector_KeyPoint(cv::Mat& mat, std::vector<cv::KeyPoint>& v_kp);
|
||||
|
||||
void vector_KeyPoint_to_Mat(std::vector<cv::KeyPoint>& v_kp, cv::Mat& mat);
|
||||
|
||||
void Mat_to_vector_Mat(cv::Mat& mat, std::vector<cv::Mat>& v_mat);
|
||||
|
||||
void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat);
|
||||
|
||||
|
@@ -27,7 +27,7 @@ public class Mat {
|
||||
|
||||
//javadoc:Mat::Mat(rows,cols,type,s)
|
||||
public Mat(int rows, int cols, CvType type, Scalar s) {
|
||||
this( nCreateMat(rows, cols, type.toInt(), s.v0, s.v1, s.v2, s.v3) );
|
||||
this( nCreateMat(rows, cols, type.toInt(), s.val[0], s.val[1], s.val[2], s.val[3]) );
|
||||
}
|
||||
|
||||
//javadoc:Mat::Mat(rows,cols,depth,s)
|
||||
@@ -280,7 +280,7 @@ public class Mat {
|
||||
//javadoc:Mat::setTo(s)
|
||||
public void setTo(Scalar s) {
|
||||
checkNull();
|
||||
nSetTo(nativeObj, s.v0, s.v1, s.v2, s.v3);
|
||||
nSetTo(nativeObj, s.val[0], s.val[1], s.val[2], s.val[3]);
|
||||
}
|
||||
|
||||
//javadoc:Mat::copyTo(m)
|
||||
|
@@ -3,41 +3,34 @@ package org.opencv;
|
||||
//javadoc:Scalar_
|
||||
public class Scalar {
|
||||
|
||||
public double v0, v1, v2, v3;
|
||||
public double val[];
|
||||
|
||||
public Scalar(double v0, double v1, double v2, double v3) {
|
||||
this.v0 = v0;
|
||||
this.v1 = v1;
|
||||
this.v2 = v2;
|
||||
this.v3 = v3;
|
||||
this.val = new double[] {v0, v1, v2, v3};
|
||||
}
|
||||
|
||||
public Scalar(double v0, double v1, double v2) {
|
||||
this(v0, v1, v2, 0);
|
||||
this.val = new double[] {v0, v1, v2, 0};
|
||||
}
|
||||
|
||||
public Scalar(double v0, double v1) {
|
||||
this(v0, v1, 0, 0);
|
||||
this.val = new double[] {v0, v1, 0, 0};
|
||||
}
|
||||
|
||||
public Scalar(double v0) {
|
||||
this(v0, 0, 0, 0);
|
||||
this.val = new double[] {v0, 0, 0, 0};
|
||||
}
|
||||
|
||||
public Scalar(double[] vals) {
|
||||
set(vals);
|
||||
this.val = new double[4];
|
||||
set(vals);
|
||||
}
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
v0 = vals.length>0 ? (int)vals[0] : 0;
|
||||
v1 = vals.length>1 ? (int)vals[1] : 0;
|
||||
v2 = vals.length>2 ? (int)vals[2] : 0;
|
||||
v3 = vals.length>3 ? (int)vals[3] : 0;
|
||||
} else {
|
||||
v0 = 0;
|
||||
v1 = 0;
|
||||
v2 = 0;
|
||||
v3 = 0;
|
||||
this.val[0] = vals.length>0 ? vals[0] : 0;
|
||||
this.val[1] = vals.length>1 ? vals[1] : 0;
|
||||
this.val[2] = vals.length>2 ? vals[2] : 0;
|
||||
this.val[3] = vals.length>3 ? vals[3] : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,46 +39,41 @@ public class Scalar {
|
||||
}
|
||||
|
||||
public Scalar clone() {
|
||||
return new Scalar(v0, v1, v2, v3);
|
||||
return new Scalar(val);
|
||||
}
|
||||
|
||||
public Scalar mul(Scalar it, double scale) {
|
||||
return new Scalar( v0 * it.v0 * scale, v1 * it.v1 * scale,
|
||||
v2 * it.v2 * scale, v3 * it.v3 * scale );
|
||||
return new Scalar( val[0] * it.val[0] * scale, val[1] * it.val[1] * scale,
|
||||
val[2] * it.val[2] * scale, val[3] * it.val[3] * scale );
|
||||
}
|
||||
|
||||
public Scalar mul(Scalar it) {
|
||||
return mul(it, 1);
|
||||
}
|
||||
public Scalar conj() {
|
||||
return new Scalar(v0, -v1, -v2, -v3);
|
||||
return new Scalar(val[0], -val[1], -val[2], -val[3]);
|
||||
}
|
||||
|
||||
public boolean isReal() {
|
||||
return v1 == 0 && v2 == 0 && v3 == 0;
|
||||
return val[1] == 0 && val[2] == 0 && val[3] == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(v0);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(v1);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(v2);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(v3);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + java.util.Arrays.hashCode(val);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Scalar)) return false;
|
||||
Scalar it = (Scalar) obj;
|
||||
return v0 == it.v0 && v1 == it.v1 && v2 == it.v2 && v3 == it.v3;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Scalar)) return false;
|
||||
Scalar it = (Scalar) obj;
|
||||
if (!java.util.Arrays.equals(val, it.val)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user