cvaux.h.svn-base
来自「非结构化路识别」· SVN-BASE 代码 · 共 1,161 行 · 第 1/4 页
SVN-BASE
1,161 行
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __CVAUX__H__
#define __CVAUX__H__
#include <cv.h>
#if defined WIN32 && defined CVAUX_DLL
#define CVAUX_DLL_ENTRY __declspec(dllexport)
#else
#define CVAUX_DLL_ENTRY
#endif
#ifndef OPENCVAUXAPI
#define OPENCVAUXAPI CV_EXTERN_C CVAUX_DLL_ENTRY
#endif
OPENCVAUXAPI CvSeq* cvSegmentImage( const CvArr* srcarr, CvArr* dstarr,
double canny_threshold,
double ffill_threshold,
CvMemStorage* storage );
/****************************************************************************************\
* 1D HMM experimental *
\****************************************************************************************/
typedef CvImgObsInfo Cv1DObsInfo;
OPENCVAUXAPI CvStatus icvCreate1DHMM( CvEHMM** this_hmm,
int state_number, int* num_mix, int obs_size );
OPENCVAUXAPI CvStatus icvRelease1DHMM( CvEHMM** phmm );
OPENCVAUXAPI CvStatus icvUniform1DSegm( Cv1DObsInfo* obs_info, CvEHMM* hmm );
OPENCVAUXAPI CvStatus icvInit1DMixSegm( Cv1DObsInfo** obs_info_array, int num_img, CvEHMM* hmm);
OPENCVAUXAPI CvStatus icvEstimate1DHMMStateParams( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm);
OPENCVAUXAPI CvStatus icvEstimate1DObsProb( CvImgObsInfo* obs_info, CvEHMM* hmm );
OPENCVAUXAPI CvStatus icvEstimate1DTransProb( Cv1DObsInfo** obs_info_array,
int num_seq,
CvEHMM* hmm );
OPENCVAUXAPI float icvViterbi( Cv1DObsInfo* obs_info, CvEHMM* hmm);
OPENCVAUXAPI CvStatus icv1DMixSegmL2( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm );
/****************************************************************************************\
* Additional operations on Subdivisions *
\****************************************************************************************/
// paints voronoi diagram: just demo function
OPENCVAUXAPI void icvDrawMosaic( CvSubdiv2D* subdiv, IplImage* src, IplImage* dst );
// checks planar subdivision for correctness. It is not an absolute check,
// but it verifies some relations between quad-edges
OPENCVAUXAPI int icvSubdiv2DCheck( CvSubdiv2D* subdiv );
// returns squared distance between two 2D points with floating-point coordinates.
CV_INLINE double icvSqDist2D32f( CvPoint2D32f pt1, CvPoint2D32f pt2 )
{
double dx = pt1.x - pt2.x;
double dy = pt1.y - pt2.y;
return dx*dx + dy*dy;
}
/****************************************************************************************\
* More operations on sequences *
\****************************************************************************************/
/*****************************************************************************************/
#define CV_CURRENT_INT( reader ) (*((int *)(reader).ptr))
#define CV_PREV_INT( reader ) (*((int *)(reader).prev_elem))
#define CV_GRAPH_WEIGHTED_VERTEX_FIELDS() CV_GRAPH_VERTEX_FIELDS()\
float weight;
#define CV_GRAPH_WEIGHTED_EDGE_FIELDS() CV_GRAPH_EDGE_FIELDS()
typedef struct CvGraphWeightedVtx
{
CV_GRAPH_WEIGHTED_VERTEX_FIELDS()
}
CvGraphWeightedVtx;
typedef struct CvGraphWeightedEdge
{
CV_GRAPH_WEIGHTED_EDGE_FIELDS()
}
CvGraphWeightedEdge;
typedef enum CvGraphWeightType
{
CV_NOT_WEIGHTED,
CV_WEIGHTED_VTX,
CV_WEIGHTED_EDGE,
CV_WEIGHTED_ALL
} CvGraphWeightType;
/*****************************************************************************************/
///////////////////////////////////////////////////////////
// Triangulation
OPENCVAUXAPI void cvDecompPoly( CvContour* cont, CvSubdiv2D** subdiv, CvMemStorage* storage );
///////////////////////////////////////////////////////////
/*******************************Stereo correspondence*************************************/
OPENCVAUXAPI void icvDrawFilledSegments( CvSeq* seq, IplImage* img, int part );
OPENCVAUXAPI CvSeq* cvExtractSingleEdges( IplImage* image, //bw image
CvMemStorage* storage );
typedef struct CvCliqueFinder
{
CvGraph* graph;
int** adj_matr;
int N; //graph size
// stacks, counters etc/
int k; //stack size
int* current_comp;
int** All;
int* ne;
int* ce;
int* fixp; //node with minimal disconnections
int* nod;
int* s; //for selected candidate
int status;
int best_score;
int weighted;
int weighted_edges;
float best_weight;
float* edge_weights;
float* vertex_weights;
float* cur_weight;
float* cand_weight;
} CvCliqueFinder;
#define CLIQUE_TIME_OFF 2
#define CLIQUE_FOUND 1
#define CLIQUE_END 0
OPENCVAUXAPI void cvStartFindCliques( CvGraph* graph, CvCliqueFinder* finder, int reverse,
int weighted CV_DEFAULT(0), int weighted_edges CV_DEFAULT(0));
OPENCVAUXAPI int cvFindNextMaximalClique( CvCliqueFinder* finder, int* clock_rest CV_DEFAULT(0) );
OPENCVAUXAPI void cvEndFindCliques( CvCliqueFinder* finder );
OPENCVAUXAPI void cvBronKerbosch( CvGraph* graph );
/*F///////////////////////////////////////////////////////////////////////////////////////
//
// Name: cvSubgraphWeight
// Purpose: finds weight of subgraph in a graph
// Context:
// Parameters:
// graph - input graph.
// subgraph - sequence of pairwise different ints. These are indices of vertices of subgraph.
// weight_type - describes the way we measure weight.
// one of the following:
// CV_NOT_WEIGHTED - weight of a clique is simply its size
// CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices
// CV_WEIGHTED_EDGE - the same but edges
// CV_WEIGHTED_ALL - the same but both edges and vertices
// weight_vtx - optional vector of floats, with size = graph->total.
// If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL
// weights of vertices must be provided. If weight_vtx not zero
// these weights considered to be here, otherwise function assumes
// that vertices of graph are inherited from CvGraphWeightedVtx.
// weight_edge - optional matrix of floats, of width and height = graph->total.
// If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL
// weights of edges ought to be supplied. If weight_edge is not zero
// function finds them here, otherwise function expects
// edges of graph to be inherited from CvGraphWeightedEdge.
// If this parameter is not zero structure of the graph is determined from matrix
// rather than from CvGraphEdge's. In particular, elements corresponding to
// absent edges should be zero.
// Returns:
// weight of subgraph.
// Notes:
//F*/
OPENCVAUXAPI float cvSubgraphWeight( CvGraph *graph, CvSeq *subgraph,
CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED),
CvVect32f weight_vtx CV_DEFAULT(0),
CvMatr32f weight_edge CV_DEFAULT(0) );
/*F///////////////////////////////////////////////////////////////////////////////////////
//
// Name: cvFindCliqueEx
// Purpose: tries to find clique with maximum possible weight in a graph
// Context:
// Parameters:
// graph - input graph.
// storage - memory storage to be used by the result.
// is_complementary - optional flag showing whether function should seek for clique
// in complementary graph.
// weight_type - describes our notion about weight.
// one of the following:
// CV_NOT_WEIGHTED - weight of a clique is simply its size
// CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices
// CV_WEIGHTED_EDGE - the same but edges
// CV_WEIGHTED_ALL - the same but both edges and vertices
// weight_vtx - optional vector of floats, with size = graph->total.
// If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL
// weights of vertices must be provided. If weight_vtx not zero
// these weights considered to be here, otherwise function assumes
// that vertices of graph are inherited from CvGraphWeightedVtx.
// weight_edge - optional matrix of floats, of width and height = graph->total.
// If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL
// weights of edges ought to be supplied. If weight_edge is not zero
// function finds them here, otherwise function expects
// edges of graph to be inherited from CvGraphWeightedEdge.
// Note that in case of CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL
// nonzero is_complementary implies nonzero weight_edge.
// start_clique - optional sequence of pairwise different ints. They are indices of
// vertices that shall be present in the output clique.
// subgraph_of_ban - optional sequence of (maybe equal) ints. They are indices of
// vertices that shall not be present in the output clique.
// clique_weight_ptr - optional output parameter. Weight of found clique stored here.
// num_generations - optional number of generations in evolutionary part of algorithm,
// zero forces to return first found clique.
// quality - optional parameter determining degree of required quality/speed tradeoff.
// Must be in the range from 0 to 9.
// 0 is fast and dirty, 9 is slow but hopefully yields good clique.
// Returns:
// sequence of pairwise different ints.
// These are indices of vertices that form found clique.
// Notes:
// in cases of CV_WEIGHTED_EDGE and CV_WEIGHTED_ALL weights should be nonnegative.
// start_clique has a priority over subgraph_of_ban.
//F*/
OPENCVAUXAPI CvSeq *cvFindCliqueEx( CvGraph *graph, CvMemStorage *storage,
int is_complementary CV_DEFAULT(0),
CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED),
CvVect32f weight_vtx CV_DEFAULT(0),
CvMatr32f weight_edge CV_DEFAULT(0),
CvSeq *start_clique CV_DEFAULT(0),
CvSeq *subgraph_of_ban CV_DEFAULT(0),
float *clique_weight_ptr CV_DEFAULT(0),
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?