Commit 3a1f85d4 authored by Andrey Kamaev's avatar Andrey Kamaev

Remerged the 2.4.0 branch

parent 77717e1a
#include "cap_ffmpeg_impl_v2.hpp"
#include "cap_ffmpeg_impl.hpp"
......@@ -56,7 +56,7 @@ version_patch = re.search("^W*#\W*define\W+CV_SUBMINOR_VERSION\W+(\d+)\W*$", ver
# The short X.Y version.
version = version_major + '.' + version_minor
# The full version, including alpha/beta/rc tags.
release = version_major + '.' + version_minor + '.' + version_patch + "-beta"
release = version_major + '.' + version_minor + '.' + version_patch
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -49,6 +49,8 @@
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, CAMERA_LOG_TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, CAMERA_LOG_TAG, __VA_ARGS__))
#include <dlfcn.h>
using namespace android;
void debugShowFPS()
......@@ -200,18 +202,25 @@ protected:
return strstr(supported_modes, mode) > 0;
}
float getFocusDistance(int focus_distance_type){
if (focus_distance_type >= 0 && focus_distance_type < 3) {
float getFocusDistance(int focus_distance_type)
{
#if !defined(ANDROID_r2_2_0)
if (focus_distance_type >= 0 && focus_distance_type < 3)
{
float focus_distances[3];
const char* output = params.get(CameraParameters::KEY_FOCUS_DISTANCES);
int val_num = CameraHandler::split_float(output, focus_distances, ',', 3);
if(val_num == 3){
if(val_num == 3)
{
return focus_distances[focus_distance_type];
} else {
}
else
{
LOGE("Invalid focus distances.");
}
}
return -1;
#endif
return -1;
}
static int getModeNum(const char** modes, const int modes_num, const char* mode_name)
......@@ -299,7 +308,9 @@ const char* CameraHandler::flashModesNames[ANDROID_CAMERA_FLASH_MODES_NUM] =
const char* CameraHandler::focusModesNames[ANDROID_CAMERA_FOCUS_MODES_NUM] =
{
CameraParameters::FOCUS_MODE_AUTO,
#if !defined(ANDROID_r2_2_0)
CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO,
#endif
CameraParameters::FOCUS_MODE_EDOF,
CameraParameters::FOCUS_MODE_FIXED,
CameraParameters::FOCUS_MODE_INFINITY
......@@ -326,17 +337,61 @@ const char* CameraHandler::antibandingModesNames[ANDROID_CAMERA_ANTIBANDING_MODE
CameraHandler* CameraHandler::initCameraConnect(const CameraCallback& callback, int cameraId, void* userData, CameraParameters* prevCameraParameters)
{
LOGD("CameraHandler::initCameraConnect(%p, %d, %p, %p)", callback, cameraId, userData, prevCameraParameters);
typedef sp<Camera> (*Android22ConnectFuncType)();
typedef sp<Camera> (*Android23ConnectFuncType)(int);
typedef sp<Camera> (*Android3DConnectFuncType)(int, int);
enum {
CAMERA_SUPPORT_MODE_2D = 0x01, /* Camera Sensor supports 2D mode. */
CAMERA_SUPPORT_MODE_3D = 0x02, /* Camera Sensor supports 3D mode. */
CAMERA_SUPPORT_MODE_NONZSL = 0x04, /* Camera Sensor in NON-ZSL mode. */
CAMERA_SUPPORT_MODE_ZSL = 0x08 /* Camera Sensor supports ZSL mode. */
};
const char Android22ConnectName[] = "_ZN7android6Camera7connectEv";
const char Android23ConnectName[] = "_ZN7android6Camera7connectEi";
const char Android3DConnectName[] = "_ZN7android6Camera7connectEii";
LOGD("CameraHandler::initCameraConnect(%p, %d, %p, %p)", callback, cameraId, userData, prevCameraParameters);
sp<Camera> camera = 0;
void* CameraHALHandle = dlopen("libcamera_client.so", RTLD_LAZY);
if (!CameraHALHandle)
{
LOGE("Cannot link to \"libcamera_client.so\"");
return NULL;
}
// reset errors
dlerror();
#ifdef ANDROID_r2_2_0
camera = Camera::connect();
#else
/* This is 2.3 or higher. The connect method has cameraID parameter */
camera = Camera::connect(cameraId);
#endif
if (Android22ConnectFuncType Android22Connect = (Android22ConnectFuncType)dlsym(CameraHALHandle, Android22ConnectName))
{
LOGD("Connecting to CameraService v 2.2");
camera = Android22Connect();
}
else if (Android23ConnectFuncType Android23Connect = (Android23ConnectFuncType)dlsym(CameraHALHandle, Android23ConnectName))
{
LOGD("Connecting to CameraService v 2.3");
camera = Android23Connect(cameraId);
}
else if (Android3DConnectFuncType Android3DConnect = (Android3DConnectFuncType)dlsym(CameraHALHandle, Android3DConnectName))
{
LOGD("Connecting to CameraService v 3D");
camera = Android3DConnect(cameraId, CAMERA_SUPPORT_MODE_2D);
}
else
{
dlclose(CameraHALHandle);
LOGE("Cannot connect to CameraService. Connect method was not found!");
return NULL;
}
dlclose(CameraHALHandle);
if ( 0 == camera.get() )
{
LOGE("initCameraConnect: Unable to connect to CameraService\n");
......
......@@ -75,7 +75,6 @@ void CV_ChessboardDetectorTimingTest::run( int start_from )
sprintf( filepath, "%scameracalibration/", ts->get_data_path().c_str() );
sprintf( filename, "%schessboard_timing_list.dat", filepath );
printf("Reading file %s\n", filename);
CvFileStorage* fs = cvOpenFileStorage( filename, 0, CV_STORAGE_READ );
CvFileNode* board_list = fs ? cvGetFileNodeByName( fs, 0, "boards" ) : 0;
......
......@@ -16,13 +16,7 @@ else()
set(cuda_link_libs "")
endif()
set(OPENCV_VERSION_FILE "${opencv_core_BINARY_DIR}/version_string.inc")
add_custom_command(OUTPUT "${OPENCV_VERSION_FILE}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${OPENCV_VERSION_FILE}"
MAIN_DEPENDENCY "${OPENCV_BUILD_INFO_FILE}"
COMMENT "")
ocv_glob_module_sources(SOURCES ${lib_cuda} ${cuda_objs} "${OPENCV_VERSION_FILE}")
ocv_glob_module_sources(SOURCES ${lib_cuda} ${cuda_objs} "${opencv_core_BINARY_DIR}/version_string.inc")
ocv_create_module(${cuda_link_libs})
ocv_add_precompiled_headers(${the_module})
......
......@@ -97,7 +97,7 @@ namespace cv { namespace gpu { namespace device
}
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
__device__ void loopUnrolledCached(int queryIdx, const DevMem2D_<T>& query, int imgIdx, const DevMem2D_<T>& train, const Mask& mask,
__device__ void loopUnrolledCached(int queryIdx, const DevMem2D_<T>& query,volatile int imgIdx, const DevMem2D_<T>& train, const Mask& mask,
typename Dist::value_type* s_query, typename Dist::value_type* s_train,
float& bestDistance, int& bestTrainIdx, int& bestImgIdx)
{
......@@ -253,7 +253,7 @@ namespace cv { namespace gpu { namespace device
// Match Unrolled
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
__device__ void loopUnrolled(int queryIdx, const DevMem2D_<T>& query, int imgIdx, const DevMem2D_<T>& train, const Mask& mask,
__device__ void loopUnrolled(int queryIdx, const DevMem2D_<T>& query,volatile int imgIdx, const DevMem2D_<T>& train, const Mask& mask,
typename Dist::value_type* s_query, typename Dist::value_type* s_train,
float& bestDistance, int& bestTrainIdx, int& bestImgIdx)
{
......@@ -409,7 +409,7 @@ namespace cv { namespace gpu { namespace device
// Match
template <int BLOCK_SIZE, typename Dist, typename T, typename Mask>
__device__ void loop(int queryIdx, const DevMem2D_<T>& query, int imgIdx, const DevMem2D_<T>& train, const Mask& mask,
__device__ void loop(int queryIdx, const DevMem2D_<T>& query, volatile int imgIdx, const DevMem2D_<T>& train, const Mask& mask,
typename Dist::value_type* s_query, typename Dist::value_type* s_train,
float& bestDistance, int& bestTrainIdx, int& bestImgIdx)
{
......
......@@ -126,18 +126,19 @@ void cv::gpu::PyrLKOpticalFlow::buildImagePyramid(const GpuMat& img0, vector<Gpu
namespace
{
void calcPatchSize(cv::Size winSize, int cn, dim3& block, dim3& patch)
void calcPatchSize(cv::Size winSize, int cn, dim3& block, dim3& patch, bool isDeviceArch11)
{
winSize.width *= cn;
if (winSize.width > 32 && winSize.width > 2 * winSize.height)
{
block.x = 32;
block.x = isDeviceArch11 ? 16 : 32;
block.y = 8;
}
else
{
block.x = block.y = 16;
block.x = 16;
block.y = isDeviceArch11 ? 8 : 16;
}
patch.x = (winSize.width + block.x - 1) / block.x;
......@@ -166,7 +167,7 @@ void cv::gpu::PyrLKOpticalFlow::sparse(const GpuMat& prevImg, const GpuMat& next
const int cn = prevImg.channels();
dim3 block, patch;
calcPatchSize(winSize, cn, block, patch);
calcPatchSize(winSize, cn, block, patch, isDeviceArch11_);
CV_Assert(derivLambda >= 0);
CV_Assert(maxLevel >= 0 && winSize.width > 2 && winSize.height > 2);
......
......@@ -42,11 +42,7 @@
#include "precomp.hpp"
#ifdef HAVE_FFMPEG
#ifdef NEW_FFMPEG
#include "cap_ffmpeg_impl_v2.hpp"
#else
#include "cap_ffmpeg_impl.hpp"
#endif
#else
#include "cap_ffmpeg_api.hpp"
#endif
......
This diff is collapsed.
This diff is collapsed.
......@@ -19,8 +19,6 @@ import org.opencv.features2d.KeyPoint;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
import android.util.Log;
public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
DescriptorMatcher matcher;
......@@ -173,8 +171,6 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
Mat query = getQueryDescriptors();
List<MatOfDMatch> matches = new ArrayList<MatOfDMatch>();
matcher.knnMatch(query, train, matches, k);
Log.d("knnMatch", "train = " + train);
Log.d("knnMatch", "query = " + query);
/*
Log.d("knnMatch", "train = " + train);
Log.d("knnMatch", "query = " + query);
......
This diff is collapsed.
This diff is collapsed.
......@@ -68,7 +68,6 @@ void vector_vector_Point_to_Mat(std::vector< std::vector< cv::Point > >& vv_pt,
void Mat_to_vector_vector_Point2f(cv::Mat& mat, std::vector< std::vector< cv::Point2f > >& vv_pt);
void vector_vector_Point2f_to_Mat(std::vector< std::vector< cv::Point2f > >& vv_pt, cv::Mat& mat);
void vector_vector_Point_to_Mat(std::vector< std::vector< cv::Point > >& vv_pt, cv::Mat& mat);
void Mat_to_vector_vector_Point3f(cv::Mat& mat, std::vector< std::vector< cv::Point3f > >& vv_pt);
void vector_vector_Point3f_to_Mat(std::vector< std::vector< cv::Point3f > >& vv_pt, cv::Mat& mat);
......@@ -4,38 +4,34 @@ import java.util.Arrays;
import java.util.List;
public class MatOfByte extends Mat {
// 8UC(x)
private static final int _depth = CvType.CV_8U;
private final int _channels;
public MatOfByte(int channels) {
super();
_channels = channels;
}
// 8UC(x)
private static final int _depth = CvType.CV_8U;
private static final int _channels = 1;
public MatOfByte() {
this(1);
super();
}
public MatOfByte(int channels, long addr) {
protected MatOfByte(long addr) {
super(addr);
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfByte(int channels, Mat m) {
super(m, Range.all());
_channels = channels;
public static MatOfByte fromNativeAddr(long addr) {
return new MatOfByte(addr);
}
public MatOfByte(Mat m) {
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfByte(int channels, byte...a) {
public MatOfByte(byte...a) {
super();
_channels = channels;
fromArray(a);
}
......@@ -51,9 +47,11 @@ public class MatOfByte extends Mat {
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public byte[] toArray() {
int num = (int) total();
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
byte[] a = new byte[num * _channels];
if(num == 0)
return a;
......@@ -62,20 +60,20 @@ public class MatOfByte extends Mat {
}
public void fromList(List<Byte> lb) {
if(lb==null || lb.size()==0)
return;
Byte ab[] = lb.toArray(null);
byte a[] = new byte[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
if(lb==null || lb.size()==0)
return;
Byte ab[] = lb.toArray(new Byte[0]);
byte a[] = new byte[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Byte> toList() {
byte[] a = toArray();
Byte ab[] = new Byte[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
byte[] a = toArray();
Byte ab[] = new Byte[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}
......@@ -6,23 +6,27 @@ import java.util.List;
import org.opencv.features2d.DMatch;
public class MatOfDMatch extends Mat {
// 32FC4
private static final int _depth = CvType.CV_32F;
private static final int _channels = 4;
// 32FC4
private static final int _depth = CvType.CV_32F;
private static final int _channels = 4;
public MatOfDMatch() {
super();
}
public MatOfDMatch(long addr) {
protected MatOfDMatch(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfDMatch fromNativeAddr(long addr) {
return new MatOfDMatch(addr);
}
public MatOfDMatch(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
......@@ -32,7 +36,7 @@ public class MatOfDMatch extends Mat {
super();
fromArray(ap);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
......@@ -68,12 +72,12 @@ public class MatOfDMatch extends Mat {
}
public void fromList(List<DMatch> ldm) {
DMatch adm[] = ldm.toArray(null);
fromArray(adm);
DMatch adm[] = ldm.toArray(new DMatch[0]);
fromArray(adm);
}
public List<DMatch> toList() {
DMatch[] adm = toArray();
return Arrays.asList(adm);
DMatch[] adm = toArray();
return Arrays.asList(adm);
}
}
......@@ -4,38 +4,34 @@ import java.util.Arrays;
import java.util.List;
public class MatOfDouble extends Mat {
// 64FC(x)
private static final int _depth = CvType.CV_64F;
private final int _channels;
public MatOfDouble(int channels) {
super();
_channels = channels;
}
// 64FC(x)
private static final int _depth = CvType.CV_64F;
private static final int _channels = 1;
public MatOfDouble() {
this(1);
super();
}
public MatOfDouble(int channels, long addr) {
protected MatOfDouble(long addr) {
super(addr);
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfDouble(int channels, Mat m) {
super(m, Range.all());
_channels = channels;
public static MatOfDouble fromNativeAddr(long addr) {
return new MatOfDouble(addr);
}
public MatOfDouble(Mat m) {
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfDouble(int channels, double...a) {
public MatOfDouble(double...a) {
super();
_channels = channels;
fromArray(a);
}
......@@ -51,9 +47,11 @@ public class MatOfDouble extends Mat {
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public double[] toArray() {
int num = (int) total();
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
double[] a = new double[num * _channels];
if(num == 0)
return a;
......@@ -62,20 +60,20 @@ public class MatOfDouble extends Mat {
}
public void fromList(List<Double> lb) {
if(lb==null || lb.size()==0)
return;
Double ab[] = lb.toArray(null);
double a[] = new double[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
if(lb==null || lb.size()==0)
return;
Double ab[] = lb.toArray(new Double[0]);
double a[] = new double[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Double> toList() {
double[] a = toArray();
Double ab[] = new Double[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
double[] a = toArray();
Double ab[] = new Double[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}
......@@ -4,38 +4,34 @@ import java.util.Arrays;
import java.util.List;
public class MatOfFloat extends Mat {
// 32FC(x)
private static final int _depth = CvType.CV_32F;
private final int _channels;
public MatOfFloat(int channels) {
super();
_channels = channels;
}
// 32FC1
private static final int _depth = CvType.CV_32F;
private static final int _channels = 1;
public MatOfFloat() {
this(1);
super();
}
public MatOfFloat(int channels, long addr) {
protected MatOfFloat(long addr) {
super(addr);
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfFloat fromNativeAddr(long addr) {
return new MatOfFloat(addr);
}
public MatOfFloat(int channels, Mat m) {
super(m, Range.all());
_channels = channels;
public MatOfFloat(Mat m) {
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfFloat(int channels, float...a) {
public MatOfFloat(float...a) {
super();
_channels = channels;
fromArray(a);
}
......@@ -51,9 +47,11 @@ public class MatOfFloat extends Mat {
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public float[] toArray() {
int num = (int) total();
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
float[] a = new float[num * _channels];
if(num == 0)
return a;
......@@ -62,20 +60,20 @@ public class MatOfFloat extends Mat {
}
public void fromList(List<Float> lb) {
if(lb==null || lb.size()==0)
return;
Float ab[] = lb.toArray(null);
float a[] = new float[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
if(lb==null || lb.size()==0)
return;
Float ab[] = lb.toArray(new Float[0]);
float a[] = new float[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Float> toList() {
float[] a = toArray();
Float ab[] = new Float[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
float[] a = toArray();
Float ab[] = new Float[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}
......@@ -5,38 +5,34 @@ import java.util.List;
public class MatOfInt extends Mat {
// 32SC(x)
private static final int _depth = CvType.CV_32S;
private final int _channels;
public MatOfInt(int channels) {
super();
_channels = channels;
}
// 32SC1
private static final int _depth = CvType.CV_32S;
private static final int _channels = 1;
public MatOfInt() {
this(1);
super();
}
public MatOfInt(int channels, long addr) {
protected MatOfInt(long addr) {
super(addr);
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfInt(int channels, Mat m) {
super(m, Range.all());
_channels = channels;
public static MatOfInt fromNativeAddr(long addr) {
return new MatOfInt(addr);
}
public MatOfInt(Mat m) {
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfInt(int channels, int...a) {
public MatOfInt(int...a) {
super();
_channels = channels;
fromArray(a);
}
......@@ -52,9 +48,11 @@ public class MatOfInt extends Mat {
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public int[] toArray() {
int num = (int) total();
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
int[] a = new int[num * _channels];
if(num == 0)
return a;
......@@ -63,20 +61,20 @@ public class MatOfInt extends Mat {
}
public void fromList(List<Integer> lb) {
if(lb==null || lb.size()==0)
return;
Integer ab[] = lb.toArray(null);
int a[] = new int[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
if(lb==null || lb.size()==0)
return;
Integer ab[] = lb.toArray(new Integer[0]);
int a[] = new int[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Integer> toList() {
int[] a = toArray();
Integer ab[] = new Integer[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
int[] a = toArray();
Integer ab[] = new Integer[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}
......@@ -6,23 +6,27 @@ import java.util.List;
import org.opencv.features2d.KeyPoint;
public class MatOfKeyPoint extends Mat {
// 32FC7
private static final int _depth = CvType.CV_32F;
private static final int _channels = 7;
// 32FC7
private static final int _depth = CvType.CV_32F;
private static final int _channels = 7;
public MatOfKeyPoint() {
super();
}
public MatOfKeyPoint(long addr) {
protected MatOfKeyPoint(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfKeyPoint fromNativeAddr(long addr) {
return new MatOfKeyPoint(addr);
}
public MatOfKeyPoint(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
......@@ -32,7 +36,7 @@ public class MatOfKeyPoint extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
......@@ -71,12 +75,12 @@ public class MatOfKeyPoint extends Mat {
}
public void fromList(List<KeyPoint> lkp) {
KeyPoint akp[] = lkp.toArray(null);
fromArray(akp);
KeyPoint akp[] = lkp.toArray(new KeyPoint[0]);
fromArray(akp);
}
public List<KeyPoint> toList() {
KeyPoint[] akp = toArray();
return Arrays.asList(akp);
KeyPoint[] akp = toArray();
return Arrays.asList(akp);
}
}
......@@ -4,23 +4,27 @@ import java.util.Arrays;
import java.util.List;
public class MatOfPoint extends Mat {
// 32SC2
private static final int _depth = CvType.CV_32S;
private static final int _channels = 2;
// 32SC2
private static final int _depth = CvType.CV_32S;
private static final int _channels = 2;
public MatOfPoint() {
super();
}
public MatOfPoint(long addr) {
protected MatOfPoint(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint fromNativeAddr(long addr) {
return new MatOfPoint(addr);
}
public MatOfPoint(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
......@@ -30,7 +34,7 @@ public class MatOfPoint extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
......@@ -49,7 +53,7 @@ public class MatOfPoint extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Point[] toArray() {
int num = (int) total();
Point[] ap = new Point[num];
......@@ -63,12 +67,12 @@ public class MatOfPoint extends Mat {
}
public void fromList(List<Point> lp) {
Point ap[] = lp.toArray(null);
fromArray(ap);
Point ap[] = lp.toArray(new Point[0]);
fromArray(ap);
}
public List<Point> toList() {
Point[] ap = toArray();
return Arrays.asList(ap);
Point[] ap = toArray();
return Arrays.asList(ap);
}
}
......@@ -4,23 +4,27 @@ import java.util.Arrays;
import java.util.List;
public class MatOfPoint2f extends Mat {
// 32FC2
private static final int _depth = CvType.CV_32F;
private static final int _channels = 2;
// 32FC2
private static final int _depth = CvType.CV_32F;
private static final int _channels = 2;
public MatOfPoint2f() {
super();
}
public MatOfPoint2f(long addr) {
protected MatOfPoint2f(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint2f fromNativeAddr(long addr) {
return new MatOfPoint2f(addr);
}
public MatOfPoint2f(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
......@@ -30,7 +34,7 @@ public class MatOfPoint2f extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
......@@ -49,7 +53,7 @@ public class MatOfPoint2f extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Point[] toArray() {
int num = (int) total();
Point[] ap = new Point[num];
......@@ -63,12 +67,12 @@ public class MatOfPoint2f extends Mat {
}
public void fromList(List<Point> lp) {
Point ap[] = lp.toArray(null);
fromArray(ap);
Point ap[] = lp.toArray(new Point[0]);
fromArray(ap);
}
public List<Point> toList() {
Point[] ap = toArray();
return Arrays.asList(ap);
Point[] ap = toArray();
return Arrays.asList(ap);
}
}
......@@ -4,23 +4,27 @@ import java.util.Arrays;
import java.util.List;
public class MatOfPoint3 extends Mat {
// 32SC3
private static final int _depth = CvType.CV_32S;
private static final int _channels = 3;
// 32SC3
private static final int _depth = CvType.CV_32S;
private static final int _channels = 3;
public MatOfPoint3() {
super();
}
public MatOfPoint3(long addr) {
protected MatOfPoint3(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint3 fromNativeAddr(long addr) {
return new MatOfPoint3(addr);
}
public MatOfPoint3(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
......@@ -30,7 +34,7 @@ public class MatOfPoint3 extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
......@@ -50,7 +54,7 @@ public class MatOfPoint3 extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Point3[] toArray() {
int num = (int) total();
Point3[] ap = new Point3[num];
......@@ -64,12 +68,12 @@ public class MatOfPoint3 extends Mat {
}
public void fromList(List<Point3> lp) {
Point3 ap[] = lp.toArray(null);
fromArray(ap);
Point3 ap[] = lp.toArray(new Point3[0]);
fromArray(ap);
}
public List<Point3> toList() {
Point3[] ap = toArray();
return Arrays.asList(ap);
Point3[] ap = toArray();
return Arrays.asList(ap);
}
}
......@@ -4,23 +4,27 @@ import java.util.Arrays;
import java.util.List;
public class MatOfPoint3f extends Mat {
// 32FC3
private static final int _depth = CvType.CV_32F;
private static final int _channels = 3;
// 32FC3
private static final int _depth = CvType.CV_32F;
private static final int _channels = 3;
public MatOfPoint3f() {
super();
}
public MatOfPoint3f(long addr) {
protected MatOfPoint3f(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint3f fromNativeAddr(long addr) {
return new MatOfPoint3f(addr);
}
public MatOfPoint3f(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
......@@ -30,7 +34,7 @@ public class MatOfPoint3f extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
......@@ -50,7 +54,7 @@ public class MatOfPoint3f extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Point3[] toArray() {
int num = (int) total();
Point3[] ap = new Point3[num];
......@@ -64,12 +68,12 @@ public class MatOfPoint3f extends Mat {
}
public void fromList(List<Point3> lp) {
Point3 ap[] = lp.toArray(null);
fromArray(ap);
Point3 ap[] = lp.toArray(new Point3[0]);
fromArray(ap);
}
public List<Point3> toList() {
Point3[] ap = toArray();
return Arrays.asList(ap);
Point3[] ap = toArray();
return Arrays.asList(ap);
}
}
......@@ -5,23 +5,27 @@ import java.util.List;
public class MatOfRect extends Mat {
// 32SC4
private static final int _depth = CvType.CV_32S;
private static final int _channels = 4;
// 32SC4
private static final int _depth = CvType.CV_32S;
private static final int _channels = 4;
public MatOfRect() {
super();
}
public MatOfRect(long addr) {
protected MatOfRect(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfRect fromNativeAddr(long addr) {
return new MatOfRect(addr);
}
public MatOfRect(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
......@@ -31,7 +35,7 @@ public class MatOfRect extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
......@@ -44,7 +48,7 @@ public class MatOfRect extends Mat {
alloc(num);
int buff[] = new int[num * _channels];
for(int i=0; i<num; i++) {
Rect r = a[i];
Rect r = a[i];
buff[_channels*i+0] = (int) r.x;
buff[_channels*i+1] = (int) r.y;
buff[_channels*i+2] = (int) r.width;
......@@ -52,7 +56,7 @@ public class MatOfRect extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Rect[] toArray() {
int num = (int) total();
......@@ -66,12 +70,12 @@ public class MatOfRect extends Mat {
return a;
}
public void fromList(List<Rect> lr) {
Rect ap[] = lr.toArray(null);
fromArray(ap);
Rect ap[] = lr.toArray(new Rect[0]);
fromArray(ap);
}
public List<Rect> toList() {
Rect[] ar = toArray();
return Arrays.asList(ar);
Rect[] ar = toArray();
return Arrays.asList(ar);
}
}
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright( C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
//(including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort(including negligence or otherwise) arising in any way out of
// the use of this software, even ifadvised of the possibility of such damage.
//
//M*/
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright( C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
//(including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort(including negligence or otherwise) arising in any way out of
// the use of this software, even ifadvised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
using namespace cv;
CvEMParams::CvEMParams() : nclusters(10), cov_mat_type(CvEM::COV_MAT_DIAGONAL),
start_step(CvEM::START_AUTO_STEP), probs(0), weights(0), means(0), covs(0)
start_step(CvEM::START_AUTO_STEP), probs(0), weights(0), means(0), covs(0)
{
term_crit=cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON );
}
CvEMParams::CvEMParams( int _nclusters, int _cov_mat_type, int _start_step,
CvTermCriteria _term_crit, const CvMat* _probs,
const CvMat* _weights, const CvMat* _means, const CvMat** _covs ) :
nclusters(_nclusters), cov_mat_type(_cov_mat_type), start_step(_start_step),
probs(_probs), weights(_weights), means(_means), covs(_covs), term_crit(_term_crit)
CvTermCriteria _term_crit, const CvMat* _probs,
const CvMat* _weights, const CvMat* _means, const CvMat** _covs ) :
nclusters(_nclusters), cov_mat_type(_cov_mat_type), start_step(_start_step),
probs(_probs), weights(_weights), means(_means), covs(_covs), term_crit(_term_crit)
{}
CvEM::CvEM() : logLikelihood(DBL_MAX)
......@@ -61,7 +61,7 @@ CvEM::CvEM() : logLikelihood(DBL_MAX)
}
CvEM::CvEM( const CvMat* samples, const CvMat* sample_idx,
CvEMParams params, CvMat* labels ) : logLikelihood(DBL_MAX)
CvEMParams params, CvMat* labels ) : logLikelihood(DBL_MAX)
{
train(samples, sample_idx, params, labels);
}
......@@ -142,7 +142,7 @@ void init_params(const CvEMParams& src,
prbs = src.probs;
weights = src.weights;
means = src.means;
if(src.covs)
{
covsHdrs.resize(src.nclusters);
......@@ -152,7 +152,7 @@ void init_params(const CvEMParams& src,
}
bool CvEM::train( const CvMat* _samples, const CvMat* _sample_idx,
CvEMParams _params, CvMat* _labels )
CvEMParams _params, CvMat* _labels )
{
CV_Assert(_sample_idx == 0);
Mat samples = cvarrToMat(_samples), labels0, labels;
......@@ -161,7 +161,7 @@ bool CvEM::train( const CvMat* _samples, const CvMat* _sample_idx,
bool isOk = train(samples, Mat(), _params, _labels ? &labels : 0);
CV_Assert( labels0.data == labels.data );
return isOk;
}
......@@ -204,7 +204,7 @@ bool CvEM::train( const Mat& _samples, const Mat& _sample_idx,
Mat prbs, weights, means, logLikelihoods;
std::vector<Mat> covsHdrs;
init_params(_params, prbs, weights, means, covsHdrs);
emObj = EM(_params.nclusters, _params.cov_mat_type, _params.term_crit);
bool isOk = false;
if( _params.start_step == EM::START_AUTO_STEP )
......@@ -224,7 +224,7 @@ bool CvEM::train( const Mat& _samples, const Mat& _sample_idx,
logLikelihood = sum(logLikelihoods).val[0];
set_mat_hdrs();
}
return isOk;
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment