mirror of https://github.com/opencv/opencv.git
* fixed manually ported classes; * added vector<vector<Point>> support; * changed argument types for 3 functions; * finished tests for org.opencv.core.Core class.pull/13383/head
parent
6d9075812f
commit
1991440cf7
28 changed files with 1773 additions and 1369 deletions
@ -1,15 +1,15 @@ |
|||||||
package org.opencv.core; |
package org.opencv.core; |
||||||
|
|
||||||
public class CvException extends RuntimeException { |
public class CvException extends RuntimeException { |
||||||
|
|
||||||
private static final long serialVersionUID = 1L; |
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
public CvException(String msg) { |
public CvException(String msg) { |
||||||
super(msg); |
super(msg); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public String toString() { |
public String toString() { |
||||||
return "CvException [" + super.toString() + "]"; |
return "CvException [" + super.toString() + "]"; |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,111 +1,136 @@ |
|||||||
package org.opencv.core; |
package org.opencv.core; |
||||||
|
|
||||||
|
|
||||||
public final class CvType { |
public final class CvType { |
||||||
|
|
||||||
// type depth constants
|
// type depth constants
|
||||||
public static final int CV_8U = 0, CV_8S = 1, |
public static final int |
||||||
CV_16U = 2, CV_16S = 3, |
CV_8U = 0, CV_8S = 1, |
||||||
CV_32S = 4, |
CV_16U = 2, CV_16S = 3, |
||||||
CV_32F = 5, |
CV_32S = 4, |
||||||
CV_64F = 6, |
CV_32F = 5, |
||||||
CV_USRTYPE1=7; |
CV_64F = 6, |
||||||
|
CV_USRTYPE1 = 7; |
||||||
|
|
||||||
// predefined type constants
|
// predefined type constants
|
||||||
public static final int |
public static final int |
||||||
CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4), |
CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4), |
||||||
CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4), |
CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4), |
||||||
CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4), |
CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4), |
||||||
CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4), |
CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4), |
||||||
CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4), |
CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4), |
||||||
CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4), |
CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4), |
||||||
CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4); |
CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4); |
||||||
|
|
||||||
private static final int CV_CN_MAX = 512, CV_CN_SHIFT = 3, CV_DEPTH_MAX = (1 << CV_CN_SHIFT); |
private static final int CV_CN_MAX = 512, CV_CN_SHIFT = 3, CV_DEPTH_MAX = (1 << CV_CN_SHIFT); |
||||||
|
|
||||||
public static final int makeType(int depth, int channels) { |
public static final int makeType(int depth, int channels) { |
||||||
if(channels<=0 || channels>=CV_CN_MAX) { |
if (channels <= 0 || channels >= CV_CN_MAX) { |
||||||
throw new java.lang.UnsupportedOperationException( |
throw new java.lang.UnsupportedOperationException( |
||||||
"Channels count should be 1.." + (CV_CN_MAX-1) ); |
"Channels count should be 1.." + (CV_CN_MAX - 1)); |
||||||
} |
} |
||||||
if(depth<0 || depth>=CV_DEPTH_MAX) { |
if (depth < 0 || depth >= CV_DEPTH_MAX) { |
||||||
throw new java.lang.UnsupportedOperationException( |
throw new java.lang.UnsupportedOperationException( |
||||||
"Data type depth should be 0.." + (CV_DEPTH_MAX-1) ); |
"Data type depth should be 0.." + (CV_DEPTH_MAX - 1)); |
||||||
} |
} |
||||||
return (depth & (CV_DEPTH_MAX-1)) + ((channels-1) << CV_CN_SHIFT); |
return (depth & (CV_DEPTH_MAX - 1)) + ((channels - 1) << CV_CN_SHIFT); |
||||||
} |
} |
||||||
|
|
||||||
|
public static final int CV_8UC(int ch) { |
||||||
|
return makeType(CV_8U, ch); |
||||||
|
} |
||||||
|
|
||||||
public static final int CV_8UC(int ch) { return makeType(CV_8U, ch); } |
public static final int CV_8SC(int ch) { |
||||||
|
return makeType(CV_8S, ch); |
||||||
public static final int CV_8SC(int ch) { return makeType(CV_8S, ch); } |
} |
||||||
|
|
||||||
public static final int CV_16UC(int ch) { return makeType(CV_16U, ch); } |
public static final int CV_16UC(int ch) { |
||||||
|
return makeType(CV_16U, ch); |
||||||
|
} |
||||||
|
|
||||||
public static final int CV_16SC(int ch) { return makeType(CV_16S, ch); } |
public static final int CV_16SC(int ch) { |
||||||
|
return makeType(CV_16S, ch); |
||||||
|
} |
||||||
|
|
||||||
public static final int CV_32SC(int ch) { return makeType(CV_32S, ch); } |
public static final int CV_32SC(int ch) { |
||||||
|
return makeType(CV_32S, ch); |
||||||
|
} |
||||||
|
|
||||||
public static final int CV_32FC(int ch) { return makeType(CV_32F, ch); } |
public static final int CV_32FC(int ch) { |
||||||
|
return makeType(CV_32F, ch); |
||||||
|
} |
||||||
|
|
||||||
public static final int CV_64FC(int ch) { return makeType(CV_64F, ch); } |
public static final int CV_64FC(int ch) { |
||||||
|
return makeType(CV_64F, ch); |
||||||
|
} |
||||||
|
|
||||||
public static final int channels(int type) { return (type >> CV_CN_SHIFT) + 1; } |
public static final int channels(int type) { |
||||||
|
return (type >> CV_CN_SHIFT) + 1; |
||||||
|
} |
||||||
|
|
||||||
public static final int depth(int type) { return type & (CV_DEPTH_MAX-1); } |
public static final int depth(int type) { |
||||||
|
return type & (CV_DEPTH_MAX - 1); |
||||||
|
} |
||||||
|
|
||||||
public static final boolean isInteger(int type) { return depth(type) < CV_32F; } |
public static final boolean isInteger(int type) { |
||||||
|
return depth(type) < CV_32F; |
||||||
|
} |
||||||
|
|
||||||
public static final int ELEM_SIZE(int type) { |
public static final int ELEM_SIZE(int type) { |
||||||
switch (depth(type)) { |
switch (depth(type)) { |
||||||
case CV_8U: |
case CV_8U: |
||||||
case CV_8S: |
case CV_8S: |
||||||
return channels(type); |
return channels(type); |
||||||
case CV_16U: |
case CV_16U: |
||||||
case CV_16S: |
case CV_16S: |
||||||
return 2 * channels(type); |
return 2 * channels(type); |
||||||
case CV_32S: |
case CV_32S: |
||||||
case CV_32F: |
case CV_32F: |
||||||
return 4 * channels(type); |
return 4 * channels(type); |
||||||
case CV_64F: |
case CV_64F: |
||||||
return 8 * channels(type); |
return 8 * channels(type); |
||||||
default: |
default: |
||||||
throw new java.lang.UnsupportedOperationException( |
throw new java.lang.UnsupportedOperationException( |
||||||
"Unsupported CvType value: " + type ); |
"Unsupported CvType value: " + type); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
public static final String typeToString(int type) { |
public static final String typeToString(int type) { |
||||||
String s; |
String s; |
||||||
switch (depth(type)) { |
switch (depth(type)) { |
||||||
case CV_8U: |
case CV_8U: |
||||||
s = "CV_8U"; |
s = "CV_8U"; |
||||||
break; |
break; |
||||||
case CV_8S: |
case CV_8S: |
||||||
s = "CV_8S"; |
s = "CV_8S"; |
||||||
break; |
break; |
||||||
case CV_16U: |
case CV_16U: |
||||||
s = "CV_16U"; |
s = "CV_16U"; |
||||||
break; |
break; |
||||||
case CV_16S: |
case CV_16S: |
||||||
s = "CV_16S"; |
s = "CV_16S"; |
||||||
break; |
break; |
||||||
case CV_32S: |
case CV_32S: |
||||||
s = "CV_32S"; |
s = "CV_32S"; |
||||||
break; |
break; |
||||||
case CV_32F: |
case CV_32F: |
||||||
s = "CV_32F"; |
s = "CV_32F"; |
||||||
break; |
break; |
||||||
case CV_64F: |
case CV_64F: |
||||||
s = "CV_64F"; |
s = "CV_64F"; |
||||||
break; |
break; |
||||||
default: |
case CV_USRTYPE1: |
||||||
s = "CV_USRTYPE1"; |
s = "CV_USRTYPE1"; |
||||||
|
break; |
||||||
|
default: |
||||||
|
throw new java.lang.UnsupportedOperationException( |
||||||
|
"Unsupported CvType value: " + type); |
||||||
} |
} |
||||||
|
|
||||||
int ch = channels(type); |
int ch = channels(type); |
||||||
if(ch<=4) return s + "C" + ch; |
if (ch <= 4) |
||||||
else return s + "C(" + ch + ")"; |
return s + "C" + ch; |
||||||
|
else |
||||||
|
return s + "C(" + ch + ")"; |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,50 +1,61 @@ |
|||||||
package org.opencv.features2d; |
package org.opencv.features2d; |
||||||
|
|
||||||
//C++: class DMatch
|
//C++: class DMatch
|
||||||
//javadoc: DMatch
|
|
||||||
|
/** |
||||||
|
* Struct for matching: query descriptor index, train descriptor index, train |
||||||
|
* image index and distance between descriptors. |
||||||
|
*/ |
||||||
public class DMatch { |
public class DMatch { |
||||||
|
|
||||||
//javadoc: DMatch::queryIdx
|
/** |
||||||
public int queryIdx; |
* query descriptor index |
||||||
//javadoc: DMatch::trainIdx
|
*/ |
||||||
public int trainIdx; |
public int queryIdx; |
||||||
//javadoc: DMatch::imgIdx
|
/** |
||||||
public int imgIdx; |
* train descriptor index |
||||||
//javadoc: DMatch::distance
|
*/ |
||||||
public float distance; |
public int trainIdx; |
||||||
|
/** |
||||||
|
* train image index |
||||||
//javadoc: DMatch::DMatch()
|
*/ |
||||||
|
public int imgIdx; |
||||||
|
|
||||||
|
// javadoc: DMatch::distance
|
||||||
|
public float distance; |
||||||
|
|
||||||
|
// javadoc: DMatch::DMatch()
|
||||||
public DMatch() { |
public DMatch() { |
||||||
this(-1, -1, Float.MAX_VALUE); |
this(-1, -1, Float.MAX_VALUE); |
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public DMatch( int _queryIdx, int _trainIdx, float _distance ) { |
|
||||||
queryIdx = _queryIdx; |
|
||||||
trainIdx = _trainIdx; |
|
||||||
imgIdx = -1; |
|
||||||
distance = _distance; |
|
||||||
} |
} |
||||||
|
|
||||||
|
// javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _distance)
|
||||||
public DMatch( int _queryIdx, int _trainIdx, int _imgIdx, float _distance ) { |
public DMatch(int _queryIdx, int _trainIdx, float _distance) { |
||||||
queryIdx = _queryIdx; |
queryIdx = _queryIdx; |
||||||
trainIdx = _trainIdx; |
trainIdx = _trainIdx; |
||||||
imgIdx = _imgIdx; |
imgIdx = -1; |
||||||
distance = _distance; |
distance = _distance; |
||||||
} |
} |
||||||
|
|
||||||
// less is better
|
// javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _imgIdx, _distance)
|
||||||
|
public DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) { |
||||||
|
queryIdx = _queryIdx; |
||||||
|
trainIdx = _trainIdx; |
||||||
|
imgIdx = _imgIdx; |
||||||
|
distance = _distance; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* less is better |
||||||
|
*/ |
||||||
boolean lessThan(DMatch it) { |
boolean lessThan(DMatch it) { |
||||||
return distance < it.distance; |
return distance < it.distance; |
||||||
} |
} |
||||||
|
|
||||||
|
@Override |
||||||
@Override |
public String toString() { |
||||||
public String toString() { |
return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx |
||||||
return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx |
+ ", imgIdx=" + imgIdx + ", distance=" + distance + "]"; |
||||||
+ ", imgIdx=" + imgIdx + ", distance=" + distance + "]"; |
} |
||||||
} |
|
||||||
|
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue