mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 05:06:29 +08:00
moved some old stuff to the legacy module; merge "compat_c.h" headers and moved to the legacy as well. moved implementation of many non-critical/obsolete inline functions and methods to .cpp to improve Opencv build time
This commit is contained in:
parent
fbdb4f4ab5
commit
54ef4c08c2
@ -745,6 +745,4 @@ CV_EXPORTS_W void reprojectImageTo3D( const Mat& disparity,
|
||||
|
||||
#endif
|
||||
|
||||
#include "opencv2/calib3d/compat_c.h"
|
||||
|
||||
#endif
|
||||
|
@ -1,286 +0,0 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., 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 the copyright holders 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 if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CALIB3D_COMPAT_C_H__
|
||||
#define __OPENCV_CALIB3D_COMPAT_C_H__
|
||||
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined __cplusplus && defined _MSC_VER && _MSC_VER >= 1400
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4100)
|
||||
#endif
|
||||
|
||||
/* Find fundamental matrix */
|
||||
CV_INLINE void cvFindFundamentalMatrix( int* points1, int* points2,
|
||||
int numpoints, int CV_UNREFERENCED(method), float* matrix )
|
||||
{
|
||||
CvMat* pointsMat1;
|
||||
CvMat* pointsMat2;
|
||||
CvMat fundMatr = cvMat(3,3,CV_32F,matrix);
|
||||
int i, curr = 0;
|
||||
|
||||
pointsMat1 = cvCreateMat(3,numpoints,CV_64F);
|
||||
pointsMat2 = cvCreateMat(3,numpoints,CV_64F);
|
||||
|
||||
for( i = 0; i < numpoints; i++ )
|
||||
{
|
||||
cvmSet(pointsMat1,0,i,points1[curr]);//x
|
||||
cvmSet(pointsMat1,1,i,points1[curr+1]);//y
|
||||
cvmSet(pointsMat1,2,i,1.0);
|
||||
|
||||
cvmSet(pointsMat2,0,i,points2[curr]);//x
|
||||
cvmSet(pointsMat2,1,i,points2[curr+1]);//y
|
||||
cvmSet(pointsMat2,2,i,1.0);
|
||||
curr += 2;
|
||||
}
|
||||
|
||||
cvFindFundamentalMat(pointsMat1,pointsMat2,&fundMatr,CV_FM_RANSAC,1,0.99,0);
|
||||
|
||||
cvReleaseMat(&pointsMat1);
|
||||
cvReleaseMat(&pointsMat2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
CV_INLINE int
|
||||
cvFindChessBoardCornerGuesses( const void* arr, void* CV_UNREFERENCED(thresharr),
|
||||
CvMemStorage * CV_UNREFERENCED(storage),
|
||||
CvSize pattern_size, CvPoint2D32f * corners,
|
||||
int *corner_count )
|
||||
{
|
||||
return cvFindChessboardCorners( arr, pattern_size, corners,
|
||||
corner_count, CV_CALIB_CB_ADAPTIVE_THRESH );
|
||||
}
|
||||
|
||||
|
||||
/* Calibrates camera using multiple views of calibration pattern */
|
||||
CV_INLINE void cvCalibrateCamera( int image_count, int* _point_counts,
|
||||
CvSize image_size, CvPoint2D32f* _image_points, CvPoint3D32f* _object_points,
|
||||
float* _distortion_coeffs, float* _camera_matrix, float* _translation_vectors,
|
||||
float* _rotation_matrices, int flags )
|
||||
{
|
||||
int i, total = 0;
|
||||
CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts );
|
||||
CvMat image_points, object_points;
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs );
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, _camera_matrix );
|
||||
CvMat rotation_matrices = cvMat( image_count, 9, CV_32FC1, _rotation_matrices );
|
||||
CvMat translation_vectors = cvMat( image_count, 3, CV_32FC1, _translation_vectors );
|
||||
|
||||
for( i = 0; i < image_count; i++ )
|
||||
total += _point_counts[i];
|
||||
|
||||
image_points = cvMat( total, 1, CV_32FC2, _image_points );
|
||||
object_points = cvMat( total, 1, CV_32FC3, _object_points );
|
||||
|
||||
cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size,
|
||||
&camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors,
|
||||
flags );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvCalibrateCamera_64d( int image_count, int* _point_counts,
|
||||
CvSize image_size, CvPoint2D64f* _image_points, CvPoint3D64f* _object_points,
|
||||
double* _distortion_coeffs, double* _camera_matrix, double* _translation_vectors,
|
||||
double* _rotation_matrices, int flags )
|
||||
{
|
||||
int i, total = 0;
|
||||
CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts );
|
||||
CvMat image_points, object_points;
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs );
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix );
|
||||
CvMat rotation_matrices = cvMat( image_count, 9, CV_64FC1, _rotation_matrices );
|
||||
CvMat translation_vectors = cvMat( image_count, 3, CV_64FC1, _translation_vectors );
|
||||
|
||||
for( i = 0; i < image_count; i++ )
|
||||
total += _point_counts[i];
|
||||
|
||||
image_points = cvMat( total, 1, CV_64FC2, _image_points );
|
||||
object_points = cvMat( total, 1, CV_64FC3, _object_points );
|
||||
|
||||
cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size,
|
||||
&camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors,
|
||||
flags );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Find 3d position of object given intrinsic camera parameters,
|
||||
3d model of the object and projection of the object into view plane */
|
||||
CV_INLINE void cvFindExtrinsicCameraParams( int point_count,
|
||||
CvSize CV_UNREFERENCED(image_size), CvPoint2D32f* _image_points,
|
||||
CvPoint3D32f* _object_points, float* focal_length,
|
||||
CvPoint2D32f principal_point, float* _distortion_coeffs,
|
||||
float* _rotation_vector, float* _translation_vector )
|
||||
{
|
||||
CvMat image_points = cvMat( point_count, 1, CV_32FC2, _image_points );
|
||||
CvMat object_points = cvMat( point_count, 1, CV_32FC3, _object_points );
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs );
|
||||
float a[9];
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, a );
|
||||
CvMat rotation_vector = cvMat( 1, 1, CV_32FC3, _rotation_vector );
|
||||
CvMat translation_vector = cvMat( 1, 1, CV_32FC3, _translation_vector );
|
||||
|
||||
a[0] = focal_length[0]; a[4] = focal_length[1];
|
||||
a[2] = principal_point.x; a[5] = principal_point.y;
|
||||
a[1] = a[3] = a[6] = a[7] = 0.f;
|
||||
a[8] = 1.f;
|
||||
|
||||
cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix,
|
||||
&dist_coeffs, &rotation_vector, &translation_vector, 0 );
|
||||
}
|
||||
|
||||
|
||||
/* Variant of the previous function that takes double-precision parameters */
|
||||
CV_INLINE void cvFindExtrinsicCameraParams_64d( int point_count,
|
||||
CvSize CV_UNREFERENCED(image_size), CvPoint2D64f* _image_points,
|
||||
CvPoint3D64f* _object_points, double* focal_length,
|
||||
CvPoint2D64f principal_point, double* _distortion_coeffs,
|
||||
double* _rotation_vector, double* _translation_vector )
|
||||
{
|
||||
CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points );
|
||||
CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points );
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs );
|
||||
double a[9];
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a );
|
||||
CvMat rotation_vector = cvMat( 1, 1, CV_64FC3, _rotation_vector );
|
||||
CvMat translation_vector = cvMat( 1, 1, CV_64FC3, _translation_vector );
|
||||
|
||||
a[0] = focal_length[0]; a[4] = focal_length[1];
|
||||
a[2] = principal_point.x; a[5] = principal_point.y;
|
||||
a[1] = a[3] = a[6] = a[7] = 0.;
|
||||
a[8] = 1.;
|
||||
|
||||
cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix,
|
||||
&dist_coeffs, &rotation_vector, &translation_vector, 0 );
|
||||
}
|
||||
|
||||
|
||||
/* Rodrigues transform */
|
||||
#define CV_RODRIGUES_M2V 0
|
||||
#define CV_RODRIGUES_V2M 1
|
||||
|
||||
/* Converts rotation_matrix matrix to rotation_matrix vector or vice versa */
|
||||
CV_INLINE void cvRodrigues( CvMat* rotation_matrix, CvMat* rotation_vector,
|
||||
CvMat* jacobian, int conv_type )
|
||||
{
|
||||
if( conv_type == CV_RODRIGUES_V2M )
|
||||
cvRodrigues2( rotation_vector, rotation_matrix, jacobian );
|
||||
else
|
||||
cvRodrigues2( rotation_matrix, rotation_vector, jacobian );
|
||||
}
|
||||
|
||||
|
||||
/* Does reprojection of 3d object points to the view plane */
|
||||
CV_INLINE void cvProjectPoints( int point_count, CvPoint3D64f* _object_points,
|
||||
double* _rotation_vector, double* _translation_vector,
|
||||
double* focal_length, CvPoint2D64f principal_point,
|
||||
double* _distortion, CvPoint2D64f* _image_points,
|
||||
double* _deriv_points_rotation_matrix,
|
||||
double* _deriv_points_translation_vect,
|
||||
double* _deriv_points_focal,
|
||||
double* _deriv_points_principal_point,
|
||||
double* _deriv_points_distortion_coeffs )
|
||||
{
|
||||
CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points );
|
||||
CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points );
|
||||
CvMat rotation_vector = cvMat( 3, 1, CV_64FC1, _rotation_vector );
|
||||
CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector );
|
||||
double a[9];
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a );
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion );
|
||||
CvMat dpdr = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_rotation_matrix );
|
||||
CvMat dpdt = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_translation_vect );
|
||||
CvMat dpdf = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_focal );
|
||||
CvMat dpdc = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_principal_point );
|
||||
CvMat dpdk = cvMat( 2*point_count, 4, CV_64FC1, _deriv_points_distortion_coeffs );
|
||||
|
||||
a[0] = focal_length[0]; a[4] = focal_length[1];
|
||||
a[2] = principal_point.x; a[5] = principal_point.y;
|
||||
a[1] = a[3] = a[6] = a[7] = 0.;
|
||||
a[8] = 1.;
|
||||
|
||||
cvProjectPoints2( &object_points, &rotation_vector, &translation_vector,
|
||||
&camera_matrix, &dist_coeffs, &image_points,
|
||||
&dpdr, &dpdt, &dpdf, &dpdc, &dpdk, 0 );
|
||||
}
|
||||
|
||||
|
||||
/* Simpler version of the previous function */
|
||||
CV_INLINE void cvProjectPointsSimple( int point_count, CvPoint3D64f* _object_points,
|
||||
double* _rotation_matrix, double* _translation_vector,
|
||||
double* _camera_matrix, double* _distortion, CvPoint2D64f* _image_points )
|
||||
{
|
||||
CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points );
|
||||
CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points );
|
||||
CvMat rotation_matrix = cvMat( 3, 3, CV_64FC1, _rotation_matrix );
|
||||
CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector );
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix );
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion );
|
||||
|
||||
cvProjectPoints2( &object_points, &rotation_matrix, &translation_vector,
|
||||
&camera_matrix, &dist_coeffs, &image_points,
|
||||
0, 0, 0, 0, 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
#define cvMake2DPoints cvConvertPointsHomogeneous
|
||||
#define cvMake3DPoints cvConvertPointsHomogeneous
|
||||
|
||||
#define cvWarpPerspectiveQMatrix cvGetPerspectiveTransform
|
||||
|
||||
#define cvConvertPointsHomogenious cvConvertPointsHomogeneous
|
||||
|
||||
#if !defined __cplusplus && defined _MSC_VER && _MSC_VER >= 1400
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -780,6 +780,4 @@ CVAPI(void) cvLSHQuery(struct CvLSH* lsh, const CvMat* query_points,
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "opencv2/imgproc/compat_c.h"
|
||||
|
||||
#endif
|
||||
|
@ -46,6 +46,7 @@
|
||||
/* Turn off the functionality until cvaux/src/Makefile.am gets updated: */
|
||||
//#if _MSC_VER >= 1200
|
||||
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#if _MSC_VER >= 1200 || defined __BORLANDC__
|
||||
@ -88,343 +89,63 @@ private: /* Internal data: */
|
||||
protected:
|
||||
int m_Wnd;
|
||||
public: /* Constructor and destructor: */
|
||||
CvVSModule()
|
||||
{
|
||||
m_pNickName = NULL;
|
||||
m_pParamList = NULL;
|
||||
m_pModuleTypeName = NULL;
|
||||
m_pModuleName = NULL;
|
||||
m_Wnd = 0;
|
||||
AddParam("DebugWnd",&m_Wnd);
|
||||
}
|
||||
virtual ~CvVSModule()
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;p;)
|
||||
{
|
||||
CvDefParam* pf = p;
|
||||
p=p->next;
|
||||
FreeParam(&pf);
|
||||
}
|
||||
m_pParamList=NULL;
|
||||
if(m_pModuleTypeName)free(m_pModuleTypeName);
|
||||
if(m_pModuleName)free(m_pModuleName);
|
||||
}
|
||||
CvVSModule();
|
||||
virtual ~CvVSModule();
|
||||
private: /* Internal functions: */
|
||||
void FreeParam(CvDefParam** pp)
|
||||
{
|
||||
CvDefParam* p = pp[0];
|
||||
if(p->Str)free(p->Str);
|
||||
if(p->pName)free(p->pName);
|
||||
if(p->pComment)free(p->pComment);
|
||||
cvFree(pp);
|
||||
}
|
||||
CvDefParam* NewParam(const char* name)
|
||||
{
|
||||
CvDefParam* pNew = (CvDefParam*)cvAlloc(sizeof(CvDefParam));
|
||||
memset(pNew,0,sizeof(CvDefParam));
|
||||
pNew->pName = strdup(name);
|
||||
if(m_pParamList==NULL)
|
||||
{
|
||||
m_pParamList = pNew;
|
||||
}
|
||||
else
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;p->next;p=p->next) ;
|
||||
p->next = pNew;
|
||||
}
|
||||
return pNew;
|
||||
};
|
||||
|
||||
CvDefParam* GetParamPtr(int index)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;index>0 && p;index--,p=p->next) ;
|
||||
return p;
|
||||
}
|
||||
CvDefParam* GetParamPtr(const char* name)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;p;p=p->next)
|
||||
{
|
||||
if(cv_stricmp(p->pName,name)==0) break;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
void FreeParam(CvDefParam** pp);
|
||||
CvDefParam* NewParam(const char* name);
|
||||
CvDefParam* GetParamPtr(int index);
|
||||
CvDefParam* GetParamPtr(const char* name);
|
||||
protected: /* INTERNAL INTERFACE */
|
||||
int IsParam(const char* name)
|
||||
{
|
||||
return GetParamPtr(name)?1:0;
|
||||
};
|
||||
void AddParam(const char* name, double* pAddr)
|
||||
{
|
||||
NewParam(name)->pDouble = pAddr;
|
||||
};
|
||||
void AddParam(const char* name, float* pAddr)
|
||||
{
|
||||
NewParam(name)->pFloat=pAddr;
|
||||
};
|
||||
void AddParam(const char* name, int* pAddr)
|
||||
{
|
||||
NewParam(name)->pInt=pAddr;
|
||||
};
|
||||
void AddParam(const char* name, const char** pAddr)
|
||||
{
|
||||
CvDefParam* pP = NewParam(name);
|
||||
const char* p = pAddr?pAddr[0]:NULL;
|
||||
pP->pStr = pAddr?(char**)pAddr:&(pP->Str);
|
||||
if(p)
|
||||
{
|
||||
pP->Str = strdup(p);
|
||||
pP->pStr[0] = pP->Str;
|
||||
}
|
||||
};
|
||||
void AddParam(const char* name)
|
||||
{
|
||||
CvDefParam* p = NewParam(name);
|
||||
p->pDouble = &p->Double;
|
||||
};
|
||||
void CommentParam(const char* name, const char* pComment)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(name);
|
||||
if(p)p->pComment = pComment ? strdup(pComment) : 0;
|
||||
};
|
||||
void SetTypeName(const char* name){m_pModuleTypeName = strdup(name);}
|
||||
void SetModuleName(const char* name){m_pModuleName = strdup(name);}
|
||||
void DelParam(const char* name)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
CvDefParam* pPrev = NULL;
|
||||
for(;p;p=p->next)
|
||||
{
|
||||
if(cv_stricmp(p->pName,name)==0) break;
|
||||
pPrev = p;
|
||||
}
|
||||
if(p)
|
||||
{
|
||||
if(pPrev)
|
||||
{
|
||||
pPrev->next = p->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pParamList = p->next;
|
||||
}
|
||||
FreeParam(&p);
|
||||
}
|
||||
}/* DelParam */
|
||||
int IsParam(const char* name);
|
||||
void AddParam(const char* name, double* pAddr);
|
||||
void AddParam(const char* name, float* pAddr);
|
||||
void AddParam(const char* name, int* pAddr);
|
||||
void AddParam(const char* name, const char** pAddr);
|
||||
void AddParam(const char* name);
|
||||
void CommentParam(const char* name, const char* pComment);
|
||||
void SetTypeName(const char* name);
|
||||
void SetModuleName(const char* name);
|
||||
void DelParam(const char* name);
|
||||
|
||||
public: /* EXTERNAL INTERFACE */
|
||||
const char* GetParamName(int index)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(index);
|
||||
return p?p->pName:NULL;
|
||||
}
|
||||
const char* GetParamComment(const char* name)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(name);
|
||||
if(p && p->pComment) return p->pComment;
|
||||
return NULL;
|
||||
}
|
||||
double GetParam(const char* name)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(name);
|
||||
if(p)
|
||||
{
|
||||
if(p->pDouble) return p->pDouble[0];
|
||||
if(p->pFloat) return p->pFloat[0];
|
||||
if(p->pInt) return p->pInt[0];
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
const char* GetParamStr(const char* name)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(name);
|
||||
return p?p->Str:NULL;
|
||||
}
|
||||
void SetParam(const char* name, double val)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;p;p=p->next)
|
||||
{
|
||||
if(cv_stricmp(p->pName,name) != 0) continue;
|
||||
if(p->pDouble)p->pDouble[0] = val;
|
||||
if(p->pFloat)p->pFloat[0] = (float)val;
|
||||
if(p->pInt)p->pInt[0] = cvRound(val);
|
||||
}
|
||||
}
|
||||
void SetParamStr(const char* name, const char* str)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(; p; p=p->next)
|
||||
{
|
||||
if(cv_stricmp(p->pName,name) != 0) continue;
|
||||
if(p->pStr)
|
||||
{
|
||||
if(p->Str)free(p->Str);
|
||||
p->Str = NULL;
|
||||
if(str)p->Str = strdup(str);
|
||||
p->pStr[0] = p->Str;
|
||||
}
|
||||
}
|
||||
/* Convert to double and set: */
|
||||
if(str) SetParam(name,atof(str));
|
||||
}
|
||||
void TransferParamsFromChild(CvVSModule* pM, const char* prefix = NULL)
|
||||
{
|
||||
char tmp[1024];
|
||||
const char* FN = NULL;
|
||||
int i;
|
||||
for(i=0;;++i)
|
||||
{
|
||||
const char* N = pM->GetParamName(i);
|
||||
if(N == NULL) break;
|
||||
FN = N;
|
||||
if(prefix)
|
||||
{
|
||||
strcpy(tmp,prefix);
|
||||
strcat(tmp,"_");
|
||||
FN = strcat(tmp,N);
|
||||
}
|
||||
|
||||
if(!IsParam(FN))
|
||||
{
|
||||
if(pM->GetParamStr(N))
|
||||
{
|
||||
AddParam(FN,(const char**)NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddParam(FN);
|
||||
}
|
||||
}
|
||||
if(pM->GetParamStr(N))
|
||||
{
|
||||
const char* val = pM->GetParamStr(N);
|
||||
SetParamStr(FN,val);
|
||||
}
|
||||
else
|
||||
{
|
||||
double val = pM->GetParam(N);
|
||||
SetParam(FN,val);
|
||||
}
|
||||
CommentParam(FN, pM->GetParamComment(N));
|
||||
}/* transfer next param */
|
||||
}/* Transfer params */
|
||||
|
||||
void TransferParamsToChild(CvVSModule* pM, char* prefix = NULL)
|
||||
{
|
||||
char tmp[1024];
|
||||
int i;
|
||||
for(i=0;;++i)
|
||||
{
|
||||
const char* N = pM->GetParamName(i);
|
||||
if(N == NULL) break;
|
||||
if(prefix)
|
||||
{
|
||||
strcpy(tmp,prefix);
|
||||
strcat(tmp,"_");
|
||||
strcat(tmp,N);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(tmp,N);
|
||||
}
|
||||
|
||||
if(IsParam(tmp))
|
||||
{
|
||||
if(GetParamStr(tmp))
|
||||
pM->SetParamStr(N,GetParamStr(tmp));
|
||||
else
|
||||
pM->SetParam(N,GetParam(tmp));
|
||||
}
|
||||
}/* Transfer next parameter */
|
||||
pM->ParamUpdate();
|
||||
}/* Transfer params */
|
||||
|
||||
virtual void ParamUpdate(){};
|
||||
const char* GetTypeName()
|
||||
{
|
||||
return m_pModuleTypeName;
|
||||
}
|
||||
int IsModuleTypeName(const char* name)
|
||||
{
|
||||
return m_pModuleTypeName?(cv_stricmp(m_pModuleTypeName,name)==0):0;
|
||||
}
|
||||
char* GetModuleName()
|
||||
{
|
||||
return m_pModuleName;
|
||||
}
|
||||
int IsModuleName(const char* name)
|
||||
{
|
||||
return m_pModuleName?(cv_stricmp(m_pModuleName,name)==0):0;
|
||||
}
|
||||
void SetNickName(const char* pStr)
|
||||
{
|
||||
if(m_pNickName)
|
||||
free(m_pNickName);
|
||||
|
||||
m_pNickName = NULL;
|
||||
|
||||
if(pStr)
|
||||
m_pNickName = strdup(pStr);
|
||||
}
|
||||
const char* GetNickName()
|
||||
{
|
||||
return m_pNickName ? m_pNickName : "unknown";
|
||||
}
|
||||
virtual void SaveState(CvFileStorage*){};
|
||||
virtual void LoadState(CvFileStorage*, CvFileNode*){};
|
||||
const char* GetParamName(int index);
|
||||
const char* GetParamComment(const char* name);
|
||||
double GetParam(const char* name);
|
||||
const char* GetParamStr(const char* name);
|
||||
void SetParam(const char* name, double val);
|
||||
void SetParamStr(const char* name, const char* str);
|
||||
void TransferParamsFromChild(CvVSModule* pM, const char* prefix = NULL);
|
||||
void TransferParamsToChild(CvVSModule* pM, char* prefix = NULL);
|
||||
virtual void ParamUpdate();
|
||||
const char* GetTypeName();
|
||||
int IsModuleTypeName(const char* name);
|
||||
char* GetModuleName();
|
||||
int IsModuleName(const char* name);
|
||||
void SetNickName(const char* pStr);
|
||||
const char* GetNickName();
|
||||
virtual void SaveState(CvFileStorage*);
|
||||
virtual void LoadState(CvFileStorage*, CvFileNode*);
|
||||
|
||||
virtual void Release() = 0;
|
||||
};/* CvVMModule */
|
||||
void inline cvWriteStruct(CvFileStorage* fs, const char* name, void* addr, const char* desc, int num=1)
|
||||
{
|
||||
cvStartWriteStruct(fs,name,CV_NODE_SEQ|CV_NODE_FLOW);
|
||||
cvWriteRawData(fs,addr,num,desc);
|
||||
cvEndWriteStruct(fs);
|
||||
}
|
||||
void inline cvReadStructByName(CvFileStorage* fs, CvFileNode* node, const char* name, void* addr, const char* desc)
|
||||
{
|
||||
CvFileNode* pSeqNode = cvGetFileNodeByName(fs, node, name);
|
||||
if(pSeqNode==NULL)
|
||||
{
|
||||
printf("WARNING!!! Can't read structure %s\n",name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(CV_NODE_IS_SEQ(pSeqNode->tag))
|
||||
{
|
||||
cvReadRawData( fs, pSeqNode, addr, desc );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("WARNING!!! Structure %s is not sequence and can not be read\n",name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CV_EXPORTS void cvWriteStruct(CvFileStorage* fs, const char* name, void* addr, const char* desc, int num=1);
|
||||
CV_EXPORTS void cvReadStructByName(CvFileStorage* fs, CvFileNode* node, const char* name, void* addr, const char* desc);
|
||||
|
||||
/* FOREGROUND DETECTOR INTERFACE */
|
||||
class CV_EXPORTS CvFGDetector: public CvVSModule
|
||||
class CV_EXPORTS CvFGDetector : public CvVSModule
|
||||
{
|
||||
public:
|
||||
CvFGDetector(){SetTypeName("FGDetector");};
|
||||
CvFGDetector();
|
||||
virtual IplImage* GetMask() = 0;
|
||||
/* Process current image: */
|
||||
virtual void Process(IplImage* pImg) = 0;
|
||||
/* Release foreground detector: */
|
||||
virtual void Release() = 0;
|
||||
};
|
||||
inline void cvReleaseFGDetector(CvFGDetector** ppT )
|
||||
{
|
||||
ppT[0]->Release();
|
||||
ppT[0] = 0;
|
||||
}
|
||||
/* FOREGROUND DETECTOR INTERFACE */
|
||||
|
||||
CV_EXPORTS void cvReleaseFGDetector(CvFGDetector** ppT );
|
||||
CV_EXPORTS CvFGDetector* cvCreateFGDetectorBase(int type, void *param);
|
||||
|
||||
|
||||
@ -552,71 +273,15 @@ struct CvBlobTrack
|
||||
class CV_EXPORTS CvBlobTrackSeq
|
||||
{
|
||||
public:
|
||||
CvBlobTrackSeq(int TrackSize = sizeof(CvBlobTrack))
|
||||
{
|
||||
m_pMem = cvCreateMemStorage();
|
||||
m_pSeq = cvCreateSeq(0,sizeof(CvSeq),TrackSize,m_pMem);
|
||||
}
|
||||
virtual ~CvBlobTrackSeq()
|
||||
{
|
||||
Clear();
|
||||
cvReleaseMemStorage(&m_pMem);
|
||||
};
|
||||
virtual CvBlobTrack* GetBlobTrack(int TrackIndex)
|
||||
{
|
||||
return (CvBlobTrack*)cvGetSeqElem(m_pSeq,TrackIndex);
|
||||
};
|
||||
virtual CvBlobTrack* GetBlobTrackByID(int TrackID)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<m_pSeq->total; ++i)
|
||||
{
|
||||
CvBlobTrack* pP = GetBlobTrack(i);
|
||||
if(pP && pP->TrackID == TrackID)
|
||||
return pP;
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
virtual void DelBlobTrack(int TrackIndex)
|
||||
{
|
||||
CvBlobTrack* pP = GetBlobTrack(TrackIndex);
|
||||
if(pP && pP->pBlobSeq) delete pP->pBlobSeq;
|
||||
cvSeqRemove(m_pSeq,TrackIndex);
|
||||
};
|
||||
virtual void DelBlobTrackByID(int TrackID)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<m_pSeq->total; ++i)
|
||||
{
|
||||
CvBlobTrack* pP = GetBlobTrack(i);
|
||||
if(TrackID == pP->TrackID)
|
||||
{
|
||||
DelBlobTrack(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
virtual void Clear()
|
||||
{
|
||||
int i;
|
||||
for(i=GetBlobTrackNum();i>0;i--)
|
||||
{
|
||||
DelBlobTrack(i-1);
|
||||
}
|
||||
cvClearSeq(m_pSeq);
|
||||
};
|
||||
virtual void AddBlobTrack(int TrackID, int StartFrame = 0)
|
||||
{
|
||||
CvBlobTrack N;
|
||||
N.TrackID = TrackID;
|
||||
N.StartFrame = StartFrame;
|
||||
N.pBlobSeq = new CvBlobSeq;
|
||||
cvSeqPush(m_pSeq,&N);
|
||||
};
|
||||
virtual int GetBlobTrackNum()
|
||||
{
|
||||
return m_pSeq->total;
|
||||
};
|
||||
CvBlobTrackSeq(int TrackSize = sizeof(CvBlobTrack));
|
||||
virtual ~CvBlobTrackSeq();
|
||||
virtual CvBlobTrack* GetBlobTrack(int TrackIndex);
|
||||
virtual CvBlobTrack* GetBlobTrackByID(int TrackID);
|
||||
virtual void DelBlobTrack(int TrackIndex);
|
||||
virtual void DelBlobTrackByID(int TrackID);
|
||||
virtual void Clear();
|
||||
virtual void AddBlobTrack(int TrackID, int StartFrame = 0);
|
||||
virtual int GetBlobTrackNum();
|
||||
protected:
|
||||
CvMemStorage* m_pMem;
|
||||
CvSeq* m_pSeq;
|
||||
@ -638,19 +303,14 @@ public:
|
||||
/* release blob detector */
|
||||
virtual void Release()=0;
|
||||
};
|
||||
|
||||
/* Release any blob detector: */
|
||||
inline void cvReleaseBlobDetector(CvBlobDetector** ppBD)
|
||||
{
|
||||
ppBD[0]->Release();
|
||||
ppBD[0] = NULL;
|
||||
}
|
||||
/* END BLOB DETECTOR INTERFACE */
|
||||
CV_EXPORTS void cvReleaseBlobDetector(CvBlobDetector** ppBD);
|
||||
|
||||
/* Declarations of constructors of implemented modules: */
|
||||
CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorSimple();
|
||||
CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorCC();
|
||||
|
||||
|
||||
struct CV_EXPORTS CvDetectedBlob : public CvBlob
|
||||
{
|
||||
float response;
|
||||
@ -667,28 +327,27 @@ CV_INLINE CvDetectedBlob cvDetectedBlob( float x, float y, float w, float h, int
|
||||
class CV_EXPORTS CvObjectDetector
|
||||
{
|
||||
public:
|
||||
CvObjectDetector( const char* /*detector_file_name*/ = 0 ) {};
|
||||
|
||||
~CvObjectDetector() {};
|
||||
CvObjectDetector( const char* /*detector_file_name*/ = 0 );
|
||||
~CvObjectDetector();
|
||||
|
||||
/*
|
||||
* Release the current detector and load new detector from file
|
||||
* (if detector_file_name is not 0)
|
||||
* Return true on success:
|
||||
*/
|
||||
bool Load( const char* /*detector_file_name*/ = 0 ) { return false; }
|
||||
bool Load( const char* /*detector_file_name*/ = 0 );
|
||||
|
||||
/* Return min detector window size: */
|
||||
CvSize GetMinWindowSize() const { return cvSize(0,0); }
|
||||
CvSize GetMinWindowSize() const;
|
||||
|
||||
/* Return max border: */
|
||||
int GetMaxBorderSize() const { return 0; }
|
||||
int GetMaxBorderSize() const;
|
||||
|
||||
/*
|
||||
* Detect the object on the image and push the detected
|
||||
* blobs into <detected_blob_seq> which must be the sequence of <CvDetectedBlob>s
|
||||
*/
|
||||
void Detect( const CvArr* /*img*/, /* out */ CvBlobSeq* /*detected_blob_seq*/ = 0 ) {};
|
||||
void Detect( const CvArr* /*img*/, /* out */ CvBlobSeq* /*detected_blob_seq*/ = 0 );
|
||||
|
||||
protected:
|
||||
class CvObjectDetectorImpl* impl;
|
||||
@ -774,7 +433,7 @@ CV_EXPORTS CvBlobTrackGen* cvCreateModuleBlobTrackGenYML();
|
||||
class CV_EXPORTS CvBlobTracker: public CvVSModule
|
||||
{
|
||||
public:
|
||||
CvBlobTracker(){SetTypeName("BlobTracker");};
|
||||
CvBlobTracker();
|
||||
|
||||
/* Add new blob to track it and assign to this blob personal ID */
|
||||
/* pBlob - pointer to structure with blob parameters (ID is ignored)*/
|
||||
@ -800,100 +459,52 @@ public:
|
||||
|
||||
|
||||
/* Process one blob (for multi hypothesis tracing): */
|
||||
virtual void ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL)
|
||||
{
|
||||
CvBlob* pB;
|
||||
int ID = 0;
|
||||
assert(pBlob);
|
||||
//pBlob->ID;
|
||||
pB = GetBlob(BlobIndex);
|
||||
if(pB)
|
||||
pBlob[0] = pB[0];
|
||||
pBlob->ID = ID;
|
||||
};
|
||||
virtual void ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL);
|
||||
|
||||
/* Get confidence/wieght/probability (0-1) for blob: */
|
||||
virtual double GetConfidence(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
virtual double GetConfidence(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL);
|
||||
|
||||
virtual double GetConfidenceList(CvBlobSeq* pBlobList, IplImage* pImg, IplImage* pImgFG = NULL)
|
||||
{
|
||||
int b,bN = pBlobList->GetBlobNum();
|
||||
double W = 1;
|
||||
for(b=0;b<bN;++b)
|
||||
{
|
||||
CvBlob* pB = pBlobList->GetBlob(b);
|
||||
int BI = GetBlobIndexByID(pB->ID);
|
||||
W *= GetConfidence(BI,pB,pImg,pImgFG);
|
||||
}
|
||||
return W;
|
||||
};
|
||||
virtual double GetConfidenceList(CvBlobSeq* pBlobList, IplImage* pImg, IplImage* pImgFG = NULL);
|
||||
|
||||
virtual void UpdateBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){};
|
||||
virtual void UpdateBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL);
|
||||
|
||||
/* Update all blob models: */
|
||||
virtual void Update(IplImage* pImg, IplImage* pImgFG = NULL)
|
||||
{
|
||||
int i;
|
||||
for(i=GetBlobNum();i>0;i--)
|
||||
{
|
||||
CvBlob* pB=GetBlob(i-1);
|
||||
UpdateBlob(i-1, pB, pImg, pImgFG);
|
||||
}
|
||||
|
||||
};
|
||||
virtual void Update(IplImage* pImg, IplImage* pImgFG = NULL);
|
||||
|
||||
/* Return pointer to blob by its unique ID: */
|
||||
virtual int GetBlobIndexByID(int BlobID)
|
||||
{
|
||||
int i;
|
||||
for(i=GetBlobNum();i>0;i--)
|
||||
{
|
||||
CvBlob* pB=GetBlob(i-1);
|
||||
if(CV_BLOB_ID(pB) == BlobID) return i-1;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
virtual int GetBlobIndexByID(int BlobID);
|
||||
|
||||
/* Return pointer to blob by its unique ID: */
|
||||
virtual CvBlob* GetBlobByID(int BlobID){return GetBlob(GetBlobIndexByID(BlobID));};
|
||||
virtual CvBlob* GetBlobByID(int BlobID);
|
||||
|
||||
/* Delete blob by its ID: */
|
||||
virtual void DelBlobByID(int BlobID){DelBlob(GetBlobIndexByID(BlobID));};
|
||||
virtual void DelBlobByID(int BlobID);
|
||||
|
||||
/* Set new parameters for specified (by index) blob: */
|
||||
virtual void SetBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/){};
|
||||
virtual void SetBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/);
|
||||
|
||||
/* Set new parameters for specified (by ID) blob: */
|
||||
virtual void SetBlobByID(int BlobID, CvBlob* pBlob)
|
||||
{
|
||||
SetBlob(GetBlobIndexByID(BlobID),pBlob);
|
||||
};
|
||||
virtual void SetBlobByID(int BlobID, CvBlob* pBlob);
|
||||
|
||||
/* =============== MULTI HYPOTHESIS INTERFACE ================== */
|
||||
|
||||
/* Return number of position hyposetis of currently tracked blob: */
|
||||
virtual int GetBlobHypNum(int /*BlobIdx*/){return 1;};
|
||||
virtual int GetBlobHypNum(int /*BlobIdx*/);
|
||||
|
||||
/* Return pointer to specified blob hypothesis by index blob: */
|
||||
virtual CvBlob* GetBlobHyp(int BlobIndex, int /*hypothesis*/){return GetBlob(BlobIndex);};
|
||||
virtual CvBlob* GetBlobHyp(int BlobIndex, int /*hypothesis*/);
|
||||
|
||||
/* Set new parameters for specified (by index) blob hyp
|
||||
* (can be called several times for each hyp ):
|
||||
*/
|
||||
virtual void SetBlobHyp(int /*BlobIndex*/, CvBlob* /*pBlob*/){};
|
||||
virtual void SetBlobHyp(int /*BlobIndex*/, CvBlob* /*pBlob*/);
|
||||
};
|
||||
inline void cvReleaseBlobTracker(CvBlobTracker**ppT )
|
||||
{
|
||||
ppT[0]->Release();
|
||||
ppT[0] = 0;
|
||||
}
|
||||
|
||||
CV_EXPORTS void cvReleaseBlobTracker(CvBlobTracker**ppT );
|
||||
/* BLOB TRACKER INTERFACE */
|
||||
|
||||
/*BLOB TRACKER ONE INTERFACE */
|
||||
class CV_EXPORTS CvBlobTrackerOne:public CvVSModule
|
||||
class CV_EXPORTS CvBlobTrackerOne : public CvVSModule
|
||||
{
|
||||
public:
|
||||
virtual void Init(CvBlob* pBlobInit, IplImage* pImg, IplImage* pImgFG = NULL) = 0;
|
@ -47,8 +47,8 @@
|
||||
including cv.h.
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_IMGPROC_COMPAT_C_H__
|
||||
#define __OPENCV_IMGPROC_COMPAT_C_H__
|
||||
#ifndef __OPENCV_COMPAT_HPP__
|
||||
#define __OPENCV_COMPAT_HPP__
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
@ -57,51 +57,47 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define CV_UNREFERENCED(arg)
|
||||
#else
|
||||
#define CV_UNREFERENCED(arg) arg
|
||||
#endif
|
||||
|
||||
#if !defined __cplusplus && defined _MSC_VER && _MSC_VER >= 1400
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4100)
|
||||
#endif
|
||||
|
||||
typedef int CvMatType;
|
||||
typedef int CvDisMaskType;
|
||||
typedef CvMat CvMatArray;
|
||||
|
||||
#define CvThreshType int
|
||||
#define CvAdaptiveThreshMethod int
|
||||
#define CvCompareMethod int
|
||||
#define CvFontFace int
|
||||
#define CvPolyApproxMethod int
|
||||
#define CvContoursMatchMethod int
|
||||
#define CvContourTreesMatchMethod int
|
||||
#define CvCoeffType int
|
||||
#define CvRodriguesType int
|
||||
#define CvElementShape int
|
||||
#define CvMorphOp int
|
||||
#define CvTemplMatchMethod int
|
||||
typedef int CvThreshType;
|
||||
typedef int CvAdaptiveThreshMethod;
|
||||
typedef int CvCompareMethod;
|
||||
typedef int CvFontFace;
|
||||
typedef int CvPolyApproxMethod;
|
||||
typedef int CvContoursMatchMethod;
|
||||
typedef int CvContourTreesMatchMethod;
|
||||
typedef int CvCoeffType;
|
||||
typedef int CvRodriguesType;
|
||||
typedef int CvElementShape;
|
||||
typedef int CvMorphOp;
|
||||
typedef int CvTemplMatchMethod;
|
||||
|
||||
#define CvPoint2D64d CvPoint2D64f
|
||||
#define CvPoint3D64d CvPoint3D64f
|
||||
typedef CvPoint2D64f CvPoint2D64d;
|
||||
typedef CvPoint3D64f CvPoint3D64d;
|
||||
|
||||
#define CV_MAT32F CV_32FC1
|
||||
#define CV_MAT3x1_32F CV_32FC1
|
||||
#define CV_MAT4x1_32F CV_32FC1
|
||||
#define CV_MAT3x3_32F CV_32FC1
|
||||
#define CV_MAT4x4_32F CV_32FC1
|
||||
enum
|
||||
{
|
||||
CV_MAT32F = CV_32FC1,
|
||||
CV_MAT3x1_32F = CV_32FC1,
|
||||
CV_MAT4x1_32F = CV_32FC1,
|
||||
CV_MAT3x3_32F = CV_32FC1,
|
||||
CV_MAT4x4_32F = CV_32FC1,
|
||||
|
||||
#define CV_MAT64D CV_64FC1
|
||||
#define CV_MAT3x1_64D CV_64FC1
|
||||
#define CV_MAT4x1_64D CV_64FC1
|
||||
#define CV_MAT3x3_64D CV_64FC1
|
||||
#define CV_MAT4x4_64D CV_64FC1
|
||||
CV_MAT64D = CV_64FC1,
|
||||
CV_MAT3x1_64D = CV_64FC1,
|
||||
CV_MAT4x1_64D = CV_64FC1,
|
||||
CV_MAT3x3_64D = CV_64FC1,
|
||||
CV_MAT4x4_64D = CV_64FC1
|
||||
};
|
||||
|
||||
#define IPL_GAUSSIAN_5x5 7
|
||||
#define CvBox2D32f CvBox2D
|
||||
enum
|
||||
{
|
||||
IPL_GAUSSIAN_5x5 = 7
|
||||
};
|
||||
|
||||
typedef CvBox2D CvBox2D32f;
|
||||
|
||||
/* allocation/deallocation macros */
|
||||
#define cvCreateImageData cvCreateData
|
||||
@ -117,11 +113,8 @@ typedef CvMat CvMatArray;
|
||||
#define cvIntegralImage cvIntegral
|
||||
#define cvMatchContours cvMatchShapes
|
||||
|
||||
CV_INLINE CvMat cvMatArray( int rows, int cols, int type,
|
||||
int count, void* data CV_DEFAULT(0))
|
||||
{
|
||||
return cvMat( rows*count, cols, type, data );
|
||||
}
|
||||
CV_EXPORTS CvMat cvMatArray( int rows, int cols, int type,
|
||||
int count, void* data CV_DEFAULT(0));
|
||||
|
||||
#define cvUpdateMHIByTime cvUpdateMotionHistory
|
||||
|
||||
@ -133,49 +126,13 @@ CV_INLINE CvMat cvMatArray( int rows, int cols, int type,
|
||||
#define cvSetHistThresh cvSetHistBinRanges
|
||||
#define cvCalcHistMask(img, mask, hist, doNotClear) cvCalcHist(img, hist, doNotClear, mask)
|
||||
|
||||
CV_INLINE double cvMean( const CvArr* image, const CvArr* mask CV_DEFAULT(0))
|
||||
{
|
||||
CvScalar mean = cvAvg( image, mask );
|
||||
return mean.val[0];
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE double cvSumPixels( const CvArr* image )
|
||||
{
|
||||
CvScalar scalar = cvSum( image );
|
||||
return scalar.val[0];
|
||||
}
|
||||
|
||||
CV_INLINE void cvMean_StdDev( const CvArr* image, double* mean, double* sdv,
|
||||
const CvArr* mask CV_DEFAULT(0))
|
||||
{
|
||||
CvScalar _mean, _sdv;
|
||||
cvAvgSdv( image, &_mean, &_sdv, mask );
|
||||
|
||||
if( mean )
|
||||
*mean = _mean.val[0];
|
||||
|
||||
if( sdv )
|
||||
*sdv = _sdv.val[0];
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvmPerspectiveProject( const CvMat* mat, const CvArr* src, CvArr* dst )
|
||||
{
|
||||
CvMat tsrc, tdst;
|
||||
|
||||
cvReshape( src, &tsrc, 3, 0 );
|
||||
cvReshape( dst, &tdst, 3, 0 );
|
||||
|
||||
cvPerspectiveTransform( &tsrc, &tdst, mat );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvFillImage( CvArr* mat, double color )
|
||||
{
|
||||
cvSet( mat, cvColorToScalar(color, cvGetElemType(mat)), 0 );
|
||||
}
|
||||
CV_EXPORTS double cvMean( const CvArr* image, const CvArr* mask CV_DEFAULT(0));
|
||||
CV_EXPORTS double cvSumPixels( const CvArr* image );
|
||||
CV_EXPORTS void cvMean_StdDev( const CvArr* image, double* mean, double* sdv,
|
||||
const CvArr* mask CV_DEFAULT(0));
|
||||
|
||||
CV_EXPORTS void cvmPerspectiveProject( const CvMat* mat, const CvArr* src, CvArr* dst );
|
||||
CV_EXPORTS void cvFillImage( CvArr* mat, double color );
|
||||
|
||||
#define cvCvtPixToPlane cvSplit
|
||||
#define cvCvtPlaneToPix cvMerge
|
||||
@ -185,174 +142,38 @@ typedef struct CvRandState
|
||||
CvRNG state; /* RNG state (the current seed and carry)*/
|
||||
int disttype; /* distribution type */
|
||||
CvScalar param[2]; /* parameters of RNG */
|
||||
}
|
||||
CvRandState;
|
||||
|
||||
} CvRandState;
|
||||
|
||||
/* Changes RNG range while preserving RNG state */
|
||||
CV_INLINE void cvRandSetRange( CvRandState* state, double param1,
|
||||
double param2, int index CV_DEFAULT(-1))
|
||||
{
|
||||
if( !state )
|
||||
{
|
||||
cvError( CV_StsNullPtr, "cvRandSetRange", "Null pointer to RNG state", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
CV_EXPORTS void cvRandSetRange( CvRandState* state, double param1,
|
||||
double param2, int index CV_DEFAULT(-1));
|
||||
|
||||
if( (unsigned)(index + 1) > 4 )
|
||||
{
|
||||
cvError( CV_StsOutOfRange, "cvRandSetRange", "index is not in -1..3", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
if( index < 0 )
|
||||
{
|
||||
state->param[0].val[0] = state->param[0].val[1] =
|
||||
state->param[0].val[2] = state->param[0].val[3] = param1;
|
||||
state->param[1].val[0] = state->param[1].val[1] =
|
||||
state->param[1].val[2] = state->param[1].val[3] = param2;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->param[0].val[index] = param1;
|
||||
state->param[1].val[index] = param2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvRandInit( CvRandState* state, double param1,
|
||||
CV_EXPORTS void cvRandInit( CvRandState* state, double param1,
|
||||
double param2, int seed,
|
||||
int disttype CV_DEFAULT(CV_RAND_UNI))
|
||||
{
|
||||
if( !state )
|
||||
{
|
||||
cvError( CV_StsNullPtr, "cvRandInit", "Null pointer to RNG state", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
if( disttype != CV_RAND_UNI && disttype != CV_RAND_NORMAL )
|
||||
{
|
||||
cvError( CV_StsBadFlag, "cvRandInit", "Unknown distribution type", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
state->state = (uint64)(seed ? seed : -1);
|
||||
state->disttype = disttype;
|
||||
cvRandSetRange( state, param1, param2, -1 );
|
||||
}
|
||||
|
||||
int disttype CV_DEFAULT(CV_RAND_UNI));
|
||||
|
||||
/* Fills array with random numbers */
|
||||
CV_INLINE void cvRand( CvRandState* state, CvArr* arr )
|
||||
{
|
||||
if( !state )
|
||||
{
|
||||
cvError( CV_StsNullPtr, "cvRand", "Null pointer to RNG state", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
cvRandArr( &state->state, arr, state->disttype, state->param[0], state->param[1] );
|
||||
}
|
||||
CV_EXPORTS void cvRand( CvRandState* state, CvArr* arr );
|
||||
|
||||
#define cvRandNext( _state ) cvRandInt( &(_state)->state )
|
||||
|
||||
CV_INLINE void cvbRand( CvRandState* state, float* dst, int len )
|
||||
{
|
||||
CvMat mat = cvMat( 1, len, CV_32F, (void*)dst );
|
||||
cvRand( state, &mat );
|
||||
}
|
||||
CV_EXPORTS void cvbRand( CvRandState* state, float* dst, int len );
|
||||
|
||||
CV_EXPORTS void cvbCartToPolar( const float* y, const float* x,
|
||||
float* magnitude, float* angle, int len );
|
||||
CV_EXPORTS void cvbFastArctan( const float* y, const float* x, float* angle, int len );
|
||||
CV_EXPORTS void cvbSqrt( const float* x, float* y, int len );
|
||||
CV_EXPORTS void cvbInvSqrt( const float* x, float* y, int len );
|
||||
CV_EXPORTS void cvbReciprocal( const float* x, float* y, int len );
|
||||
CV_EXPORTS void cvbFastExp( const float* x, double* y, int len );
|
||||
CV_EXPORTS void cvbFastLog( const double* x, float* y, int len );
|
||||
|
||||
CV_INLINE void cvbCartToPolar( const float* y, const float* x,
|
||||
float* magnitude, float* angle, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
CvMat mm = mx;
|
||||
CvMat ma = mx;
|
||||
|
||||
my.data.fl = (float*)y;
|
||||
mm.data.fl = (float*)magnitude;
|
||||
ma.data.fl = (float*)angle;
|
||||
|
||||
cvCartToPolar( &mx, &my, &mm, angle ? &ma : NULL, 1 );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvbFastArctan( const float* y, const float* x,
|
||||
float* angle, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
CvMat ma = mx;
|
||||
|
||||
my.data.fl = (float*)y;
|
||||
ma.data.fl = (float*)angle;
|
||||
|
||||
cvCartToPolar( &mx, &my, NULL, &ma, 1 );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvbSqrt( const float* x, float* y, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
my.data.fl = (float*)y;
|
||||
|
||||
cvPow( &mx, &my, 0.5 );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvbInvSqrt( const float* x, float* y, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
my.data.fl = (float*)y;
|
||||
|
||||
cvPow( &mx, &my, -0.5 );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvbReciprocal( const float* x, float* y, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
my.data.fl = (float*)y;
|
||||
|
||||
cvPow( &mx, &my, -1 );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvbFastExp( const float* x, double* y, int len )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < len; i++ )
|
||||
y[i] = exp((double)x[i]);
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvbFastLog( const double* x, float* y, int len )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < len; i++ )
|
||||
y[i] = (float)log(x[i]);
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE CvRect cvContourBoundingRect( void* point_set, int update CV_DEFAULT(0))
|
||||
{
|
||||
return cvBoundingRect( point_set, update );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE double cvPseudoInverse( const CvArr* src, CvArr* dst )
|
||||
{
|
||||
return cvInvert( src, dst, CV_SVD );
|
||||
}
|
||||
CV_EXPORTS CvRect cvContourBoundingRect( void* point_set, int update CV_DEFAULT(0));
|
||||
|
||||
CV_EXPORTS double cvPseudoInverse( const CvArr* src, CvArr* dst );
|
||||
#define cvPseudoInv cvPseudoInverse
|
||||
|
||||
#define cvContourMoments( contour, moments ) \
|
||||
cvMoments( contour, moments, 0 )
|
||||
#define cvContourMoments( contour, moments ) cvMoments( contour, moments, 0 )
|
||||
|
||||
#define cvGetPtrAt cvPtr2D
|
||||
#define cvGetAt cvGet2D
|
||||
@ -389,98 +210,37 @@ CV_INLINE double cvPseudoInverse( const CvArr* src, CvArr* dst )
|
||||
#define cvReleaseMatHeader cvReleaseMat
|
||||
|
||||
/* Calculates exact convex hull of 2d point set */
|
||||
CV_INLINE void cvConvexHull( CvPoint* points, int num_points,
|
||||
CvRect* CV_UNREFERENCED(bound_rect),
|
||||
int orientation, int* hull, int* hullsize )
|
||||
{
|
||||
CvMat points1 = cvMat( 1, num_points, CV_32SC2, points );
|
||||
CvMat hull1 = cvMat( 1, num_points, CV_32SC1, hull );
|
||||
|
||||
cvConvexHull2( &points1, &hull1, orientation, 0 );
|
||||
*hullsize = hull1.cols;
|
||||
}
|
||||
|
||||
/* Calculates exact convex hull of 2d point set stored in a sequence */
|
||||
#define cvContourConvexHull( contour, orientation, storage ) \
|
||||
cvConvexHull2( contour, storage, orientation )
|
||||
|
||||
/* Calculates approximate convex hull of 2d point set */
|
||||
#define cvConvexHullApprox( points, num_points, bound_rect, bandwidth, \
|
||||
orientation, hull, hullsize ) \
|
||||
cvConvexHull( points, num_points, bound_rect, orientation, hull, hullsize )
|
||||
|
||||
/* Calculates approximate convex hull of 2d point set stored in a sequence */
|
||||
#define cvContourConvexHullApprox( contour, bandwidth, orientation, storage ) \
|
||||
cvConvexHull2( contour, storage, orientation )
|
||||
CV_EXPORTS void cvConvexHull( CvPoint* points, int num_points,
|
||||
CvRect* bound_rect,
|
||||
int orientation, int* hull, int* hullsize );
|
||||
|
||||
|
||||
CV_INLINE void cvMinAreaRect( CvPoint* points, int n,
|
||||
int CV_UNREFERENCED(left), int CV_UNREFERENCED(bottom),
|
||||
int CV_UNREFERENCED(right), int CV_UNREFERENCED(top),
|
||||
CV_EXPORTS void cvMinAreaRect( CvPoint* points, int n,
|
||||
int left, int bottom,
|
||||
int right, int top,
|
||||
CvPoint2D32f* anchor,
|
||||
CvPoint2D32f* vect1,
|
||||
CvPoint2D32f* vect2 )
|
||||
{
|
||||
CvMat mat = cvMat( 1, n, CV_32SC2, points );
|
||||
CvBox2D box = cvMinAreaRect2( &mat, 0 );
|
||||
CvPoint2D32f pt[4];
|
||||
|
||||
cvBoxPoints( box, pt );
|
||||
*anchor = pt[0];
|
||||
vect1->x = pt[1].x - pt[0].x;
|
||||
vect1->y = pt[1].y - pt[0].y;
|
||||
vect2->x = pt[3].x - pt[0].x;
|
||||
vect2->y = pt[3].y - pt[0].y;
|
||||
}
|
||||
CvPoint2D32f* vect2 );
|
||||
|
||||
typedef int CvDisType;
|
||||
typedef int CvChainApproxMethod;
|
||||
typedef int CvContourRetrievalMode;
|
||||
|
||||
CV_INLINE void cvFitLine3D( CvPoint3D32f* points, int count, int dist,
|
||||
void *param, float reps, float aeps, float* line )
|
||||
{
|
||||
CvMat mat = cvMat( 1, count, CV_32FC3, points );
|
||||
float _param = param != NULL ? *(float*)param : 0.f;
|
||||
assert( dist != CV_DIST_USER );
|
||||
cvFitLine( &mat, dist, _param, reps, aeps, line );
|
||||
}
|
||||
CV_EXPORTS void cvFitLine3D( CvPoint3D32f* points, int count, int dist,
|
||||
void *param, float reps, float aeps, float* line );
|
||||
|
||||
/* Fits a line into set of 2d points in a robust way (M-estimator technique) */
|
||||
CV_INLINE void cvFitLine2D( CvPoint2D32f* points, int count, int dist,
|
||||
void *param, float reps, float aeps, float* line )
|
||||
{
|
||||
CvMat mat = cvMat( 1, count, CV_32FC2, points );
|
||||
float _param = param != NULL ? *(float*)param : 0.f;
|
||||
assert( dist != CV_DIST_USER );
|
||||
cvFitLine( &mat, dist, _param, reps, aeps, line );
|
||||
}
|
||||
CV_EXPORTS void cvFitLine2D( CvPoint2D32f* points, int count, int dist,
|
||||
void *param, float reps, float aeps, float* line );
|
||||
|
||||
|
||||
CV_INLINE void cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box )
|
||||
{
|
||||
CvMat mat = cvMat( 1, count, CV_32FC2, (void*)points );
|
||||
*box = cvFitEllipse2( &mat );
|
||||
}
|
||||
CV_EXPORTS void cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box );
|
||||
|
||||
/* Projects 2d points to one of standard coordinate planes
|
||||
(i.e. removes one of coordinates) */
|
||||
CV_INLINE void cvProject3D( CvPoint3D32f* points3D, int count,
|
||||
CV_EXPORTS void cvProject3D( CvPoint3D32f* points3D, int count,
|
||||
CvPoint2D32f* points2D,
|
||||
int xIndx CV_DEFAULT(0),
|
||||
int yIndx CV_DEFAULT(1))
|
||||
{
|
||||
CvMat src = cvMat( 1, count, CV_32FC3, points3D );
|
||||
CvMat dst = cvMat( 1, count, CV_32FC2, points2D );
|
||||
float m[6] = {0,0,0,0,0,0};
|
||||
CvMat M = cvMat( 2, 3, CV_32F, m );
|
||||
|
||||
assert( (unsigned)xIndx < 3 && (unsigned)yIndx < 3 );
|
||||
m[xIndx] = m[yIndx+3] = 1.f;
|
||||
|
||||
cvTransform( &src, &dst, &M, NULL );
|
||||
}
|
||||
|
||||
int yIndx CV_DEFAULT(1));
|
||||
|
||||
/* Retrieves value of the particular bin
|
||||
of x-dimensional (x=1,2,3,...) histogram */
|
||||
@ -508,134 +268,52 @@ CV_INLINE void cvProject3D( CvPoint3D32f* points3D, int count,
|
||||
#define CV_IS_SET_ELEM_EXISTS CV_IS_SET_ELEM
|
||||
|
||||
|
||||
CV_INLINE int cvHoughLines( CvArr* image, double rho,
|
||||
CV_EXPORTS int cvHoughLines( CvArr* image, double rho,
|
||||
double theta, int threshold,
|
||||
float* lines, int linesNumber )
|
||||
{
|
||||
CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines );
|
||||
cvHoughLines2( image, &linesMat, CV_HOUGH_STANDARD,
|
||||
rho, theta, threshold, 0, 0 );
|
||||
float* lines, int linesNumber );
|
||||
|
||||
return linesMat.cols;
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE int cvHoughLinesP( CvArr* image, double rho,
|
||||
CV_EXPORTS int cvHoughLinesP( CvArr* image, double rho,
|
||||
double theta, int threshold,
|
||||
int lineLength, int lineGap,
|
||||
int* lines, int linesNumber )
|
||||
{
|
||||
CvMat linesMat = cvMat( 1, linesNumber, CV_32SC4, lines );
|
||||
cvHoughLines2( image, &linesMat, CV_HOUGH_PROBABILISTIC,
|
||||
rho, theta, threshold, lineLength, lineGap );
|
||||
|
||||
return linesMat.cols;
|
||||
}
|
||||
int* lines, int linesNumber );
|
||||
|
||||
|
||||
CV_INLINE int cvHoughLinesSDiv( CvArr* image, double rho, int srn,
|
||||
CV_EXPORTS int cvHoughLinesSDiv( CvArr* image, double rho, int srn,
|
||||
double theta, int stn, int threshold,
|
||||
float* lines, int linesNumber )
|
||||
{
|
||||
CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines );
|
||||
cvHoughLines2( image, &linesMat, CV_HOUGH_MULTI_SCALE,
|
||||
rho, theta, threshold, srn, stn );
|
||||
float* lines, int linesNumber );
|
||||
|
||||
return linesMat.cols;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CV_INLINE float cvCalcEMD( const float* signature1, int size1,
|
||||
CV_EXPORTS float cvCalcEMD( const float* signature1, int size1,
|
||||
const float* signature2, int size2,
|
||||
int dims, int dist_type CV_DEFAULT(CV_DIST_L2),
|
||||
CvDistanceFunction dist_func CV_DEFAULT(0),
|
||||
float* lower_bound CV_DEFAULT(0),
|
||||
void* user_param CV_DEFAULT(0))
|
||||
{
|
||||
CvMat sign1 = cvMat( size1, dims + 1, CV_32FC1, (void*)signature1 );
|
||||
CvMat sign2 = cvMat( size2, dims + 1, CV_32FC1, (void*)signature2 );
|
||||
void* user_param CV_DEFAULT(0));
|
||||
|
||||
return cvCalcEMD2( &sign1, &sign2, dist_type, dist_func, 0, 0, lower_bound, user_param );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvKMeans( int num_clusters, float** samples,
|
||||
CV_EXPORTS void cvKMeans( int num_clusters, float** samples,
|
||||
int num_samples, int vec_size,
|
||||
CvTermCriteria termcrit, int* cluster_idx )
|
||||
{
|
||||
CvMat* samples_mat = cvCreateMat( num_samples, vec_size, CV_32FC1 );
|
||||
CvMat cluster_idx_mat = cvMat( num_samples, 1, CV_32SC1, cluster_idx );
|
||||
int i;
|
||||
for( i = 0; i < num_samples; i++ )
|
||||
memcpy( samples_mat->data.fl + i*vec_size, samples[i], vec_size*sizeof(float));
|
||||
cvKMeans2( samples_mat, num_clusters, &cluster_idx_mat, termcrit, 1, 0, 0, 0, 0 );
|
||||
cvReleaseMat( &samples_mat );
|
||||
}
|
||||
CvTermCriteria termcrit, int* cluster_idx );
|
||||
|
||||
|
||||
CV_INLINE void cvStartScanGraph( CvGraph* graph, CvGraphScanner* scanner,
|
||||
CV_EXPORTS void cvStartScanGraph( CvGraph* graph, CvGraphScanner* scanner,
|
||||
CvGraphVtx* vtx CV_DEFAULT(NULL),
|
||||
int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS))
|
||||
{
|
||||
CvGraphScanner* temp_scanner;
|
||||
int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS));
|
||||
|
||||
if( !scanner )
|
||||
cvError( CV_StsNullPtr, "cvStartScanGraph", "Null scanner pointer", "cvcompat.h", 0 );
|
||||
|
||||
temp_scanner = cvCreateGraphScanner( graph, vtx, mask );
|
||||
*scanner = *temp_scanner;
|
||||
cvFree( &temp_scanner );
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE void cvEndScanGraph( CvGraphScanner* scanner )
|
||||
{
|
||||
if( !scanner )
|
||||
cvError( CV_StsNullPtr, "cvEndScanGraph", "Null scanner pointer", "cvcompat.h", 0 );
|
||||
|
||||
if( scanner->stack )
|
||||
{
|
||||
CvGraphScanner* temp_scanner = (CvGraphScanner*)cvAlloc( sizeof(*temp_scanner) );
|
||||
*temp_scanner = *scanner;
|
||||
cvReleaseGraphScanner( &temp_scanner );
|
||||
memset( scanner, 0, sizeof(*scanner) );
|
||||
}
|
||||
}
|
||||
CV_EXPORTS void cvEndScanGraph( CvGraphScanner* scanner );
|
||||
|
||||
|
||||
/* old drawing functions */
|
||||
CV_INLINE void cvLineAA( CvArr* img, CvPoint pt1, CvPoint pt2,
|
||||
double color, int scale CV_DEFAULT(0))
|
||||
{
|
||||
cvLine( img, pt1, pt2, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale );
|
||||
}
|
||||
CV_EXPORTS void cvLineAA( CvArr* img, CvPoint pt1, CvPoint pt2,
|
||||
double color, int scale CV_DEFAULT(0));
|
||||
|
||||
CV_INLINE void cvCircleAA( CvArr* img, CvPoint center, int radius,
|
||||
double color, int scale CV_DEFAULT(0) )
|
||||
{
|
||||
cvCircle( img, center, radius, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale );
|
||||
}
|
||||
CV_EXPORTS void cvCircleAA( CvArr* img, CvPoint center, int radius,
|
||||
double color, int scale CV_DEFAULT(0) );
|
||||
|
||||
CV_INLINE void cvEllipseAA( CvArr* img, CvPoint center, CvSize axes,
|
||||
CV_EXPORTS void cvEllipseAA( CvArr* img, CvPoint center, CvSize axes,
|
||||
double angle, double start_angle,
|
||||
double end_angle, double color,
|
||||
int scale CV_DEFAULT(0) )
|
||||
{
|
||||
cvEllipse( img, center, axes, angle, start_angle, end_angle,
|
||||
cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale );
|
||||
}
|
||||
|
||||
CV_INLINE void cvPolyLineAA( CvArr* img, CvPoint** pts, int* npts, int contours,
|
||||
int is_closed, double color, int scale CV_DEFAULT(0) )
|
||||
{
|
||||
cvPolyLine( img, pts, npts, contours, is_closed,
|
||||
cvColorToScalar(color, cvGetElemType(img)),
|
||||
1, CV_AA, scale );
|
||||
}
|
||||
|
||||
int scale CV_DEFAULT(0) );
|
||||
|
||||
CV_EXPORTS void cvPolyLineAA( CvArr* img, CvPoint** pts, int* npts, int contours,
|
||||
int is_closed, double color, int scale CV_DEFAULT(0) );
|
||||
|
||||
/****************************************************************************************\
|
||||
* Pixel Access Macros *
|
||||
@ -784,19 +462,22 @@ typedef struct _CvPixelPosition32f
|
||||
#define CV_MOVE_RD_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs))
|
||||
|
||||
/* Numeric constants which used for moving in arbitrary direction */
|
||||
#define CV_SHIFT_NONE 2
|
||||
#define CV_SHIFT_LEFT 1
|
||||
#define CV_SHIFT_RIGHT 3
|
||||
#define CV_SHIFT_UP 6
|
||||
#define CV_SHIFT_DOWN 10
|
||||
#define CV_SHIFT_LU 5
|
||||
#define CV_SHIFT_RU 7
|
||||
#define CV_SHIFT_LD 9
|
||||
#define CV_SHIFT_RD 11
|
||||
enum
|
||||
{
|
||||
CV_SHIFT_NONE = 2,
|
||||
CV_SHIFT_LEFT = 1,
|
||||
CV_SHIFT_RIGHT = 3,
|
||||
CV_SHIFT_UP = 6,
|
||||
CV_SHIFT_DOWN = 10,
|
||||
CV_SHIFT_LU = 5,
|
||||
CV_SHIFT_RU = 7,
|
||||
CV_SHIFT_LD = 9,
|
||||
CV_SHIFT_RD = 11
|
||||
};
|
||||
|
||||
/* Move by one pixel in specified direction */
|
||||
/* pos - position structure */
|
||||
/* shift - direction ( it's value must be one of the CV_SHIFT_… constants ) */
|
||||
/* shift - direction ( it's value must be one of the CV_SHIFT_Ö constants ) */
|
||||
/* cs - number of the image channels */
|
||||
#define CV_MOVE_PARAM( pos, shift, cs ) \
|
||||
( (pos).currline += (pos).step_arr[(shift)>>2], (pos).x += ((shift)&3)-2, \
|
||||
@ -806,7 +487,7 @@ typedef struct _CvPixelPosition32f
|
||||
/* Move by one pixel in specified direction with wrapping when the */
|
||||
/* position achieves image boundary */
|
||||
/* pos - position structure */
|
||||
/* shift - direction ( it's value must be one of the CV_SHIFT_… constants ) */
|
||||
/* shift - direction ( it's value must be one of the CV_SHIFT_Ö constants ) */
|
||||
/* cs - number of the image channels */
|
||||
#define CV_MOVE_PARAM_WRAP( pos, shift, cs ) \
|
||||
( (pos).currline += (pos).step_arr[(shift)>>2], \
|
||||
@ -826,59 +507,96 @@ typedef float* CvMatr32f;
|
||||
typedef double* CvVect64d;
|
||||
typedef double* CvMatr64d;
|
||||
|
||||
typedef struct CvMatrix3
|
||||
{
|
||||
float m[3][3];
|
||||
}
|
||||
CvMatrix3;
|
||||
|
||||
|
||||
CV_INLINE void cvUnDistortOnce( const CvArr* src, CvArr* dst,
|
||||
CV_EXPORTS void cvUnDistortOnce( const CvArr* src, CvArr* dst,
|
||||
const float* intrinsic_matrix,
|
||||
const float* distortion_coeffs,
|
||||
int CV_UNREFERENCED(interpolate) )
|
||||
{
|
||||
CvMat _a = cvMat( 3, 3, CV_32F, (void*)intrinsic_matrix );
|
||||
CvMat _k = cvMat( 4, 1, CV_32F, (void*)distortion_coeffs );
|
||||
cvUndistort2( src, dst, &_a, &_k, 0 );
|
||||
}
|
||||
|
||||
int interpolate );
|
||||
|
||||
/* the two functions below have quite hackerish implementations, use with care
|
||||
(or, which is better, switch to cvUndistortInitMap and cvRemap instead */
|
||||
CV_INLINE void cvUnDistortInit( const CvArr* CV_UNREFERENCED(src),
|
||||
CV_EXPORTS void cvUnDistortInit( const CvArr* src,
|
||||
CvArr* undistortion_map,
|
||||
const float* A, const float* k,
|
||||
int CV_UNREFERENCED(interpolate) )
|
||||
{
|
||||
union { uchar* ptr; float* fl; } data;
|
||||
CvSize sz;
|
||||
cvGetRawData( undistortion_map, &data.ptr, 0, &sz );
|
||||
assert( sz.width >= 8 );
|
||||
/* just save the intrinsic parameters to the map */
|
||||
data.fl[0] = A[0]; data.fl[1] = A[4];
|
||||
data.fl[2] = A[2]; data.fl[3] = A[5];
|
||||
data.fl[4] = k[0]; data.fl[5] = k[1];
|
||||
data.fl[6] = k[2]; data.fl[7] = k[3];
|
||||
}
|
||||
int interpolate );
|
||||
|
||||
CV_INLINE void cvUnDistort( const CvArr* src, CvArr* dst,
|
||||
CV_EXPORTS void cvUnDistort( const CvArr* src, CvArr* dst,
|
||||
const CvArr* undistortion_map,
|
||||
int CV_UNREFERENCED(interpolate) )
|
||||
{
|
||||
union { uchar* ptr; float* fl; } data;
|
||||
float a[] = {0,0,0,0,0,0,0,0,1};
|
||||
CvSize sz;
|
||||
cvGetRawData( undistortion_map, &data.ptr, 0, &sz );
|
||||
assert( sz.width >= 8 );
|
||||
a[0] = data.fl[0]; a[4] = data.fl[1];
|
||||
a[2] = data.fl[2]; a[5] = data.fl[3];
|
||||
cvUnDistortOnce( src, dst, a, data.fl + 4, 1 );
|
||||
}
|
||||
int interpolate );
|
||||
|
||||
/* Find fundamental matrix */
|
||||
CV_EXPORTS void cvFindFundamentalMatrix( int* points1, int* points2,
|
||||
int numpoints, int method, float* matrix );
|
||||
|
||||
|
||||
CV_EXPORTS int cvFindChessBoardCornerGuesses( const void* arr, void* thresharr,
|
||||
CvMemStorage* storage,
|
||||
CvSize pattern_size, CvPoint2D32f * corners,
|
||||
int *corner_count );
|
||||
|
||||
/* Calibrates camera using multiple views of calibration pattern */
|
||||
CV_EXPORTS void cvCalibrateCamera( int image_count, int* _point_counts,
|
||||
CvSize image_size, CvPoint2D32f* _image_points, CvPoint3D32f* _object_points,
|
||||
float* _distortion_coeffs, float* _camera_matrix, float* _translation_vectors,
|
||||
float* _rotation_matrices, int flags );
|
||||
|
||||
|
||||
CV_EXPORTS void cvCalibrateCamera_64d( int image_count, int* _point_counts,
|
||||
CvSize image_size, CvPoint2D64f* _image_points, CvPoint3D64f* _object_points,
|
||||
double* _distortion_coeffs, double* _camera_matrix, double* _translation_vectors,
|
||||
double* _rotation_matrices, int flags );
|
||||
|
||||
|
||||
/* Find 3d position of object given intrinsic camera parameters,
|
||||
3d model of the object and projection of the object into view plane */
|
||||
CV_EXPORTS void cvFindExtrinsicCameraParams( int point_count,
|
||||
CvSize image_size, CvPoint2D32f* _image_points,
|
||||
CvPoint3D32f* _object_points, float* focal_length,
|
||||
CvPoint2D32f principal_point, float* _distortion_coeffs,
|
||||
float* _rotation_vector, float* _translation_vector );
|
||||
|
||||
/* Variant of the previous function that takes double-precision parameters */
|
||||
CV_EXPORTS void cvFindExtrinsicCameraParams_64d( int point_count,
|
||||
CvSize image_size, CvPoint2D64f* _image_points,
|
||||
CvPoint3D64f* _object_points, double* focal_length,
|
||||
CvPoint2D64f principal_point, double* _distortion_coeffs,
|
||||
double* _rotation_vector, double* _translation_vector );
|
||||
|
||||
/* Rodrigues transform */
|
||||
enum
|
||||
{
|
||||
CV_RODRIGUES_M2V = 0,
|
||||
CV_RODRIGUES_V2M = 1
|
||||
};
|
||||
|
||||
/* Converts rotation_matrix matrix to rotation_matrix vector or vice versa */
|
||||
CV_EXPORTS void cvRodrigues( CvMat* rotation_matrix, CvMat* rotation_vector,
|
||||
CvMat* jacobian, int conv_type );
|
||||
|
||||
/* Does reprojection of 3d object points to the view plane */
|
||||
CV_EXPORTS void cvProjectPoints( int point_count, CvPoint3D64f* _object_points,
|
||||
double* _rotation_vector, double* _translation_vector,
|
||||
double* focal_length, CvPoint2D64f principal_point,
|
||||
double* _distortion, CvPoint2D64f* _image_points,
|
||||
double* _deriv_points_rotation_matrix,
|
||||
double* _deriv_points_translation_vect,
|
||||
double* _deriv_points_focal,
|
||||
double* _deriv_points_principal_point,
|
||||
double* _deriv_points_distortion_coeffs );
|
||||
|
||||
|
||||
/* Simpler version of the previous function */
|
||||
CV_EXPORTS void cvProjectPointsSimple( int point_count, CvPoint3D64f* _object_points,
|
||||
double* _rotation_matrix, double* _translation_vector,
|
||||
double* _camera_matrix, double* _distortion, CvPoint2D64f* _image_points );
|
||||
|
||||
|
||||
#define cvMake2DPoints cvConvertPointsHomogeneous
|
||||
#define cvMake3DPoints cvConvertPointsHomogeneous
|
||||
|
||||
#define cvWarpPerspectiveQMatrix cvGetPerspectiveTransform
|
||||
|
||||
#define cvConvertPointsHomogenious cvConvertPointsHomogeneous
|
||||
|
||||
#if !defined __cplusplus && defined _MSC_VER && _MSC_VER >= 1400
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -579,17 +579,17 @@ CVAPI(int) icvCompute3DPoint( double alpha,double betta,
|
||||
CvStereoLineCoeff* coeffs,
|
||||
CvPoint3D64f* point);
|
||||
|
||||
CVAPI(int) icvCreateConvertMatrVect( CvMatr64d rotMatr1,
|
||||
CvMatr64d transVect1,
|
||||
CvMatr64d rotMatr2,
|
||||
CvMatr64d transVect2,
|
||||
CvMatr64d convRotMatr,
|
||||
CvMatr64d convTransVect);
|
||||
CVAPI(int) icvCreateConvertMatrVect( double* rotMatr1,
|
||||
double* transVect1,
|
||||
double* rotMatr2,
|
||||
double* transVect2,
|
||||
double* convRotMatr,
|
||||
double* convTransVect);
|
||||
|
||||
CVAPI(int) icvConvertPointSystem(CvPoint3D64f M2,
|
||||
CvPoint3D64f* M1,
|
||||
CvMatr64d rotMatr,
|
||||
CvMatr64d transVect
|
||||
double* rotMatr,
|
||||
double* transVect
|
||||
);
|
||||
|
||||
CVAPI(int) icvComputeCoeffForStereo( CvStereoCamera* stereoCamera);
|
||||
@ -615,17 +615,17 @@ CVAPI(int) icvComCoeffForLine( CvPoint2D64f point1,
|
||||
CvPoint2D64f point2,
|
||||
CvPoint2D64f point3,
|
||||
CvPoint2D64f point4,
|
||||
CvMatr64d camMatr1,
|
||||
CvMatr64d rotMatr1,
|
||||
CvMatr64d transVect1,
|
||||
CvMatr64d camMatr2,
|
||||
CvMatr64d rotMatr2,
|
||||
CvMatr64d transVect2,
|
||||
double* camMatr1,
|
||||
double* rotMatr1,
|
||||
double* transVect1,
|
||||
double* camMatr2,
|
||||
double* rotMatr2,
|
||||
double* transVect2,
|
||||
CvStereoLineCoeff* coeffs,
|
||||
int* needSwapCameras);
|
||||
|
||||
CVAPI(int) icvGetDirectionForPoint( CvPoint2D64f point,
|
||||
CvMatr64d camMatr,
|
||||
double* camMatr,
|
||||
CvPoint3D64f* direct);
|
||||
|
||||
CVAPI(int) icvGetCrossLines(CvPoint3D64f point11,CvPoint3D64f point12,
|
||||
@ -638,15 +638,15 @@ CVAPI(int) icvComputeStereoLineCoeffs( CvPoint3D64f pointA,
|
||||
double gamma,
|
||||
CvStereoLineCoeff* coeffs);
|
||||
|
||||
/*CVAPI(int) icvComputeFundMatrEpipoles ( CvMatr64d camMatr1,
|
||||
CvMatr64d rotMatr1,
|
||||
CvVect64d transVect1,
|
||||
CvMatr64d camMatr2,
|
||||
CvMatr64d rotMatr2,
|
||||
CvVect64d transVect2,
|
||||
/*CVAPI(int) icvComputeFundMatrEpipoles ( double* camMatr1,
|
||||
double* rotMatr1,
|
||||
double* transVect1,
|
||||
double* camMatr2,
|
||||
double* rotMatr2,
|
||||
double* transVect2,
|
||||
CvPoint2D64f* epipole1,
|
||||
CvPoint2D64f* epipole2,
|
||||
CvMatr64d fundMatr);*/
|
||||
double* fundMatr);*/
|
||||
|
||||
CVAPI(int) icvGetAngleLine( CvPoint2D64f startPoint, CvSize imageSize,CvPoint2D64f *point1,CvPoint2D64f *point2);
|
||||
|
||||
@ -656,24 +656,24 @@ CVAPI(void) icvGetCoefForPiece( CvPoint2D64f p_start,CvPoint2D64f p_end,
|
||||
|
||||
/*CVAPI(void) icvGetCommonArea( CvSize imageSize,
|
||||
CvPoint2D64f epipole1,CvPoint2D64f epipole2,
|
||||
CvMatr64d fundMatr,
|
||||
CvVect64d coeff11,CvVect64d coeff12,
|
||||
CvVect64d coeff21,CvVect64d coeff22,
|
||||
double* fundMatr,
|
||||
double* coeff11,double* coeff12,
|
||||
double* coeff21,double* coeff22,
|
||||
int* result);*/
|
||||
|
||||
CVAPI(void) icvComputeeInfiniteProject1(CvMatr64d rotMatr,
|
||||
CvMatr64d camMatr1,
|
||||
CvMatr64d camMatr2,
|
||||
CVAPI(void) icvComputeeInfiniteProject1(double* rotMatr,
|
||||
double* camMatr1,
|
||||
double* camMatr2,
|
||||
CvPoint2D32f point1,
|
||||
CvPoint2D32f *point2);
|
||||
|
||||
CVAPI(void) icvComputeeInfiniteProject2(CvMatr64d rotMatr,
|
||||
CvMatr64d camMatr1,
|
||||
CvMatr64d camMatr2,
|
||||
CVAPI(void) icvComputeeInfiniteProject2(double* rotMatr,
|
||||
double* camMatr1,
|
||||
double* camMatr2,
|
||||
CvPoint2D32f* point1,
|
||||
CvPoint2D32f point2);
|
||||
|
||||
CVAPI(void) icvGetCrossDirectDirect( CvVect64d direct1,CvVect64d direct2,
|
||||
CVAPI(void) icvGetCrossDirectDirect( double* direct1,double* direct2,
|
||||
CvPoint2D64f *cross,int* result);
|
||||
|
||||
CVAPI(void) icvGetCrossPieceDirect( CvPoint2D64f p_start,CvPoint2D64f p_end,
|
||||
@ -693,20 +693,20 @@ CVAPI(void) icvGetCrossRectDirect( CvSize imageSize,
|
||||
int* result);
|
||||
|
||||
CVAPI(void) icvProjectPointToImage( CvPoint3D64f point,
|
||||
CvMatr64d camMatr,CvMatr64d rotMatr,CvVect64d transVect,
|
||||
double* camMatr,double* rotMatr,double* transVect,
|
||||
CvPoint2D64f* projPoint);
|
||||
|
||||
CVAPI(void) icvGetQuadsTransform( CvSize imageSize,
|
||||
CvMatr64d camMatr1,
|
||||
CvMatr64d rotMatr1,
|
||||
CvVect64d transVect1,
|
||||
CvMatr64d camMatr2,
|
||||
CvMatr64d rotMatr2,
|
||||
CvVect64d transVect2,
|
||||
double* camMatr1,
|
||||
double* rotMatr1,
|
||||
double* transVect1,
|
||||
double* camMatr2,
|
||||
double* rotMatr2,
|
||||
double* transVect2,
|
||||
CvSize* warpSize,
|
||||
double quad1[4][2],
|
||||
double quad2[4][2],
|
||||
CvMatr64d fundMatr,
|
||||
double* fundMatr,
|
||||
CvPoint3D64f* epipole1,
|
||||
CvPoint3D64f* epipole2
|
||||
);
|
||||
@ -715,7 +715,7 @@ CVAPI(void) icvGetQuadsTransformStruct( CvStereoCamera* stereoCamera);
|
||||
|
||||
CVAPI(void) icvComputeStereoParamsForCameras(CvStereoCamera* stereoCamera);
|
||||
|
||||
CVAPI(void) icvGetCutPiece( CvVect64d areaLineCoef1,CvVect64d areaLineCoef2,
|
||||
CVAPI(void) icvGetCutPiece( double* areaLineCoef1,double* areaLineCoef2,
|
||||
CvPoint2D64f epipole,
|
||||
CvSize imageSize,
|
||||
CvPoint2D64f* point11,CvPoint2D64f* point12,
|
||||
@ -726,14 +726,14 @@ CVAPI(void) icvGetMiddleAnglePoint( CvPoint2D64f basePoint,
|
||||
CvPoint2D64f point1,CvPoint2D64f point2,
|
||||
CvPoint2D64f* midPoint);
|
||||
|
||||
CVAPI(void) icvGetNormalDirect(CvVect64d direct,CvPoint2D64f point,CvVect64d normDirect);
|
||||
CVAPI(void) icvGetNormalDirect(double* direct,CvPoint2D64f point,double* normDirect);
|
||||
|
||||
CVAPI(double) icvGetVect(CvPoint2D64f basePoint,CvPoint2D64f point1,CvPoint2D64f point2);
|
||||
|
||||
CVAPI(void) icvProjectPointToDirect( CvPoint2D64f point,CvVect64d lineCoeff,
|
||||
CVAPI(void) icvProjectPointToDirect( CvPoint2D64f point,double* lineCoeff,
|
||||
CvPoint2D64f* projectPoint);
|
||||
|
||||
CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64f point,CvVect64d lineCoef,double*dist);
|
||||
CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64f point,double* lineCoef,double*dist);
|
||||
|
||||
CVAPI(IplImage*) icvCreateIsometricImage( IplImage* src, IplImage* dst,
|
||||
int desired_depth, int desired_num_channels );
|
||||
@ -1096,6 +1096,11 @@ CVAPI(void) cvInitPerspectiveTransform( CvSize size, const CvPoint2D32f vertex[4
|
||||
|
||||
/*************************** View Morphing Functions ************************/
|
||||
|
||||
typedef struct CvMatrix3
|
||||
{
|
||||
float m[3][3];
|
||||
} CvMatrix3;
|
||||
|
||||
/* The order of the function corresponds to the order they should appear in
|
||||
the view morphing pipeline */
|
||||
|
||||
|
@ -42,34 +42,20 @@
|
||||
// Function cvCreateBGStatModel creates and returns initialized BG model.
|
||||
// Parameters:
|
||||
// first_frame - frame from video sequence
|
||||
// model_type – type of BG model (CV_BG_MODEL_MOG, CV_BG_MODEL_FGD,…)
|
||||
// model_type ñ type of BG model (CV_BG_MODEL_MOG, CV_BG_MODEL_FGD,Ö)
|
||||
// parameters - (optional) if NULL the default parameters of the algorithm will be used
|
||||
CvBGStatModel* cvCreateBGStatModel( IplImage* first_frame, int model_type, void* params )
|
||||
static CvBGStatModel* cvCreateBGStatModel( IplImage* first_frame, int model_type, void* params )
|
||||
{
|
||||
CvBGStatModel* bg_model = NULL;
|
||||
|
||||
|
||||
if( model_type == CV_BG_MODEL_FGD || model_type == CV_BG_MODEL_FGD_SIMPLE )
|
||||
bg_model = cvCreateFGDStatModel( first_frame, (CvFGDStatModelParams*)params );
|
||||
else if( model_type == CV_BG_MODEL_MOG )
|
||||
bg_model = cvCreateGaussianBGModel( first_frame, (CvGaussBGStatModelParams*)params );
|
||||
|
||||
|
||||
return bg_model;
|
||||
}
|
||||
|
||||
void cvReleaseBGStatModel( CvBGStatModel** bg_model )
|
||||
{
|
||||
if( bg_model && *bg_model && (*bg_model)->release )
|
||||
(*bg_model)->release( bg_model );
|
||||
}
|
||||
|
||||
int cvUpdateBGStatModel( IplImage* current_frame,
|
||||
CvBGStatModel* bg_model,
|
||||
double learningRate )
|
||||
{
|
||||
return bg_model && bg_model->update ? bg_model->update( current_frame, bg_model, learningRate ) : 0;
|
||||
}
|
||||
|
||||
|
||||
/* FOREGROUND DETECTOR INTERFACE */
|
||||
class CvFGDetectorBase : public CvFGDetector
|
||||
{
|
640
modules/legacy/src/blobtrack.cpp
Normal file
640
modules/legacy/src/blobtrack.cpp
Normal file
@ -0,0 +1,640 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009-2010, Willow Garage Inc., 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 names of the copyright holders 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 if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
//////////////////////////// CvVSModule /////////////////////////////
|
||||
|
||||
CvVSModule::CvVSModule()
|
||||
{
|
||||
m_pNickName = NULL;
|
||||
m_pParamList = NULL;
|
||||
m_pModuleTypeName = NULL;
|
||||
m_pModuleName = NULL;
|
||||
m_Wnd = 0;
|
||||
AddParam("DebugWnd",&m_Wnd);
|
||||
}
|
||||
|
||||
CvVSModule::~CvVSModule()
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;p;)
|
||||
{
|
||||
CvDefParam* pf = p;
|
||||
p=p->next;
|
||||
FreeParam(&pf);
|
||||
}
|
||||
m_pParamList=NULL;
|
||||
if(m_pModuleTypeName)free(m_pModuleTypeName);
|
||||
if(m_pModuleName)free(m_pModuleName);
|
||||
}
|
||||
|
||||
void CvVSModule::FreeParam(CvDefParam** pp)
|
||||
{
|
||||
CvDefParam* p = pp[0];
|
||||
if(p->Str)free(p->Str);
|
||||
if(p->pName)free(p->pName);
|
||||
if(p->pComment)free(p->pComment);
|
||||
cvFree(pp);
|
||||
}
|
||||
|
||||
CvDefParam* CvVSModule::NewParam(const char* name)
|
||||
{
|
||||
CvDefParam* pNew = (CvDefParam*)cvAlloc(sizeof(CvDefParam));
|
||||
memset(pNew,0,sizeof(CvDefParam));
|
||||
pNew->pName = strdup(name);
|
||||
if(m_pParamList==NULL)
|
||||
{
|
||||
m_pParamList = pNew;
|
||||
}
|
||||
else
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;p->next;p=p->next) ;
|
||||
p->next = pNew;
|
||||
}
|
||||
return pNew;
|
||||
}
|
||||
|
||||
CvDefParam* CvVSModule::GetParamPtr(int index)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;index>0 && p;index--,p=p->next) ;
|
||||
return p;
|
||||
}
|
||||
|
||||
CvDefParam* CvVSModule::GetParamPtr(const char* name)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;p;p=p->next)
|
||||
{
|
||||
if(cv_stricmp(p->pName,name)==0) break;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
int CvVSModule::IsParam(const char* name)
|
||||
{
|
||||
return GetParamPtr(name)?1:0;
|
||||
}
|
||||
|
||||
void CvVSModule::AddParam(const char* name, double* pAddr)
|
||||
{
|
||||
NewParam(name)->pDouble = pAddr;
|
||||
}
|
||||
|
||||
void CvVSModule::AddParam(const char* name, float* pAddr)
|
||||
{
|
||||
NewParam(name)->pFloat=pAddr;
|
||||
}
|
||||
|
||||
void CvVSModule::AddParam(const char* name, int* pAddr)
|
||||
{
|
||||
NewParam(name)->pInt=pAddr;
|
||||
}
|
||||
|
||||
void CvVSModule::AddParam(const char* name, const char** pAddr)
|
||||
{
|
||||
CvDefParam* pP = NewParam(name);
|
||||
const char* p = pAddr?pAddr[0]:NULL;
|
||||
pP->pStr = pAddr?(char**)pAddr:&(pP->Str);
|
||||
if(p)
|
||||
{
|
||||
pP->Str = strdup(p);
|
||||
pP->pStr[0] = pP->Str;
|
||||
}
|
||||
}
|
||||
|
||||
void CvVSModule::AddParam(const char* name)
|
||||
{
|
||||
CvDefParam* p = NewParam(name);
|
||||
p->pDouble = &p->Double;
|
||||
}
|
||||
|
||||
void CvVSModule::CommentParam(const char* name, const char* pComment)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(name);
|
||||
if(p)p->pComment = pComment ? strdup(pComment) : 0;
|
||||
}
|
||||
|
||||
void CvVSModule::SetTypeName(const char* name){m_pModuleTypeName = strdup(name);}
|
||||
|
||||
void CvVSModule::SetModuleName(const char* name){m_pModuleName = strdup(name);}
|
||||
|
||||
void CvVSModule::DelParam(const char* name)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
CvDefParam* pPrev = NULL;
|
||||
for(;p;p=p->next)
|
||||
{
|
||||
if(cv_stricmp(p->pName,name)==0) break;
|
||||
pPrev = p;
|
||||
}
|
||||
if(p)
|
||||
{
|
||||
if(pPrev)
|
||||
{
|
||||
pPrev->next = p->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pParamList = p->next;
|
||||
}
|
||||
FreeParam(&p);
|
||||
}
|
||||
}/* DelParam */
|
||||
|
||||
|
||||
const char* CvVSModule::GetParamName(int index)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(index);
|
||||
return p?p->pName:NULL;
|
||||
}
|
||||
const char* CvVSModule::GetParamComment(const char* name)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(name);
|
||||
if(p && p->pComment) return p->pComment;
|
||||
return NULL;
|
||||
}
|
||||
double CvVSModule::GetParam(const char* name)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(name);
|
||||
if(p)
|
||||
{
|
||||
if(p->pDouble) return p->pDouble[0];
|
||||
if(p->pFloat) return p->pFloat[0];
|
||||
if(p->pInt) return p->pInt[0];
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
const char* CvVSModule::GetParamStr(const char* name)
|
||||
{
|
||||
CvDefParam* p = GetParamPtr(name);
|
||||
return p?p->Str:NULL;
|
||||
}
|
||||
void CvVSModule::SetParam(const char* name, double val)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(;p;p=p->next)
|
||||
{
|
||||
if(cv_stricmp(p->pName,name) != 0) continue;
|
||||
if(p->pDouble)p->pDouble[0] = val;
|
||||
if(p->pFloat)p->pFloat[0] = (float)val;
|
||||
if(p->pInt)p->pInt[0] = cvRound(val);
|
||||
}
|
||||
}
|
||||
void CvVSModule::SetParamStr(const char* name, const char* str)
|
||||
{
|
||||
CvDefParam* p = m_pParamList;
|
||||
for(; p; p=p->next)
|
||||
{
|
||||
if(cv_stricmp(p->pName,name) != 0) continue;
|
||||
if(p->pStr)
|
||||
{
|
||||
if(p->Str)free(p->Str);
|
||||
p->Str = NULL;
|
||||
if(str)p->Str = strdup(str);
|
||||
p->pStr[0] = p->Str;
|
||||
}
|
||||
}
|
||||
/* Convert to double and set: */
|
||||
if(str) SetParam(name,atof(str));
|
||||
}
|
||||
|
||||
void CvVSModule::TransferParamsFromChild(CvVSModule* pM, const char* prefix)
|
||||
{
|
||||
char tmp[1024];
|
||||
const char* FN = NULL;
|
||||
int i;
|
||||
for(i=0;;++i)
|
||||
{
|
||||
const char* N = pM->GetParamName(i);
|
||||
if(N == NULL) break;
|
||||
FN = N;
|
||||
if(prefix)
|
||||
{
|
||||
strcpy(tmp,prefix);
|
||||
strcat(tmp,"_");
|
||||
FN = strcat(tmp,N);
|
||||
}
|
||||
|
||||
if(!IsParam(FN))
|
||||
{
|
||||
if(pM->GetParamStr(N))
|
||||
{
|
||||
AddParam(FN,(const char**)NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddParam(FN);
|
||||
}
|
||||
}
|
||||
if(pM->GetParamStr(N))
|
||||
{
|
||||
const char* val = pM->GetParamStr(N);
|
||||
SetParamStr(FN,val);
|
||||
}
|
||||
else
|
||||
{
|
||||
double val = pM->GetParam(N);
|
||||
SetParam(FN,val);
|
||||
}
|
||||
CommentParam(FN, pM->GetParamComment(N));
|
||||
}/* transfer next param */
|
||||
}/* Transfer params */
|
||||
|
||||
void CvVSModule::TransferParamsToChild(CvVSModule* pM, char* prefix)
|
||||
{
|
||||
char tmp[1024];
|
||||
int i;
|
||||
for(i=0;;++i)
|
||||
{
|
||||
const char* N = pM->GetParamName(i);
|
||||
if(N == NULL) break;
|
||||
if(prefix)
|
||||
{
|
||||
strcpy(tmp,prefix);
|
||||
strcat(tmp,"_");
|
||||
strcat(tmp,N);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(tmp,N);
|
||||
}
|
||||
|
||||
if(IsParam(tmp))
|
||||
{
|
||||
if(GetParamStr(tmp))
|
||||
pM->SetParamStr(N,GetParamStr(tmp));
|
||||
else
|
||||
pM->SetParam(N,GetParam(tmp));
|
||||
}
|
||||
}/* Transfer next parameter */
|
||||
pM->ParamUpdate();
|
||||
}/* Transfer params */
|
||||
|
||||
void CvVSModule::ParamUpdate(){}
|
||||
|
||||
const char* CvVSModule::GetTypeName()
|
||||
{
|
||||
return m_pModuleTypeName;
|
||||
}
|
||||
|
||||
int CvVSModule::IsModuleTypeName(const char* name)
|
||||
{
|
||||
return m_pModuleTypeName?(cv_stricmp(m_pModuleTypeName,name)==0):0;
|
||||
}
|
||||
|
||||
char* CvVSModule::GetModuleName()
|
||||
{
|
||||
return m_pModuleName;
|
||||
}
|
||||
|
||||
int CvVSModule::IsModuleName(const char* name)
|
||||
{
|
||||
return m_pModuleName?(cv_stricmp(m_pModuleName,name)==0):0;
|
||||
}
|
||||
|
||||
void CvVSModule::SetNickName(const char* pStr)
|
||||
{
|
||||
if(m_pNickName)
|
||||
free(m_pNickName);
|
||||
|
||||
m_pNickName = NULL;
|
||||
|
||||
if(pStr)
|
||||
m_pNickName = strdup(pStr);
|
||||
}
|
||||
|
||||
const char* CvVSModule::GetNickName()
|
||||
{
|
||||
return m_pNickName ? m_pNickName : "unknown";
|
||||
}
|
||||
|
||||
void CvVSModule::SaveState(CvFileStorage*)
|
||||
{
|
||||
}
|
||||
|
||||
void CvVSModule::LoadState(CvFileStorage*, CvFileNode*)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
void cvWriteStruct(CvFileStorage* fs, const char* name, void* addr, const char* desc, int num)
|
||||
{
|
||||
cvStartWriteStruct(fs,name,CV_NODE_SEQ|CV_NODE_FLOW);
|
||||
cvWriteRawData(fs,addr,num,desc);
|
||||
cvEndWriteStruct(fs);
|
||||
}
|
||||
|
||||
void cvReadStructByName(CvFileStorage* fs, CvFileNode* node, const char* name, void* addr, const char* desc)
|
||||
{
|
||||
CvFileNode* pSeqNode = cvGetFileNodeByName(fs, node, name);
|
||||
if(pSeqNode==NULL)
|
||||
{
|
||||
printf("WARNING!!! Can't read structure %s\n",name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(CV_NODE_IS_SEQ(pSeqNode->tag))
|
||||
{
|
||||
cvReadRawData( fs, pSeqNode, addr, desc );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("WARNING!!! Structure %s is not sequence and can not be read\n",name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////// CvFGDetector ///////////////////////////////////////////
|
||||
|
||||
CvFGDetector::CvFGDetector()
|
||||
{
|
||||
SetTypeName("FGDetector");
|
||||
}
|
||||
|
||||
void cvReleaseFGDetector(CvFGDetector** ppT )
|
||||
{
|
||||
ppT[0]->Release();
|
||||
ppT[0] = 0;
|
||||
}
|
||||
|
||||
///////////////////////////// CvBlobSeq ///////////////////////////////////////////////
|
||||
|
||||
CvBlobTrackSeq::CvBlobTrackSeq(int TrackSize)
|
||||
{
|
||||
m_pMem = cvCreateMemStorage();
|
||||
m_pSeq = cvCreateSeq(0,sizeof(CvSeq),TrackSize,m_pMem);
|
||||
}
|
||||
|
||||
CvBlobTrackSeq::~CvBlobTrackSeq()
|
||||
{
|
||||
Clear();
|
||||
cvReleaseMemStorage(&m_pMem);
|
||||
}
|
||||
|
||||
CvBlobTrack* CvBlobTrackSeq::GetBlobTrack(int TrackIndex)
|
||||
{
|
||||
return (CvBlobTrack*)cvGetSeqElem(m_pSeq,TrackIndex);
|
||||
}
|
||||
|
||||
CvBlobTrack* CvBlobTrackSeq::GetBlobTrackByID(int TrackID)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<m_pSeq->total; ++i)
|
||||
{
|
||||
CvBlobTrack* pP = GetBlobTrack(i);
|
||||
if(pP && pP->TrackID == TrackID)
|
||||
return pP;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CvBlobTrackSeq::DelBlobTrack(int TrackIndex)
|
||||
{
|
||||
CvBlobTrack* pP = GetBlobTrack(TrackIndex);
|
||||
if(pP && pP->pBlobSeq) delete pP->pBlobSeq;
|
||||
cvSeqRemove(m_pSeq,TrackIndex);
|
||||
}
|
||||
|
||||
void CvBlobTrackSeq::DelBlobTrackByID(int TrackID)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<m_pSeq->total; ++i)
|
||||
{
|
||||
CvBlobTrack* pP = GetBlobTrack(i);
|
||||
if(TrackID == pP->TrackID)
|
||||
{
|
||||
DelBlobTrack(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CvBlobTrackSeq::Clear()
|
||||
{
|
||||
int i;
|
||||
for(i=GetBlobTrackNum();i>0;i--)
|
||||
{
|
||||
DelBlobTrack(i-1);
|
||||
}
|
||||
cvClearSeq(m_pSeq);
|
||||
}
|
||||
|
||||
void CvBlobTrackSeq::AddBlobTrack(int TrackID, int StartFrame)
|
||||
{
|
||||
CvBlobTrack N;
|
||||
N.TrackID = TrackID;
|
||||
N.StartFrame = StartFrame;
|
||||
N.pBlobSeq = new CvBlobSeq;
|
||||
cvSeqPush(m_pSeq,&N);
|
||||
}
|
||||
|
||||
int CvBlobTrackSeq::GetBlobTrackNum()
|
||||
{
|
||||
return m_pSeq->total;
|
||||
}
|
||||
|
||||
void cvReleaseBlobDetector(CvBlobDetector** ppBD)
|
||||
{
|
||||
ppBD[0]->Release();
|
||||
ppBD[0] = NULL;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////// CvObjectDetector /////////////////////////////////
|
||||
|
||||
CvObjectDetector::CvObjectDetector( const char* /*detector_file_name*/ )
|
||||
{
|
||||
}
|
||||
|
||||
CvObjectDetector::~CvObjectDetector()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the current detector and load new detector from file
|
||||
* (if detector_file_name is not 0)
|
||||
* Return true on success:
|
||||
*/
|
||||
bool CvObjectDetector::Load( const char* /*detector_file_name*/ )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return min detector window size: */
|
||||
CvSize CvObjectDetector::GetMinWindowSize() const
|
||||
{
|
||||
return cvSize(0,0);
|
||||
}
|
||||
|
||||
/* Return max border: */
|
||||
int CvObjectDetector::GetMaxBorderSize() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect the object on the image and push the detected
|
||||
* blobs into <detected_blob_seq> which must be the sequence of <CvDetectedBlob>s
|
||||
*/
|
||||
void CvObjectDetector::Detect( const CvArr* /*img*/,
|
||||
/* out */ CvBlobSeq* /*detected_blob_seq*/ )
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////// CvBlobTracker //////////////////////////////////////
|
||||
|
||||
CvBlobTracker::CvBlobTracker(){SetTypeName("BlobTracker");}
|
||||
|
||||
/* Process one blob (for multi hypothesis tracing): */
|
||||
void CvBlobTracker::ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/)
|
||||
{
|
||||
CvBlob* pB;
|
||||
int ID = 0;
|
||||
assert(pBlob);
|
||||
//pBlob->ID;
|
||||
pB = GetBlob(BlobIndex);
|
||||
if(pB)
|
||||
pBlob[0] = pB[0];
|
||||
pBlob->ID = ID;
|
||||
}
|
||||
|
||||
/* Get confidence/wieght/probability (0-1) for blob: */
|
||||
double CvBlobTracker::GetConfidence(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
double CvBlobTracker::GetConfidenceList(CvBlobSeq* pBlobList, IplImage* pImg, IplImage* pImgFG)
|
||||
{
|
||||
int b,bN = pBlobList->GetBlobNum();
|
||||
double W = 1;
|
||||
for(b=0;b<bN;++b)
|
||||
{
|
||||
CvBlob* pB = pBlobList->GetBlob(b);
|
||||
int BI = GetBlobIndexByID(pB->ID);
|
||||
W *= GetConfidence(BI,pB,pImg,pImgFG);
|
||||
}
|
||||
return W;
|
||||
}
|
||||
|
||||
void CvBlobTracker::UpdateBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/)
|
||||
{
|
||||
}
|
||||
|
||||
/* Update all blob models: */
|
||||
void CvBlobTracker::Update(IplImage* pImg, IplImage* pImgFG)
|
||||
{
|
||||
int i;
|
||||
for(i=GetBlobNum();i>0;i--)
|
||||
{
|
||||
CvBlob* pB=GetBlob(i-1);
|
||||
UpdateBlob(i-1, pB, pImg, pImgFG);
|
||||
}
|
||||
}
|
||||
|
||||
/* Return pointer to blob by its unique ID: */
|
||||
int CvBlobTracker::GetBlobIndexByID(int BlobID)
|
||||
{
|
||||
int i;
|
||||
for(i=GetBlobNum();i>0;i--)
|
||||
{
|
||||
CvBlob* pB=GetBlob(i-1);
|
||||
if(CV_BLOB_ID(pB) == BlobID) return i-1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Return pointer to blob by its unique ID: */
|
||||
CvBlob* CvBlobTracker::GetBlobByID(int BlobID)
|
||||
{
|
||||
return GetBlob(GetBlobIndexByID(BlobID));
|
||||
}
|
||||
|
||||
/* Delete blob by its ID: */
|
||||
void CvBlobTracker::DelBlobByID(int BlobID)
|
||||
{
|
||||
DelBlob(GetBlobIndexByID(BlobID));
|
||||
}
|
||||
|
||||
/* Set new parameters for specified (by index) blob: */
|
||||
void CvBlobTracker::SetBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/)
|
||||
{
|
||||
}
|
||||
|
||||
/* Set new parameters for specified (by ID) blob: */
|
||||
void CvBlobTracker::SetBlobByID(int BlobID, CvBlob* pBlob)
|
||||
{
|
||||
SetBlob(GetBlobIndexByID(BlobID),pBlob);
|
||||
}
|
||||
|
||||
/* =============== MULTI HYPOTHESIS INTERFACE ================== */
|
||||
|
||||
/* Return number of position hyposetis of currently tracked blob: */
|
||||
int CvBlobTracker::GetBlobHypNum(int /*BlobIdx*/)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return pointer to specified blob hypothesis by index blob: */
|
||||
CvBlob* CvBlobTracker::GetBlobHyp(int BlobIndex, int /*hypothesis*/)
|
||||
{
|
||||
return GetBlob(BlobIndex);
|
||||
}
|
||||
|
||||
/* Set new parameters for specified (by index) blob hyp
|
||||
* (can be called several times for each hyp ):
|
||||
*/
|
||||
void CvBlobTracker::SetBlobHyp(int /*BlobIndex*/, CvBlob* /*pBlob*/)
|
||||
{
|
||||
}
|
||||
|
||||
void cvReleaseBlobTracker(CvBlobTracker**ppT )
|
||||
{
|
||||
ppT[0]->Release();
|
||||
ppT[0] = 0;
|
||||
}
|
||||
|
684
modules/legacy/src/compat.cpp
Normal file
684
modules/legacy/src/compat.cpp
Normal file
@ -0,0 +1,684 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2010, Willow Garage Inc., 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 if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
CvMat cvMatArray( int rows, int cols, int type,
|
||||
int count, void* data)
|
||||
{
|
||||
return cvMat( rows*count, cols, type, data );
|
||||
}
|
||||
|
||||
|
||||
double cvMean( const CvArr* image, const CvArr* mask )
|
||||
{
|
||||
CvScalar mean = cvAvg( image, mask );
|
||||
return mean.val[0];
|
||||
}
|
||||
|
||||
|
||||
double cvSumPixels( const CvArr* image )
|
||||
{
|
||||
CvScalar scalar = cvSum( image );
|
||||
return scalar.val[0];
|
||||
}
|
||||
|
||||
void cvMean_StdDev( const CvArr* image, double* mean, double* sdv, const CvArr* mask)
|
||||
{
|
||||
CvScalar _mean, _sdv;
|
||||
cvAvgSdv( image, &_mean, &_sdv, mask );
|
||||
|
||||
if( mean )
|
||||
*mean = _mean.val[0];
|
||||
|
||||
if( sdv )
|
||||
*sdv = _sdv.val[0];
|
||||
}
|
||||
|
||||
|
||||
void cvmPerspectiveProject( const CvMat* mat, const CvArr* src, CvArr* dst )
|
||||
{
|
||||
CvMat tsrc, tdst;
|
||||
|
||||
cvReshape( src, &tsrc, 3, 0 );
|
||||
cvReshape( dst, &tdst, 3, 0 );
|
||||
|
||||
cvPerspectiveTransform( &tsrc, &tdst, mat );
|
||||
}
|
||||
|
||||
|
||||
void cvFillImage( CvArr* mat, double color )
|
||||
{
|
||||
cvSet( mat, cvColorToScalar(color, cvGetElemType(mat)), 0 );
|
||||
}
|
||||
|
||||
|
||||
/* Changes RNG range while preserving RNG state */
|
||||
void cvRandSetRange( CvRandState* state, double param1, double param2, int index)
|
||||
{
|
||||
if( !state )
|
||||
{
|
||||
cvError( CV_StsNullPtr, "cvRandSetRange", "Null pointer to RNG state", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
if( (unsigned)(index + 1) > 4 )
|
||||
{
|
||||
cvError( CV_StsOutOfRange, "cvRandSetRange", "index is not in -1..3", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
if( index < 0 )
|
||||
{
|
||||
state->param[0].val[0] = state->param[0].val[1] =
|
||||
state->param[0].val[2] = state->param[0].val[3] = param1;
|
||||
state->param[1].val[0] = state->param[1].val[1] =
|
||||
state->param[1].val[2] = state->param[1].val[3] = param2;
|
||||
}
|
||||
else
|
||||
{
|
||||
state->param[0].val[index] = param1;
|
||||
state->param[1].val[index] = param2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cvRandInit( CvRandState* state, double param1, double param2,
|
||||
int seed, int disttype)
|
||||
{
|
||||
if( !state )
|
||||
{
|
||||
cvError( CV_StsNullPtr, "cvRandInit", "Null pointer to RNG state", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
if( disttype != CV_RAND_UNI && disttype != CV_RAND_NORMAL )
|
||||
{
|
||||
cvError( CV_StsBadFlag, "cvRandInit", "Unknown distribution type", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
state->state = (uint64)(seed ? seed : -1);
|
||||
state->disttype = disttype;
|
||||
cvRandSetRange( state, param1, param2, -1 );
|
||||
}
|
||||
|
||||
|
||||
/* Fills array with random numbers */
|
||||
void cvRand( CvRandState* state, CvArr* arr )
|
||||
{
|
||||
if( !state )
|
||||
{
|
||||
cvError( CV_StsNullPtr, "cvRand", "Null pointer to RNG state", "cvcompat.h", 0 );
|
||||
return;
|
||||
}
|
||||
cvRandArr( &state->state, arr, state->disttype, state->param[0], state->param[1] );
|
||||
}
|
||||
|
||||
void cvbRand( CvRandState* state, float* dst, int len )
|
||||
{
|
||||
CvMat mat = cvMat( 1, len, CV_32F, (void*)dst );
|
||||
cvRand( state, &mat );
|
||||
}
|
||||
|
||||
|
||||
void cvbCartToPolar( const float* y, const float* x, float* magnitude, float* angle, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
CvMat mm = mx;
|
||||
CvMat ma = mx;
|
||||
|
||||
my.data.fl = (float*)y;
|
||||
mm.data.fl = (float*)magnitude;
|
||||
ma.data.fl = (float*)angle;
|
||||
|
||||
cvCartToPolar( &mx, &my, &mm, angle ? &ma : NULL, 1 );
|
||||
}
|
||||
|
||||
|
||||
void cvbFastArctan( const float* y, const float* x, float* angle, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
CvMat ma = mx;
|
||||
|
||||
my.data.fl = (float*)y;
|
||||
ma.data.fl = (float*)angle;
|
||||
|
||||
cvCartToPolar( &mx, &my, NULL, &ma, 1 );
|
||||
}
|
||||
|
||||
|
||||
void cvbSqrt( const float* x, float* y, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
my.data.fl = (float*)y;
|
||||
|
||||
cvPow( &mx, &my, 0.5 );
|
||||
}
|
||||
|
||||
|
||||
void cvbInvSqrt( const float* x, float* y, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
my.data.fl = (float*)y;
|
||||
|
||||
cvPow( &mx, &my, -0.5 );
|
||||
}
|
||||
|
||||
|
||||
void cvbReciprocal( const float* x, float* y, int len )
|
||||
{
|
||||
CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
|
||||
CvMat my = mx;
|
||||
my.data.fl = (float*)y;
|
||||
|
||||
cvPow( &mx, &my, -1 );
|
||||
}
|
||||
|
||||
|
||||
void cvbFastExp( const float* x, double* y, int len )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < len; i++ )
|
||||
y[i] = exp((double)x[i]);
|
||||
}
|
||||
|
||||
|
||||
void cvbFastLog( const double* x, float* y, int len )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < len; i++ )
|
||||
y[i] = (float)log(x[i]);
|
||||
}
|
||||
|
||||
|
||||
CvRect cvContourBoundingRect( void* point_set, int update)
|
||||
{
|
||||
return cvBoundingRect( point_set, update );
|
||||
}
|
||||
|
||||
|
||||
double cvPseudoInverse( const CvArr* src, CvArr* dst )
|
||||
{
|
||||
return cvInvert( src, dst, CV_SVD );
|
||||
}
|
||||
|
||||
|
||||
/* Calculates exact convex hull of 2d point set */
|
||||
void cvConvexHull( CvPoint* points, int num_points, CvRect*,
|
||||
int orientation, int* hull, int* hullsize )
|
||||
{
|
||||
CvMat points1 = cvMat( 1, num_points, CV_32SC2, points );
|
||||
CvMat hull1 = cvMat( 1, num_points, CV_32SC1, hull );
|
||||
|
||||
cvConvexHull2( &points1, &hull1, orientation, 0 );
|
||||
*hullsize = hull1.cols;
|
||||
}
|
||||
|
||||
void cvMinAreaRect( CvPoint* points, int n, int, int, int, int,
|
||||
CvPoint2D32f* anchor, CvPoint2D32f* vect1, CvPoint2D32f* vect2 )
|
||||
{
|
||||
CvMat mat = cvMat( 1, n, CV_32SC2, points );
|
||||
CvBox2D box = cvMinAreaRect2( &mat, 0 );
|
||||
CvPoint2D32f pt[4];
|
||||
|
||||
cvBoxPoints( box, pt );
|
||||
*anchor = pt[0];
|
||||
vect1->x = pt[1].x - pt[0].x;
|
||||
vect1->y = pt[1].y - pt[0].y;
|
||||
vect2->x = pt[3].x - pt[0].x;
|
||||
vect2->y = pt[3].y - pt[0].y;
|
||||
}
|
||||
|
||||
void cvFitLine3D( CvPoint3D32f* points, int count, int dist,
|
||||
void *param, float reps, float aeps, float* line )
|
||||
{
|
||||
CvMat mat = cvMat( 1, count, CV_32FC3, points );
|
||||
float _param = param != NULL ? *(float*)param : 0.f;
|
||||
assert( dist != CV_DIST_USER );
|
||||
cvFitLine( &mat, dist, _param, reps, aeps, line );
|
||||
}
|
||||
|
||||
/* Fits a line into set of 2d points in a robust way (M-estimator technique) */
|
||||
void cvFitLine2D( CvPoint2D32f* points, int count, int dist,
|
||||
void *param, float reps, float aeps, float* line )
|
||||
{
|
||||
CvMat mat = cvMat( 1, count, CV_32FC2, points );
|
||||
float _param = param != NULL ? *(float*)param : 0.f;
|
||||
assert( dist != CV_DIST_USER );
|
||||
cvFitLine( &mat, dist, _param, reps, aeps, line );
|
||||
}
|
||||
|
||||
|
||||
void cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box )
|
||||
{
|
||||
CvMat mat = cvMat( 1, count, CV_32FC2, (void*)points );
|
||||
*box = cvFitEllipse2( &mat );
|
||||
}
|
||||
|
||||
/* Projects 2d points to one of standard coordinate planes
|
||||
(i.e. removes one of coordinates) */
|
||||
void cvProject3D( CvPoint3D32f* points3D, int count,
|
||||
CvPoint2D32f* points2D, int xIndx, int yIndx)
|
||||
{
|
||||
CvMat src = cvMat( 1, count, CV_32FC3, points3D );
|
||||
CvMat dst = cvMat( 1, count, CV_32FC2, points2D );
|
||||
float m[6] = {0,0,0,0,0,0};
|
||||
CvMat M = cvMat( 2, 3, CV_32F, m );
|
||||
|
||||
assert( (unsigned)xIndx < 3 && (unsigned)yIndx < 3 );
|
||||
m[xIndx] = m[yIndx+3] = 1.f;
|
||||
|
||||
cvTransform( &src, &dst, &M, NULL );
|
||||
}
|
||||
|
||||
|
||||
int cvHoughLines( CvArr* image, double rho,
|
||||
double theta, int threshold,
|
||||
float* lines, int linesNumber )
|
||||
{
|
||||
CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines );
|
||||
cvHoughLines2( image, &linesMat, CV_HOUGH_STANDARD,
|
||||
rho, theta, threshold, 0, 0 );
|
||||
|
||||
return linesMat.cols;
|
||||
}
|
||||
|
||||
|
||||
int cvHoughLinesP( CvArr* image, double rho,
|
||||
double theta, int threshold,
|
||||
int lineLength, int lineGap,
|
||||
int* lines, int linesNumber )
|
||||
{
|
||||
CvMat linesMat = cvMat( 1, linesNumber, CV_32SC4, lines );
|
||||
cvHoughLines2( image, &linesMat, CV_HOUGH_PROBABILISTIC,
|
||||
rho, theta, threshold, lineLength, lineGap );
|
||||
|
||||
return linesMat.cols;
|
||||
}
|
||||
|
||||
|
||||
int cvHoughLinesSDiv( CvArr* image, double rho, int srn,
|
||||
double theta, int stn, int threshold,
|
||||
float* lines, int linesNumber )
|
||||
{
|
||||
CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines );
|
||||
cvHoughLines2( image, &linesMat, CV_HOUGH_MULTI_SCALE,
|
||||
rho, theta, threshold, srn, stn );
|
||||
|
||||
return linesMat.cols;
|
||||
}
|
||||
|
||||
|
||||
float cvCalcEMD( const float* signature1, int size1, const float* signature2, int size2,
|
||||
int dims, int dist_type, CvDistanceFunction dist_func,
|
||||
float* lower_bound, void* user_param)
|
||||
{
|
||||
CvMat sign1 = cvMat( size1, dims + 1, CV_32FC1, (void*)signature1 );
|
||||
CvMat sign2 = cvMat( size2, dims + 1, CV_32FC1, (void*)signature2 );
|
||||
|
||||
return cvCalcEMD2( &sign1, &sign2, dist_type, dist_func, 0, 0, lower_bound, user_param );
|
||||
}
|
||||
|
||||
|
||||
void cvKMeans( int num_clusters, float** samples,
|
||||
int num_samples, int vec_size,
|
||||
CvTermCriteria termcrit, int* cluster_idx )
|
||||
{
|
||||
CvMat* samples_mat = cvCreateMat( num_samples, vec_size, CV_32FC1 );
|
||||
CvMat cluster_idx_mat = cvMat( num_samples, 1, CV_32SC1, cluster_idx );
|
||||
int i;
|
||||
for( i = 0; i < num_samples; i++ )
|
||||
memcpy( samples_mat->data.fl + i*vec_size, samples[i], vec_size*sizeof(float));
|
||||
cvKMeans2( samples_mat, num_clusters, &cluster_idx_mat, termcrit, 1, 0, 0, 0, 0 );
|
||||
cvReleaseMat( &samples_mat );
|
||||
}
|
||||
|
||||
|
||||
void cvStartScanGraph( CvGraph* graph, CvGraphScanner* scanner,
|
||||
CvGraphVtx* vtx, int mask)
|
||||
{
|
||||
CvGraphScanner* temp_scanner;
|
||||
|
||||
if( !scanner )
|
||||
cvError( CV_StsNullPtr, "cvStartScanGraph", "Null scanner pointer", "cvcompat.h", 0 );
|
||||
|
||||
temp_scanner = cvCreateGraphScanner( graph, vtx, mask );
|
||||
*scanner = *temp_scanner;
|
||||
cvFree( &temp_scanner );
|
||||
}
|
||||
|
||||
|
||||
void cvEndScanGraph( CvGraphScanner* scanner )
|
||||
{
|
||||
if( !scanner )
|
||||
cvError( CV_StsNullPtr, "cvEndScanGraph", "Null scanner pointer", "cvcompat.h", 0 );
|
||||
|
||||
if( scanner->stack )
|
||||
{
|
||||
CvGraphScanner* temp_scanner = (CvGraphScanner*)cvAlloc( sizeof(*temp_scanner) );
|
||||
*temp_scanner = *scanner;
|
||||
cvReleaseGraphScanner( &temp_scanner );
|
||||
memset( scanner, 0, sizeof(*scanner) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* old drawing functions */
|
||||
void cvLineAA( CvArr* img, CvPoint pt1, CvPoint pt2, double color, int scale)
|
||||
{
|
||||
cvLine( img, pt1, pt2, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale );
|
||||
}
|
||||
|
||||
void cvCircleAA( CvArr* img, CvPoint center, int radius, double color, int scale)
|
||||
{
|
||||
cvCircle( img, center, radius, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale );
|
||||
}
|
||||
|
||||
void cvEllipseAA( CvArr* img, CvPoint center, CvSize axes,
|
||||
double angle, double start_angle,
|
||||
double end_angle, double color,
|
||||
int scale)
|
||||
{
|
||||
cvEllipse( img, center, axes, angle, start_angle, end_angle,
|
||||
cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale );
|
||||
}
|
||||
|
||||
void cvPolyLineAA( CvArr* img, CvPoint** pts, int* npts, int contours,
|
||||
int is_closed, double color, int scale )
|
||||
{
|
||||
cvPolyLine( img, pts, npts, contours, is_closed,
|
||||
cvColorToScalar(color, cvGetElemType(img)),
|
||||
1, CV_AA, scale );
|
||||
}
|
||||
|
||||
|
||||
void cvUnDistortOnce( const CvArr* src, CvArr* dst,
|
||||
const float* intrinsic_matrix,
|
||||
const float* distortion_coeffs,
|
||||
int )
|
||||
{
|
||||
CvMat _a = cvMat( 3, 3, CV_32F, (void*)intrinsic_matrix );
|
||||
CvMat _k = cvMat( 4, 1, CV_32F, (void*)distortion_coeffs );
|
||||
cvUndistort2( src, dst, &_a, &_k, 0 );
|
||||
}
|
||||
|
||||
|
||||
/* the two functions below have quite hackerish implementations, use with care
|
||||
(or, which is better, switch to cvUndistortInitMap and cvRemap instead */
|
||||
void cvUnDistortInit( const CvArr*,
|
||||
CvArr* undistortion_map,
|
||||
const float* A, const float* k,
|
||||
int)
|
||||
{
|
||||
union { uchar* ptr; float* fl; } data;
|
||||
CvSize sz;
|
||||
cvGetRawData( undistortion_map, &data.ptr, 0, &sz );
|
||||
assert( sz.width >= 8 );
|
||||
/* just save the intrinsic parameters to the map */
|
||||
data.fl[0] = A[0]; data.fl[1] = A[4];
|
||||
data.fl[2] = A[2]; data.fl[3] = A[5];
|
||||
data.fl[4] = k[0]; data.fl[5] = k[1];
|
||||
data.fl[6] = k[2]; data.fl[7] = k[3];
|
||||
}
|
||||
|
||||
void cvUnDistort( const CvArr* src, CvArr* dst,
|
||||
const CvArr* undistortion_map, int )
|
||||
{
|
||||
union { uchar* ptr; float* fl; } data;
|
||||
float a[] = {0,0,0,0,0,0,0,0,1};
|
||||
CvSize sz;
|
||||
cvGetRawData( undistortion_map, &data.ptr, 0, &sz );
|
||||
assert( sz.width >= 8 );
|
||||
a[0] = data.fl[0]; a[4] = data.fl[1];
|
||||
a[2] = data.fl[2]; a[5] = data.fl[3];
|
||||
cvUnDistortOnce( src, dst, a, data.fl + 4, 1 );
|
||||
}
|
||||
|
||||
|
||||
/* Find fundamental matrix */
|
||||
void cvFindFundamentalMatrix( int* points1, int* points2, int numpoints, int, float* matrix )
|
||||
{
|
||||
CvMat* pointsMat1;
|
||||
CvMat* pointsMat2;
|
||||
CvMat fundMatr = cvMat(3,3,CV_32F,matrix);
|
||||
int i, curr = 0;
|
||||
|
||||
pointsMat1 = cvCreateMat(3,numpoints,CV_64F);
|
||||
pointsMat2 = cvCreateMat(3,numpoints,CV_64F);
|
||||
|
||||
for( i = 0; i < numpoints; i++ )
|
||||
{
|
||||
cvmSet(pointsMat1,0,i,points1[curr]);//x
|
||||
cvmSet(pointsMat1,1,i,points1[curr+1]);//y
|
||||
cvmSet(pointsMat1,2,i,1.0);
|
||||
|
||||
cvmSet(pointsMat2,0,i,points2[curr]);//x
|
||||
cvmSet(pointsMat2,1,i,points2[curr+1]);//y
|
||||
cvmSet(pointsMat2,2,i,1.0);
|
||||
curr += 2;
|
||||
}
|
||||
|
||||
cvFindFundamentalMat(pointsMat1,pointsMat2,&fundMatr,CV_FM_RANSAC,1,0.99,0);
|
||||
|
||||
cvReleaseMat(&pointsMat1);
|
||||
cvReleaseMat(&pointsMat2);
|
||||
}
|
||||
|
||||
|
||||
int cvFindChessBoardCornerGuesses( const void* arr, void*,
|
||||
CvMemStorage*, CvSize pattern_size,
|
||||
CvPoint2D32f* corners, int* corner_count )
|
||||
{
|
||||
return cvFindChessboardCorners( arr, pattern_size, corners,
|
||||
corner_count, CV_CALIB_CB_ADAPTIVE_THRESH );
|
||||
}
|
||||
|
||||
|
||||
/* Calibrates camera using multiple views of calibration pattern */
|
||||
void cvCalibrateCamera( int image_count, int* _point_counts,
|
||||
CvSize image_size, CvPoint2D32f* _image_points, CvPoint3D32f* _object_points,
|
||||
float* _distortion_coeffs, float* _camera_matrix, float* _translation_vectors,
|
||||
float* _rotation_matrices, int flags )
|
||||
{
|
||||
int i, total = 0;
|
||||
CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts );
|
||||
CvMat image_points, object_points;
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs );
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, _camera_matrix );
|
||||
CvMat rotation_matrices = cvMat( image_count, 9, CV_32FC1, _rotation_matrices );
|
||||
CvMat translation_vectors = cvMat( image_count, 3, CV_32FC1, _translation_vectors );
|
||||
|
||||
for( i = 0; i < image_count; i++ )
|
||||
total += _point_counts[i];
|
||||
|
||||
image_points = cvMat( total, 1, CV_32FC2, _image_points );
|
||||
object_points = cvMat( total, 1, CV_32FC3, _object_points );
|
||||
|
||||
cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size,
|
||||
&camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors,
|
||||
flags );
|
||||
}
|
||||
|
||||
|
||||
void cvCalibrateCamera_64d( int image_count, int* _point_counts,
|
||||
CvSize image_size, CvPoint2D64f* _image_points, CvPoint3D64f* _object_points,
|
||||
double* _distortion_coeffs, double* _camera_matrix, double* _translation_vectors,
|
||||
double* _rotation_matrices, int flags )
|
||||
{
|
||||
int i, total = 0;
|
||||
CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts );
|
||||
CvMat image_points, object_points;
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs );
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix );
|
||||
CvMat rotation_matrices = cvMat( image_count, 9, CV_64FC1, _rotation_matrices );
|
||||
CvMat translation_vectors = cvMat( image_count, 3, CV_64FC1, _translation_vectors );
|
||||
|
||||
for( i = 0; i < image_count; i++ )
|
||||
total += _point_counts[i];
|
||||
|
||||
image_points = cvMat( total, 1, CV_64FC2, _image_points );
|
||||
object_points = cvMat( total, 1, CV_64FC3, _object_points );
|
||||
|
||||
cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size,
|
||||
&camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors,
|
||||
flags );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Find 3d position of object given intrinsic camera parameters,
|
||||
3d model of the object and projection of the object into view plane */
|
||||
void cvFindExtrinsicCameraParams( int point_count,
|
||||
CvSize image_size, CvPoint2D32f* _image_points,
|
||||
CvPoint3D32f* _object_points, float* focal_length,
|
||||
CvPoint2D32f principal_point, float* _distortion_coeffs,
|
||||
float* _rotation_vector, float* _translation_vector )
|
||||
{
|
||||
CvMat image_points = cvMat( point_count, 1, CV_32FC2, _image_points );
|
||||
CvMat object_points = cvMat( point_count, 1, CV_32FC3, _object_points );
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs );
|
||||
float a[9];
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, a );
|
||||
CvMat rotation_vector = cvMat( 1, 1, CV_32FC3, _rotation_vector );
|
||||
CvMat translation_vector = cvMat( 1, 1, CV_32FC3, _translation_vector );
|
||||
|
||||
a[0] = focal_length[0]; a[4] = focal_length[1];
|
||||
a[2] = principal_point.x; a[5] = principal_point.y;
|
||||
a[1] = a[3] = a[6] = a[7] = 0.f;
|
||||
a[8] = 1.f;
|
||||
|
||||
cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix,
|
||||
&dist_coeffs, &rotation_vector, &translation_vector, 0 );
|
||||
}
|
||||
|
||||
|
||||
/* Variant of the previous function that takes double-precision parameters */
|
||||
void cvFindExtrinsicCameraParams_64d( int point_count,
|
||||
CvSize image_size, CvPoint2D64f* _image_points,
|
||||
CvPoint3D64f* _object_points, double* focal_length,
|
||||
CvPoint2D64f principal_point, double* _distortion_coeffs,
|
||||
double* _rotation_vector, double* _translation_vector )
|
||||
{
|
||||
CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points );
|
||||
CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points );
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs );
|
||||
double a[9];
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a );
|
||||
CvMat rotation_vector = cvMat( 1, 1, CV_64FC3, _rotation_vector );
|
||||
CvMat translation_vector = cvMat( 1, 1, CV_64FC3, _translation_vector );
|
||||
|
||||
a[0] = focal_length[0]; a[4] = focal_length[1];
|
||||
a[2] = principal_point.x; a[5] = principal_point.y;
|
||||
a[1] = a[3] = a[6] = a[7] = 0.;
|
||||
a[8] = 1.;
|
||||
|
||||
cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix,
|
||||
&dist_coeffs, &rotation_vector, &translation_vector, 0 );
|
||||
}
|
||||
|
||||
/* Converts rotation_matrix matrix to rotation_matrix vector or vice versa */
|
||||
void cvRodrigues( CvMat* rotation_matrix, CvMat* rotation_vector,
|
||||
CvMat* jacobian, int conv_type )
|
||||
{
|
||||
if( conv_type == CV_RODRIGUES_V2M )
|
||||
cvRodrigues2( rotation_vector, rotation_matrix, jacobian );
|
||||
else
|
||||
cvRodrigues2( rotation_matrix, rotation_vector, jacobian );
|
||||
}
|
||||
|
||||
|
||||
/* Does reprojection of 3d object points to the view plane */
|
||||
void cvProjectPoints( int point_count, CvPoint3D64f* _object_points,
|
||||
double* _rotation_vector, double* _translation_vector,
|
||||
double* focal_length, CvPoint2D64f principal_point,
|
||||
double* _distortion, CvPoint2D64f* _image_points,
|
||||
double* _deriv_points_rotation_matrix,
|
||||
double* _deriv_points_translation_vect,
|
||||
double* _deriv_points_focal,
|
||||
double* _deriv_points_principal_point,
|
||||
double* _deriv_points_distortion_coeffs )
|
||||
{
|
||||
CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points );
|
||||
CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points );
|
||||
CvMat rotation_vector = cvMat( 3, 1, CV_64FC1, _rotation_vector );
|
||||
CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector );
|
||||
double a[9];
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a );
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion );
|
||||
CvMat dpdr = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_rotation_matrix );
|
||||
CvMat dpdt = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_translation_vect );
|
||||
CvMat dpdf = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_focal );
|
||||
CvMat dpdc = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_principal_point );
|
||||
CvMat dpdk = cvMat( 2*point_count, 4, CV_64FC1, _deriv_points_distortion_coeffs );
|
||||
|
||||
a[0] = focal_length[0]; a[4] = focal_length[1];
|
||||
a[2] = principal_point.x; a[5] = principal_point.y;
|
||||
a[1] = a[3] = a[6] = a[7] = 0.;
|
||||
a[8] = 1.;
|
||||
|
||||
cvProjectPoints2( &object_points, &rotation_vector, &translation_vector,
|
||||
&camera_matrix, &dist_coeffs, &image_points,
|
||||
&dpdr, &dpdt, &dpdf, &dpdc, &dpdk, 0 );
|
||||
}
|
||||
|
||||
|
||||
/* Simpler version of the previous function */
|
||||
void cvProjectPointsSimple( int point_count, CvPoint3D64f* _object_points,
|
||||
double* _rotation_matrix, double* _translation_vector,
|
||||
double* _camera_matrix, double* _distortion, CvPoint2D64f* _image_points )
|
||||
{
|
||||
CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points );
|
||||
CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points );
|
||||
CvMat rotation_matrix = cvMat( 3, 3, CV_64FC1, _rotation_matrix );
|
||||
CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector );
|
||||
CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix );
|
||||
CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion );
|
||||
|
||||
cvProjectPoints2( &object_points, &rotation_matrix, &translation_vector,
|
||||
&camera_matrix, &dist_coeffs, &image_points,
|
||||
0, 0, 0, 0, 0, 0 );
|
||||
}
|
@ -50,8 +50,14 @@
|
||||
#endif
|
||||
|
||||
#include "opencv2/legacy/legacy.hpp"
|
||||
#include "opencv2/video/tracking.hpp"
|
||||
|
||||
#include "opencv2/core/internal.hpp"
|
||||
#include "opencv2/video/tracking.hpp"
|
||||
#include "opencv2/video/background_segm.hpp"
|
||||
|
||||
#include "opencv2/legacy/blobtrack.hpp"
|
||||
#include "opencv2/legacy/compat.hpp"
|
||||
|
||||
#include "_matrix.h"
|
||||
|
||||
typedef unsigned short ushort;
|
||||
|
@ -340,7 +340,6 @@ CVAPI(CvSeq*) cvSegmentFGMask( CvArr *fgmask, int poly1Hull0 CV_DEFAULT(1),
|
||||
CvMemStorage* storage CV_DEFAULT(0),
|
||||
CvPoint offset CV_DEFAULT(cvPoint(0,0)));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,20 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
void cvReleaseBGStatModel( CvBGStatModel** bg_model )
|
||||
{
|
||||
if( bg_model && *bg_model && (*bg_model)->release )
|
||||
(*bg_model)->release( bg_model );
|
||||
}
|
||||
|
||||
int cvUpdateBGStatModel( IplImage* current_frame,
|
||||
CvBGStatModel* bg_model,
|
||||
double learningRate )
|
||||
{
|
||||
return bg_model && bg_model->update ? bg_model->update( current_frame, bg_model, learningRate ) : 0;
|
||||
}
|
||||
|
||||
|
||||
// Function cvRefineForegroundMaskBySegm preforms FG post-processing based on segmentation
|
||||
// (all pixels of the segment will be classified as FG if majority of pixels of the region are FG).
|
||||
// parameters:
|
||||
|
@ -52,7 +52,6 @@
|
||||
#endif
|
||||
|
||||
#include "opencv2/video/tracking.hpp"
|
||||
#include "opencv2/video/blobtrack.hpp"
|
||||
#include "opencv2/video/background_segm.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user