Compare commits

3 Commits

Author SHA1 Message Date
yanshui177
e9f18bbc9b 文件夹监控wei服务
伪服务
2017-05-17 20:50:34 +08:00
yanshui177
6dcd378738 完善目录结构
完善了目录结构,添加了以前的web段com组件调用的代码(在/测试目录下)(部署没有使用到)
2017-05-17 20:43:16 +08:00
yanshui177
ad754709a5 依赖库
添加了鉴别主程序所需的依赖库
ps:虽然使用opencv,但是使用的函数都是opencv100的函数
2017-05-17 20:00:13 +08:00
1258 changed files with 671390 additions and 420 deletions

View File

@@ -0,0 +1,163 @@
/*
实现文件DBop.cpp 数据库操作实现文件
*/
#include "DBop.h"
#include "path.h"
/*本地的全局变量*/
_ConnectionPtr p_conn; /*全局变量 连接对象*/
_RecordsetPtr p_recordset; /*全局变量 记录集对象*/
_CommandPtr p_cmd; /*全局变量 操作集对象*/
string str_conn; /*全局变量 连接字符串设置*/
/**
程序功能: 根据string类的stu【存储学号】搜索出所有此人的考试信息,并分别存储在不同的变量中
@变量 stuNum 学号
@变量 date<vector> 考试时间
@变量 subject<vector> 考试科目
@变量 stuNum<vector> 考号
@返回值 成功1 失败0
*/
int DbImg(string stuNum, vector<string>& dateVec, vector<string>& subjectVec, vector<string>& stuNum2)//搜寻图片
{
/*字符转换,方便使用*/
string userName(g_db_userName.c_str());
string password(g_db_password.c_str());
string hostName(g_db_hostName.c_str());
string dBName(g_db_dBName.c_str());
/*创建链接描述符*/
str_conn = "Provider=OraOLEDB.Oracle.1;Persist Security Info = true;User ID = ";
str_conn += userName; //===仅初始化一次===//
str_conn += ";Password="; //==================//
str_conn += password;
str_conn += ";Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=";
str_conn += hostName;
str_conn += ")(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=";
str_conn += dBName;
str_conn += ")))";
//构造查询语句 下句注释是sql语句需要构造成这种类型
/*select KS_ZKZ, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201510' and KS_ZKZ = 010207203867*/
/*string sql = "select KS_ZKZ2, KSSJ, TJ_KC_DM from ZK.T_BYSQ_KS_KC WHERE KSSJ between '200907' and '201504' AND KS_ZKZ = ";*/
string sql = "select KS_ZKZ2, KSSJ, TJ_KC_DM from ";
sql += g_db_hoster_zk;
sql += ".T_BYSQ_KS_KC WHERE KSSJ between ";
sql += g_db_qurry_start;
sql += " and ";
sql += g_db_qurry_end;
sql += "AND KS_ZKZ =";
sql += stuNum.c_str();
_bstr_t _vstr_sql(sql.c_str());/* 转换string为_variant_t */
::CoInitialize(NULL);//初始化com组件
/*创建、打开连接*/
try{
p_conn.CreateInstance("ADODB.Connection");//创建连接
p_recordset.CreateInstance("ADODB.Recordset");//创建结果集,也就是实例化
p_conn->CursorLocation = adUseClient; //存储过程同时返回记录集和返回值
p_conn->Open(_bstr_t(str_conn.c_str()), _bstr_t(userName.c_str()), _bstr_t(password.c_str()), adConnectUnspecified);
HRESULT hr = p_recordset->Open(_bstr_t(_vstr_sql),//执行sq语句查询一个学生的所有考试信息
p_conn.GetInterfacePtr(),
adOpenStatic,
adLockOptimistic,
adCmdText);
//将结果集输出到三个vector变量中
if (p_recordset->RecordCount < 1)//结果集为空
{
return 0;//没有信息,直接跳过这个人
}
do{ //将结果集输出到三个vector变量中
dateVec.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KSSJ"))->GetValue()));
subjectVec.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("TJ_KC_DM"))->GetValue()));
stuNum2.push_back((string)(_bstr_t)(p_recordset->Fields->GetItem(_variant_t("KS_ZKZ2"))->GetValue()));
p_recordset->MoveNext();
} while (!p_recordset->EndOfFile);
}
catch (_com_error e){/**/}
/*关闭查询*/
::CoUninitialize();
return 0;
}
/**
程序功能: 更新学生数据库信息,根据学生的鉴定结果,将结果输出到数据库中
@变量 stuNum学号
@变量 subject考试科目
@变量 flagCheat作弊标记
@返回值 成功1失败0
*/
int DbUpdate(string stuNum, vector<string> dateVec, vector<string> subjectVec, vector<string> stuNum2, vector<string> flagVec)
{
/*字符转换,方便使用*/
string userName(g_db_userName.c_str());
string password(g_db_password.c_str());
string hostName(g_db_hostName.c_str());
string dBName(g_db_dBName.c_str());
/*更新字串设置*/
int count = subjectVec.size();
vector<string> sqlKC; //课程表:作弊第一字段
int ci = 0; //循环
/*构造更新语句*/
for (ci = 0; ci < count; ++ci)
{
/*作弊的*/
string sqlKC1 = "UPDATE ";
sqlKC1 += g_db_hoster_zk;
sqlKC1 += ".T_BYSQ_KS_KC SET BJSH_JG_JQ =";//天津_课程_代码
sqlKC1 += flagVec[ci].c_str();
sqlKC1 += " WHERE KS_ZKZ2=";
sqlKC1 += stuNum2[ci].c_str();
sqlKC1 += " AND TJ_KC_DM=";
sqlKC1 += subjectVec[ci].c_str();
sqlKC1 += " AND KSSJ=";
sqlKC1 += dateVec[ci].c_str();
sqlKC1 += " AND KS_ZKZ=";
sqlKC1 += stuNum.c_str();
sqlKC.push_back(sqlKC1);
}
::CoInitialize(NULL);//初始化com组件
/*更新数据库表*/
try{
p_conn.CreateInstance("ADODB.Connection");//创建连接
p_recordset.CreateInstance("ADODB.Recordset");//创建结果集,也就是实例化
p_cmd.CreateInstance("ADODB.Command");
p_conn->CursorLocation = adUseClient; //存储过程同时返回记录集和返回值
p_conn->Open(_bstr_t(str_conn.c_str()), _bstr_t(userName.c_str()), _bstr_t(password.c_str()), adConnectUnspecified);
p_cmd->ActiveConnection = p_conn;
for (ci = 0; ci < count; ++ci)
{
p_recordset->Open(_bstr_t(sqlKC[ci].c_str()),//更新第二条
p_conn.GetInterfacePtr(),
adOpenStatic,
adLockOptimistic,
adCmdText);
}
}
catch (_com_error e){}
/*关闭查询*/
::CoUninitialize();
return 1;
}

View File

@@ -0,0 +1,55 @@
/*
头文件DBop.h 数据库操作头文件
*/
#pragma once
#import "msado15.dll" no_namespace rename("EOF","EndOfFile")
#include <vector>
#include <string>
#include <iostream>
#include <windows.h>
#include <iomanip>
#include <stdio.h>
using namespace std;
/*全局变量*/
extern char *g_log_adr; /*全局变量 程序日志存储地址*/
extern char g_log_rec[500]; /*全局变量 程序日志专用变量*/
extern FILE *g_log_fpzz; /*全局变量 程序日志专用文件句柄*/
extern string g_db_hostName; /*全局变量 服务器ip或名称*/
extern string g_db_dBName; /*全局变量 服务器ODBC数据源*/
extern string g_db_userName; /*全局变量 服务器用户名*/
extern string g_db_password; /*全局变量 服务器密码*/
extern string g_db_qurry_start; /*全局变量 数据库查询_开始日期*/
extern string g_db_qurry_end; /*全局变量 数据库查询_结束日期*/
extern string g_db_qurry_zone; /*全局变量 数据库查询_特定区域*/
extern string g_db_qurry_stu_num; /*全局变量 数据库查询_特定考号*/
extern bool g_db_qurry_all; /*全局变量 数据库查询_查询全部标记*/
extern string g_db_hoster_zk; /*全局变量 数据库用户zk考试院的zk本地的yannsy*/
/*****************************************函数原型*************************************/
/**
程序功能: 根据string类的stu【存储学号】搜索出所有此人的考试信息,并分别存储在不同的变量中
@变量 stuNum 学号
@变量 date<vector> 考试时间
@变量 subject<vector> 考试科目
@变量 stuNum<vector> 考号
@返回值 成功1 失败0
*/
int DbImg(string stuNum, vector<string>& dateVec, vector<string>& subjectVec, vector<string>& stuNum2);
/**
程序功能: 更新学生数据库信息,根据学生的鉴定结果,将结果输出到数据库中
@变量 stuNum学号
@变量 subject考试科目
@变量 flagCheat作弊标记
@返回值 成功1失败0
*/
int DbUpdate(string stuNum, vector<string> dateVec, vector<string> subjectVec, vector<string> stuNum2, vector<string> flagVec);

View File

@@ -0,0 +1,14 @@
/*
动态链接库定义文件HWCV.cpp 动态链接库的入口等定义文件
*/
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

View File

@@ -0,0 +1,3 @@
LIBRARY "HWCV"
EXPORTS HWCV
EXPORTS TEST

View File

@@ -0,0 +1,148 @@
# Microsoft Developer Studio Project File - Name="HWCV" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=HWCV - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "HWCV.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "HWCV.mak" CFG="HWCV - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "HWCV - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "HWCV - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "HWCV - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HWCV_EXPORTS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /G4 /Gz /Zp4 /MD /W3 /GX /O2 /I "OpenCV\cv\include" /I "OpenCV\otherlibs\highgui" /I "OpenCV\cxcore\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HWCV_EXPORTS" /U "OpenCV\\lib" /FR /FD /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "NDEBUG"
# ADD RSC /l 0x804 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 FreeImage.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib /nologo /dll /machine:I386
!ELSEIF "$(CFG)" == "HWCV - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HWCV_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HWCV_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "_DEBUG"
# ADD RSC /l 0x804 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib FreeImage.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "HWCV - Win32 Release"
# Name "HWCV - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\DBop.cpp
# End Source File
# Begin Source File
SOURCE=.\HWCV.CPP
# End Source File
# Begin Source File
SOURCE=.\path.cpp
# End Source File
# Begin Source File
SOURCE=.\segmentation.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\DBop.h
# End Source File
# Begin Source File
SOURCE=.\HWCV.def
# End Source File
# Begin Source File
SOURCE=.\path.h
# End Source File
# Begin Source File
SOURCE=.\segmentation.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "HWCV"=".\HWCV.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,32 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: HWCV - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\Users\ãÆË§Ë§\AppData\Local\Temp\RSPEA13.tmp" with contents
[
FreeImage.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib /nologo /dll /incremental:no /pdb:"Release/HWCV.pdb" /machine:I386 /def:".\HWCV.def" /out:"Release/HWCV.dll" /implib:"Release/HWCV.lib"
".\Release\DBop.obj"
".\Release\HWCV.OBJ"
".\Release\path.obj"
".\Release\segmentation.obj"
".\Release\StdAfx.obj"
]
Creating command line "link.exe @"C:\Users\ãÆË§Ë§\AppData\Local\Temp\RSPEA13.tmp""
<h3>Output Window</h3>
Linking...
Creating library Release/HWCV.lib and object Release/HWCV.exp
Creating command line "bscmake.exe /nologo /o"Release/HWCV.bsc" ".\Release\DBop.sbr" ".\Release\HWCV.SBR" ".\Release\path.sbr" ".\Release\segmentation.sbr" ".\Release\StdAfx.sbr""
Creating browse info file...
<h3>Output Window</h3>
<h3>Results</h3>
HWCV.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<SccProjectName />
<SccLocalPath />
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>.\Debug\</OutDir>
<IntDir>.\Debug\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>.\Release\</OutDir>
<IntDir>.\Release\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<FunctionLevelLinking>false</FunctionLevelLinking>
<Optimization>Disabled</Optimization>
<SuppressStartupBanner>true</SuppressStartupBanner>
<WarningLevel>Level3</WarningLevel>
<MinimalRebuild>true</MinimalRebuild>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;HWCV_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>.\Debug\</AssemblerListingLocation>
<PrecompiledHeaderOutputFile>.\Debug\HWCV.pch</PrecompiledHeaderOutputFile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<ObjectFileName>.\Debug\</ObjectFileName>
<ProgramDataBaseFileName>.\Debug\</ProgramDataBaseFileName>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
</ClCompile>
<Midl>
<SuppressStartupBanner>true</SuppressStartupBanner>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>.\Debug\HWCV.tlb</TypeLibraryName>
<MkTypLibCompatible>true</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Debug\HWCV.bsc</OutputFile>
</Bscmake>
<Link>
<SuppressStartupBanner>true</SuppressStartupBanner>
<LinkDLL>true</LinkDLL>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OutputFile>.\Debug\HWCV.dll</OutputFile>
<ImportLibrary>.\Debug\HWCV.lib</ImportLibrary>
<AdditionalDependencies>odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>.\HWCV.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<Optimization>MaxSpeed</Optimization>
<SuppressStartupBanner>true</SuppressStartupBanner>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>OpenCV\cv\include;OpenCV\otherlibs\highgui;OpenCV\cxcore\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;HWCV_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UndefinePreprocessorDefinitions>OpenCV\\lib;%(UndefinePreprocessorDefinitions)</UndefinePreprocessorDefinitions>
<AssemblerListingLocation>.\Release\</AssemblerListingLocation>
<BrowseInformation>true</BrowseInformation>
<PrecompiledHeaderOutputFile>.\Release\HWCV.pch</PrecompiledHeaderOutputFile>
<PrecompiledHeader>
</PrecompiledHeader>
<ObjectFileName>.\Release\</ObjectFileName>
<ProgramDataBaseFileName>.\Release\</ProgramDataBaseFileName>
<CallingConvention>StdCall</CallingConvention>
<StructMemberAlignment>4Bytes</StructMemberAlignment>
</ClCompile>
<Midl>
<SuppressStartupBanner>true</SuppressStartupBanner>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>.\Release\HWCV.tlb</TypeLibraryName>
<MkTypLibCompatible>true</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Release\HWCV.bsc</OutputFile>
</Bscmake>
<Link>
<SuppressStartupBanner>true</SuppressStartupBanner>
<LinkDLL>true</LinkDLL>
<SubSystem>Console</SubSystem>
<OutputFile>.\Release\HWCV.dll</OutputFile>
<ImportLibrary>.\Release\HWCV.lib</ImportLibrary>
<AdditionalDependencies>FreeImage.lib;cxcore.lib;cv.lib;ml.lib;cvaux.lib;highgui.lib;cvcam.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>.\HWCV.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="binary.cpp" />
<ClCompile Include="Cjbsb.cpp" />
<ClCompile Include="Cword.cpp" />
<ClCompile Include="getFiles.cpp" />
<ClCompile Include="getFloders.cpp" />
<ClCompile Include="getType.cpp" />
<ClCompile Include="gif2ipl.cpp" />
<ClCompile Include="outline.cpp" />
<ClCompile Include="outlinefeature.cpp" />
<ClCompile Include="read_scanf.cpp" />
<ClCompile Include="segmentation.cpp" />
<ClCompile Include="singlefeature.cpp" />
<ClCompile Include="Thinner.cpp" />
<ClCompile Include="worddivide.cpp" />
<ClCompile Include="wordrecognize.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Cword.h" />
<ClInclude Include="FreeImage.h" />
<ClInclude Include="Point.h" />
<ClInclude Include="Thinner.h" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="HWCV.def" />
<CustomBuild Include="ReadMe.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{5132bb21-0ec3-411b-8a1b-91890205e9e8}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{0146cd25-bd07-4b86-90b5-8a28a4b87af1}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{7d418a22-acbe-42ad-9b5f-bba6e2b4b2be}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="binary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Cjbsb.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Cword.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="getFiles.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="getFloders.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="getType.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="gif2ipl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="outline.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="outlinefeature.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="read_scanf.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="segmentation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="singlefeature.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Thinner.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="worddivide.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wordrecognize.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Cword.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FreeImage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Point.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Thinner.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="HWCV.def">
<Filter>Header Files</Filter>
</CustomBuild>
<CustomBuild Include="ReadMe.txt" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,538 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = cv
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/autotools/aclocal/az_python.m4 \
$(top_srcdir)/autotools/aclocal/pkg.m4 \
$(top_srcdir)/autotools/aclocal/swig_complete.m4 \
$(top_srcdir)/autotools/aclocal/version_at_least.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/autotools/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/cvconfig.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_APPS_FALSE = @BUILD_APPS_FALSE@
BUILD_APPS_TRUE = @BUILD_APPS_TRUE@
BUILD_CARBON_FALSE = @BUILD_CARBON_FALSE@
BUILD_CARBON_TRUE = @BUILD_CARBON_TRUE@
BUILD_DC1394_FALSE = @BUILD_DC1394_FALSE@
BUILD_DC1394_TRUE = @BUILD_DC1394_TRUE@
BUILD_FFMPEG_FALSE = @BUILD_FFMPEG_FALSE@
BUILD_FFMPEG_TRUE = @BUILD_FFMPEG_TRUE@
BUILD_GTK_FALSE = @BUILD_GTK_FALSE@
BUILD_GTK_TRUE = @BUILD_GTK_TRUE@
BUILD_PYTHON_WRAPPERS_FALSE = @BUILD_PYTHON_WRAPPERS_FALSE@
BUILD_PYTHON_WRAPPERS_TRUE = @BUILD_PYTHON_WRAPPERS_TRUE@
BUILD_QUICKTIME_FALSE = @BUILD_QUICKTIME_FALSE@
BUILD_QUICKTIME_TRUE = @BUILD_QUICKTIME_TRUE@
BUILD_V4L_FALSE = @BUILD_V4L_FALSE@
BUILD_V4L_TRUE = @BUILD_V4L_TRUE@
BUILD_XINE_FALSE = @BUILD_XINE_FALSE@
BUILD_XINE_TRUE = @BUILD_XINE_TRUE@
CARBON_CFLAGS = @CARBON_CFLAGS@
CARBON_LIBS = @CARBON_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEBUG = @DEBUG@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
FFMPEGLIBS = @FFMPEGLIBS@
GREP = @GREP@
GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
GTHREAD_LIBS = @GTHREAD_LIBS@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_LIBS = @GTK_LIBS@
IEEE1394LIBS = @IEEE1394LIBS@
IMAGELIBS = @IMAGELIBS@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_VERSION = @LT_VERSION@
MAKEINFO = @MAKEINFO@
MMAJOR = @MMAJOR@
MMINOR = @MMINOR@
MSUBMINOR = @MSUBMINOR@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PYTHON = @PYTHON@
PYTHON_CSPEC = @PYTHON_CSPEC@
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
PYTHON_LSPEC = @PYTHON_LSPEC@
PYTHON_PLATFORM = @PYTHON_PLATFORM@
PYTHON_PREFIX = @PYTHON_PREFIX@
PYTHON_VERSION = @PYTHON_VERSION@
QUICKTIME_CFLAGS = @QUICKTIME_CFLAGS@
QUICKTIME_LIBS = @QUICKTIME_LIBS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
SWIG = @SWIG@
SWIG_PYTHON_LIBS = @SWIG_PYTHON_LIBS@
SWIG_PYTHON_OPT = @SWIG_PYTHON_OPT@
SWIG_RUNTIME_LIBS_DIR = @SWIG_RUNTIME_LIBS_DIR@
SWIG_VERSION = @SWIG_VERSION@
UPDATE_SWIG_WRAPPERS_FALSE = @UPDATE_SWIG_WRAPPERS_FALSE@
UPDATE_SWIG_WRAPPERS_TRUE = @UPDATE_SWIG_WRAPPERS_TRUE@
VERSION = @VERSION@
XINE_LIBS = @XINE_LIBS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgpyexecdir = @pkgpyexecdir@
pkgpythondir = @pkgpythondir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
pyexecdir = @pyexecdir@
pythondir = @pythondir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
SUBDIRS = src include
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cv/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu cv/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(mkdir_p) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-libtool clean-recursive ctags \
ctags-recursive distclean distclean-generic distclean-libtool \
distclean-recursive distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-generic mostlyclean-libtool \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,7 @@
EXTRA_DIST = cvstreams.h
# The directory where the include files will be installed
libcvincludedir = $(includedir)/opencv
# Which header files to install
libcvinclude_HEADERS = cv.h cvcompat.h cvtypes.h cv.hpp

View File

@@ -0,0 +1,465 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = cv/include
DIST_COMMON = $(libcvinclude_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/autotools/aclocal/az_python.m4 \
$(top_srcdir)/autotools/aclocal/pkg.m4 \
$(top_srcdir)/autotools/aclocal/swig_complete.m4 \
$(top_srcdir)/autotools/aclocal/version_at_least.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/autotools/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/cvconfig.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libcvincludedir)"
libcvincludeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(libcvinclude_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_APPS_FALSE = @BUILD_APPS_FALSE@
BUILD_APPS_TRUE = @BUILD_APPS_TRUE@
BUILD_CARBON_FALSE = @BUILD_CARBON_FALSE@
BUILD_CARBON_TRUE = @BUILD_CARBON_TRUE@
BUILD_DC1394_FALSE = @BUILD_DC1394_FALSE@
BUILD_DC1394_TRUE = @BUILD_DC1394_TRUE@
BUILD_FFMPEG_FALSE = @BUILD_FFMPEG_FALSE@
BUILD_FFMPEG_TRUE = @BUILD_FFMPEG_TRUE@
BUILD_GTK_FALSE = @BUILD_GTK_FALSE@
BUILD_GTK_TRUE = @BUILD_GTK_TRUE@
BUILD_PYTHON_WRAPPERS_FALSE = @BUILD_PYTHON_WRAPPERS_FALSE@
BUILD_PYTHON_WRAPPERS_TRUE = @BUILD_PYTHON_WRAPPERS_TRUE@
BUILD_QUICKTIME_FALSE = @BUILD_QUICKTIME_FALSE@
BUILD_QUICKTIME_TRUE = @BUILD_QUICKTIME_TRUE@
BUILD_V4L_FALSE = @BUILD_V4L_FALSE@
BUILD_V4L_TRUE = @BUILD_V4L_TRUE@
BUILD_XINE_FALSE = @BUILD_XINE_FALSE@
BUILD_XINE_TRUE = @BUILD_XINE_TRUE@
CARBON_CFLAGS = @CARBON_CFLAGS@
CARBON_LIBS = @CARBON_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEBUG = @DEBUG@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
FFMPEGLIBS = @FFMPEGLIBS@
GREP = @GREP@
GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
GTHREAD_LIBS = @GTHREAD_LIBS@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_LIBS = @GTK_LIBS@
IEEE1394LIBS = @IEEE1394LIBS@
IMAGELIBS = @IMAGELIBS@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_VERSION = @LT_VERSION@
MAKEINFO = @MAKEINFO@
MMAJOR = @MMAJOR@
MMINOR = @MMINOR@
MSUBMINOR = @MSUBMINOR@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PYTHON = @PYTHON@
PYTHON_CSPEC = @PYTHON_CSPEC@
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
PYTHON_LSPEC = @PYTHON_LSPEC@
PYTHON_PLATFORM = @PYTHON_PLATFORM@
PYTHON_PREFIX = @PYTHON_PREFIX@
PYTHON_VERSION = @PYTHON_VERSION@
QUICKTIME_CFLAGS = @QUICKTIME_CFLAGS@
QUICKTIME_LIBS = @QUICKTIME_LIBS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
SWIG = @SWIG@
SWIG_PYTHON_LIBS = @SWIG_PYTHON_LIBS@
SWIG_PYTHON_OPT = @SWIG_PYTHON_OPT@
SWIG_RUNTIME_LIBS_DIR = @SWIG_RUNTIME_LIBS_DIR@
SWIG_VERSION = @SWIG_VERSION@
UPDATE_SWIG_WRAPPERS_FALSE = @UPDATE_SWIG_WRAPPERS_FALSE@
UPDATE_SWIG_WRAPPERS_TRUE = @UPDATE_SWIG_WRAPPERS_TRUE@
VERSION = @VERSION@
XINE_LIBS = @XINE_LIBS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgpyexecdir = @pkgpyexecdir@
pkgpythondir = @pkgpythondir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
pyexecdir = @pyexecdir@
pythondir = @pythondir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
EXTRA_DIST = cvstreams.h
# The directory where the include files will be installed
libcvincludedir = $(includedir)/opencv
# Which header files to install
libcvinclude_HEADERS = cv.h cvcompat.h cvtypes.h cv.hpp
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cv/include/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu cv/include/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-libcvincludeHEADERS: $(libcvinclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(libcvincludedir)" || $(mkdir_p) "$(DESTDIR)$(libcvincludedir)"
@list='$(libcvinclude_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(libcvincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(libcvincludedir)/$$f'"; \
$(libcvincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(libcvincludedir)/$$f"; \
done
uninstall-libcvincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(libcvinclude_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(libcvincludedir)/$$f'"; \
rm -f "$(DESTDIR)$(libcvincludedir)/$$f"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(libcvincludedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-libcvincludeHEADERS
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libcvincludeHEADERS
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool ctags distclean distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-libcvincludeHEADERS install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libcvincludeHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,372 @@
/*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 _CV_HPP_
#define _CV_HPP_
#ifdef __cplusplus
/****************************************************************************************\
* CvBaseImageFilter: Base class for filtering operations *
\****************************************************************************************/
#define CV_WHOLE 0
#define CV_START 1
#define CV_END 2
#define CV_MIDDLE 4
#define CV_ISOLATED_ROI 8
typedef void (*CvRowFilterFunc)( const uchar* src, uchar* dst, void* params );
typedef void (*CvColumnFilterFunc)( uchar** src, uchar* dst, int dst_step, int count, void* params );
class CV_EXPORTS CvBaseImageFilter
{
public:
CvBaseImageFilter();
/* calls init() */
CvBaseImageFilter( int _max_width, int _src_type, int _dst_type,
bool _is_separable, CvSize _ksize,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual ~CvBaseImageFilter();
/* initializes the class for processing an image of maximal width _max_width,
input image has data type _src_type, the output will have _dst_type.
_is_separable != 0 if the filter is separable
(specific behaviour is defined in a derived class), 0 otherwise.
_ksize and _anchor specify the kernel size and the anchor point. _anchor=(-1,-1) means
that the anchor is at the center.
to get interpolate pixel values outside the image _border_mode=IPL_BORDER_*** is used,
_border_value specify the pixel value in case of IPL_BORDER_CONSTANT border mode.
before initialization clear() is called if necessary.
*/
virtual void init( int _max_width, int _src_type, int _dst_type,
bool _is_separable, CvSize _ksize,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
/* releases all the internal buffers.
for the further use of the object, init() needs to be called. */
virtual void clear();
/* processes input image or a part of it.
input is represented either as matrix (CvMat* src)
or a list of row pointers (uchar** src2).
in the later case width, _src_y1 and _src_y2 are used to specify the size.
_dst is the output image/matrix.
_src_roi specifies the roi inside the input image to process,
(0,0,-1,-1) denotes the whole image.
_dst_origin is the upper-left corner of the filtered roi within the output image.
_phase is either CV_START, or CV_END, or CV_MIDDLE, or CV_START|CV_END, or CV_WHOLE,
which is the same as CV_START|CV_END.
CV_START means that the input is the first (top) stripe of the processed image [roi],
CV_END - the input is the last (bottom) stripe of the processed image [roi],
CV_MIDDLE - the input is neither first nor last stripe.
CV_WHOLE - the input is the whole processed image [roi].
*/
virtual int process( const CvMat* _src, CvMat* _dst,
CvRect _src_roi=cvRect(0,0,-1,-1),
CvPoint _dst_origin=cvPoint(0,0), int _flags=0 );
/* retrieve various parameters of the filtering object */
int get_src_type() const { return src_type; }
int get_dst_type() const { return dst_type; }
int get_work_type() const { return work_type; }
CvSize get_kernel_size() const { return ksize; }
CvPoint get_anchor() const { return anchor; }
int get_width() const { return prev_x_range.end_index - prev_x_range.start_index; }
CvRowFilterFunc get_x_filter_func() const { return x_func; }
CvColumnFilterFunc get_y_filter_func() const { return y_func; }
protected:
/* initializes work_type, buf_size and max_rows */
virtual void get_work_params();
/* it is called (not always) from process when _phase=CV_START or CV_WHOLE.
the method initializes ring buffer (buf_end, buf_head, buf_tail, buf_count, rows),
prev_width, prev_x_range, const_row, border_tab, border_tab_sz* */
virtual void start_process( CvSlice x_range, int width );
/* forms pointers to "virtual rows" above or below the processed roi using the specified
border mode */
virtual void make_y_border( int row_count, int top_rows, int bottom_rows );
virtual int fill_cyclic_buffer( const uchar* src, int src_step,
int y, int y1, int y2 );
enum { ALIGN=32 };
int max_width;
/* currently, work_type must be the same as src_type in case of non-separable filters */
int min_depth, src_type, dst_type, work_type;
/* pointers to convolution functions, initialized by init method.
for non-separable filters only y_conv should be set */
CvRowFilterFunc x_func;
CvColumnFilterFunc y_func;
uchar* buffer;
uchar** rows;
int top_rows, bottom_rows, max_rows;
uchar *buf_start, *buf_end, *buf_head, *buf_tail;
int buf_size, buf_step, buf_count, buf_max_count;
bool is_separable;
CvSize ksize;
CvPoint anchor;
int max_ky, border_mode;
CvScalar border_value;
uchar* const_row;
int* border_tab;
int border_tab_sz1, border_tab_sz;
CvSlice prev_x_range;
int prev_width;
};
/* Derived class, for linear separable filtering. */
class CV_EXPORTS CvSepFilter : public CvBaseImageFilter
{
public:
CvSepFilter();
CvSepFilter( int _max_width, int _src_type, int _dst_type,
const CvMat* _kx, const CvMat* _ky,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual ~CvSepFilter();
virtual void init( int _max_width, int _src_type, int _dst_type,
const CvMat* _kx, const CvMat* _ky,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual void init_deriv( int _max_width, int _src_type, int _dst_type,
int dx, int dy, int aperture_size, int flags=0 );
virtual void init_gaussian( int _max_width, int _src_type, int _dst_type,
int gaussian_size, double sigma );
/* dummy method to avoid compiler warnings */
virtual void init( int _max_width, int _src_type, int _dst_type,
bool _is_separable, CvSize _ksize,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual void clear();
const CvMat* get_x_kernel() const { return kx; }
const CvMat* get_y_kernel() const { return ky; }
int get_x_kernel_flags() const { return kx_flags; }
int get_y_kernel_flags() const { return ky_flags; }
enum { GENERIC=0, ASYMMETRICAL=1, SYMMETRICAL=2, POSITIVE=4, SUM_TO_1=8, INTEGER=16 };
enum { NORMALIZE_KERNEL=1, FLIP_KERNEL=2 };
static void init_gaussian_kernel( CvMat* kernel, double sigma=-1 );
static void init_sobel_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, int flags=0 );
static void init_scharr_kernel( CvMat* _kx, CvMat* _ky, int dx, int dy, int flags=0 );
protected:
CvMat *kx, *ky;
int kx_flags, ky_flags;
};
/* Derived class, for linear non-separable filtering. */
class CV_EXPORTS CvLinearFilter : public CvBaseImageFilter
{
public:
CvLinearFilter();
CvLinearFilter( int _max_width, int _src_type, int _dst_type,
const CvMat* _kernel,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual ~CvLinearFilter();
virtual void init( int _max_width, int _src_type, int _dst_type,
const CvMat* _kernel,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
/* dummy method to avoid compiler warnings */
virtual void init( int _max_width, int _src_type, int _dst_type,
bool _is_separable, CvSize _ksize,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual void clear();
const CvMat* get_kernel() const { return kernel; }
uchar* get_kernel_sparse_buf() { return k_sparse; }
int get_kernel_sparse_count() const { return k_sparse_count; }
protected:
CvMat *kernel;
uchar* k_sparse;
int k_sparse_count;
};
/* Box filter ("all 1's", optionally normalized) filter. */
class CV_EXPORTS CvBoxFilter : public CvBaseImageFilter
{
public:
CvBoxFilter();
CvBoxFilter( int _max_width, int _src_type, int _dst_type,
bool _normalized, CvSize _ksize,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual void init( int _max_width, int _src_type, int _dst_type,
bool _normalized, CvSize _ksize,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual ~CvBoxFilter();
bool is_normalized() const { return normalized; }
double get_scale() const { return scale; }
uchar* get_sum_buf() { return sum; }
int* get_sum_count_ptr() { return &sum_count; }
protected:
virtual void start_process( CvSlice x_range, int width );
uchar* sum;
int sum_count;
bool normalized;
double scale;
};
/* Laplacian operator: (d2/dx + d2/dy)I. */
class CV_EXPORTS CvLaplaceFilter : public CvSepFilter
{
public:
CvLaplaceFilter();
CvLaplaceFilter( int _max_width, int _src_type, int _dst_type,
bool _normalized, int _ksize,
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual ~CvLaplaceFilter();
virtual void init( int _max_width, int _src_type, int _dst_type,
bool _normalized, int _ksize,
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
/* dummy methods to avoid compiler warnings */
virtual void init( int _max_width, int _src_type, int _dst_type,
bool _is_separable, CvSize _ksize,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual void init( int _max_width, int _src_type, int _dst_type,
const CvMat* _kx, const CvMat* _ky,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
bool is_normalized() const { return normalized; }
bool is_basic_laplacian() const { return basic_laplacian; }
protected:
void get_work_params();
bool basic_laplacian;
bool normalized;
};
/* basic morphological operations: erosion & dilation */
class CV_EXPORTS CvMorphology : public CvBaseImageFilter
{
public:
CvMorphology();
CvMorphology( int _operation, int _max_width, int _src_dst_type,
int _element_shape, CvMat* _element,
CvSize _ksize=cvSize(0,0), CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual ~CvMorphology();
virtual void init( int _operation, int _max_width, int _src_dst_type,
int _element_shape, CvMat* _element,
CvSize _ksize=cvSize(0,0), CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
/* dummy method to avoid compiler warnings */
virtual void init( int _max_width, int _src_type, int _dst_type,
bool _is_separable, CvSize _ksize,
CvPoint _anchor=cvPoint(-1,-1),
int _border_mode=IPL_BORDER_REPLICATE,
CvScalar _border_value=cvScalarAll(0) );
virtual void clear();
const CvMat* get_element() const { return element; }
int get_element_shape() const { return el_shape; }
int get_operation() const { return operation; }
uchar* get_element_sparse_buf() { return el_sparse; }
int get_element_sparse_count() const { return el_sparse_count; }
enum { RECT=0, CROSS=1, ELLIPSE=2, CUSTOM=100, BINARY = 0, GRAYSCALE=256 };
enum { ERODE=0, DILATE=1 };
static void init_binary_element( CvMat* _element, int _element_shape,
CvPoint _anchor=cvPoint(-1,-1) );
protected:
void start_process( CvSlice x_range, int width );
int fill_cyclic_buffer( const uchar* src, int src_step,
int y0, int y1, int y2 );
uchar* el_sparse;
int el_sparse_count;
CvMat *element;
int el_shape;
int operation;
};
#endif /* __cplusplus */
#endif /* _CV_HPP_ */
/* End of file. */

View File

@@ -0,0 +1,93 @@
/*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 _CVSTREAMS_H_
#define _CVSTREAMS_H_
#ifdef WIN32
#include <streams.h> /* !!! IF YOU'VE GOT AN ERROR HERE, PLEASE READ BELOW !!! */
/***************** How to get Visual Studio understand streams.h ****************\
You need DirectShow SDK that is now a part of Platform SDK
(Windows Server 2003 SP1 SDK or later),
and DirectX SDK (2006 April or later).
1. Download the Platform SDK from
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
and DirectX SDK from msdn.microsoft.com/directx/
(They are huge, but you can download it by parts).
If it doesn't work for you, consider HighGUI that can capture video via VFW or MIL
2. Install Platform SDK together with DirectShow SDK.
Install DirectX (with or without sample code).
3. Build baseclasses.
See <PlatformSDKInstallFolder>\samples\multimedia\directshow\readme.txt.
4. Copy the built libraries (called strmbase.lib and strmbasd.lib
in Release and Debug versions, respectively) to
<PlatformSDKInstallFolder>\lib.
5. In Developer Studio add the following paths:
<DirectXSDKInstallFolder>\include
<PlatformSDKInstallFolder>\include
<PlatformSDKInstallFolder>\samples\multimedia\directshow\baseclasses
to the includes' search path
(at Tools->Options->Directories->Include files in case of Visual Studio 6.0,
at Tools->Options->Projects and Solutions->VC++ Directories->Include files in case
of Visual Studio 2005)
Add
<DirectXSDKInstallFolder>\lib
<PlatformSDKInstallFolder>\lib
to the libraries' search path (in the same dialog, ...->"Library files" page)
NOTE: PUT THE ADDED LINES ON THE VERY TOP OF THE LISTS, OTHERWISE YOU MAY STILL GET
COMPILER OR LINKER ERRORS. This is necessary, because Visual Studio
may include older versions of the same headers and libraries.
6. Now you can build OpenCV DirectShow filters.
\***********************************************************************************/
#endif
#endif /*_CVSTREAMS_H_*/

View File

@@ -0,0 +1,384 @@
/*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 _CVTYPES_H_
#define _CVTYPES_H_
#ifndef SKIP_INCLUDES
#include <assert.h>
#include <stdlib.h>
#endif
/* spatial and central moments */
typedef struct CvMoments
{
double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; /* spatial moments */
double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /* central moments */
double inv_sqrt_m00; /* m00 != 0 ? 1/sqrt(m00) : 0 */
}
CvMoments;
/* Hu invariants */
typedef struct CvHuMoments
{
double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /* Hu invariants */
}
CvHuMoments;
/**************************** Connected Component **************************************/
typedef struct CvConnectedComp
{
double area; /* area of the connected component */
CvScalar value; /* average color of the connected component */
CvRect rect; /* ROI of the component */
CvSeq* contour; /* optional component boundary
(the contour might have child contours corresponding to the holes)*/
}
CvConnectedComp;
/*
Internal structure that is used for sequental retrieving contours from the image.
It supports both hierarchical and plane variants of Suzuki algorithm.
*/
typedef struct _CvContourScanner* CvContourScanner;
/* contour retrieval mode */
#define CV_RETR_EXTERNAL 0
#define CV_RETR_LIST 1
#define CV_RETR_CCOMP 2
#define CV_RETR_TREE 3
/* contour approximation method */
#define CV_CHAIN_CODE 0
#define CV_CHAIN_APPROX_NONE 1
#define CV_CHAIN_APPROX_SIMPLE 2
#define CV_CHAIN_APPROX_TC89_L1 3
#define CV_CHAIN_APPROX_TC89_KCOS 4
#define CV_LINK_RUNS 5
/* Freeman chain reader state */
typedef struct CvChainPtReader
{
CV_SEQ_READER_FIELDS()
char code;
CvPoint pt;
char deltas[8][2];
}
CvChainPtReader;
/* initializes 8-element array for fast access to 3x3 neighborhood of a pixel */
#define CV_INIT_3X3_DELTAS( deltas, step, nch ) \
((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
(deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
(deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
(deltas)[6] = (step), (deltas)[7] = (step) + (nch))
/* Contour tree header */
typedef struct CvContourTree
{
CV_SEQUENCE_FIELDS()
CvPoint p1; /* the first point of the binary tree root segment */
CvPoint p2; /* the last point of the binary tree root segment */
}
CvContourTree;
/* Finds a sequence of convexity defects of given contour */
typedef struct CvConvexityDefect
{
CvPoint* start; /* point of the contour where the defect begins */
CvPoint* end; /* point of the contour where the defect ends */
CvPoint* depth_point; /* the farthest from the convex hull point within the defect */
float depth; /* distance between the farthest point and the convex hull */
}
CvConvexityDefect;
/************ Data structures and related enumerations for Planar Subdivisions ************/
typedef size_t CvSubdiv2DEdge;
#define CV_QUADEDGE2D_FIELDS() \
int flags; \
struct CvSubdiv2DPoint* pt[4]; \
CvSubdiv2DEdge next[4];
#define CV_SUBDIV2D_POINT_FIELDS()\
int flags; \
CvSubdiv2DEdge first; \
CvPoint2D32f pt;
#define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30)
typedef struct CvQuadEdge2D
{
CV_QUADEDGE2D_FIELDS()
}
CvQuadEdge2D;
typedef struct CvSubdiv2DPoint
{
CV_SUBDIV2D_POINT_FIELDS()
}
CvSubdiv2DPoint;
#define CV_SUBDIV2D_FIELDS() \
CV_GRAPH_FIELDS() \
int quad_edges; \
int is_geometry_valid; \
CvSubdiv2DEdge recent_edge; \
CvPoint2D32f topleft; \
CvPoint2D32f bottomright;
typedef struct CvSubdiv2D
{
CV_SUBDIV2D_FIELDS()
}
CvSubdiv2D;
typedef enum CvSubdiv2DPointLocation
{
CV_PTLOC_ERROR = -2,
CV_PTLOC_OUTSIDE_RECT = -1,
CV_PTLOC_INSIDE = 0,
CV_PTLOC_VERTEX = 1,
CV_PTLOC_ON_EDGE = 2
}
CvSubdiv2DPointLocation;
typedef enum CvNextEdgeType
{
CV_NEXT_AROUND_ORG = 0x00,
CV_NEXT_AROUND_DST = 0x22,
CV_PREV_AROUND_ORG = 0x11,
CV_PREV_AROUND_DST = 0x33,
CV_NEXT_AROUND_LEFT = 0x13,
CV_NEXT_AROUND_RIGHT = 0x31,
CV_PREV_AROUND_LEFT = 0x20,
CV_PREV_AROUND_RIGHT = 0x02
}
CvNextEdgeType;
/* get the next edge with the same origin point (counterwise) */
#define CV_SUBDIV2D_NEXT_EDGE( edge ) (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3])
/* Defines for Distance Transform */
#define CV_DIST_USER -1 /* User defined distance */
#define CV_DIST_L1 1 /* distance = |x1-x2| + |y1-y2| */
#define CV_DIST_L2 2 /* the simple euclidean distance */
#define CV_DIST_C 3 /* distance = max(|x1-x2|,|y1-y2|) */
#define CV_DIST_L12 4 /* L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */
#define CV_DIST_FAIR 5 /* distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */
#define CV_DIST_WELSCH 6 /* distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */
#define CV_DIST_HUBER 7 /* distance = |x|<c ? x^2/2 : c(|x|-c/2), c=1.345 */
/* Filters used in pyramid decomposition */
typedef enum CvFilter
{
CV_GAUSSIAN_5x5 = 7
}
CvFilter;
/****************************************************************************************/
/* Older definitions */
/****************************************************************************************/
typedef float* CvVect32f;
typedef float* CvMatr32f;
typedef double* CvVect64d;
typedef double* CvMatr64d;
typedef struct CvMatrix3
{
float m[3][3];
}
CvMatrix3;
#ifdef __cplusplus
extern "C" {
#endif
typedef float (CV_CDECL * CvDistanceFunction)( const float* a, const float* b, void* user_param );
#ifdef __cplusplus
}
#endif
typedef struct CvConDensation
{
int MP;
int DP;
float* DynamMatr; /* Matrix of the linear Dynamics system */
float* State; /* Vector of State */
int SamplesNum; /* Number of the Samples */
float** flSamples; /* arr of the Sample Vectors */
float** flNewSamples; /* temporary array of the Sample Vectors */
float* flConfidence; /* Confidence for each Sample */
float* flCumulative; /* Cumulative confidence */
float* Temp; /* Temporary vector */
float* RandomSample; /* RandomVector to update sample set */
struct CvRandState* RandS; /* Array of structures to generate random vectors */
}
CvConDensation;
/*
standard Kalman filter (in G. Welch' and G. Bishop's notation):
x(k)=A*x(k-1)+B*u(k)+w(k) p(w)~N(0,Q)
z(k)=H*x(k)+v(k), p(v)~N(0,R)
*/
typedef struct CvKalman
{
int MP; /* number of measurement vector dimensions */
int DP; /* number of state vector dimensions */
int CP; /* number of control vector dimensions */
/* backward compatibility fields */
#if 1
float* PosterState; /* =state_pre->data.fl */
float* PriorState; /* =state_post->data.fl */
float* DynamMatr; /* =transition_matrix->data.fl */
float* MeasurementMatr; /* =measurement_matrix->data.fl */
float* MNCovariance; /* =measurement_noise_cov->data.fl */
float* PNCovariance; /* =process_noise_cov->data.fl */
float* KalmGainMatr; /* =gain->data.fl */
float* PriorErrorCovariance;/* =error_cov_pre->data.fl */
float* PosterErrorCovariance;/* =error_cov_post->data.fl */
float* Temp1; /* temp1->data.fl */
float* Temp2; /* temp2->data.fl */
#endif
CvMat* state_pre; /* predicted state (x'(k)):
x(k)=A*x(k-1)+B*u(k) */
CvMat* state_post; /* corrected state (x(k)):
x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) */
CvMat* transition_matrix; /* state transition matrix (A) */
CvMat* control_matrix; /* control matrix (B)
(it is not used if there is no control)*/
CvMat* measurement_matrix; /* measurement matrix (H) */
CvMat* process_noise_cov; /* process noise covariance matrix (Q) */
CvMat* measurement_noise_cov; /* measurement noise covariance matrix (R) */
CvMat* error_cov_pre; /* priori error estimate covariance matrix (P'(k)):
P'(k)=A*P(k-1)*At + Q)*/
CvMat* gain; /* Kalman gain matrix (K(k)):
K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)*/
CvMat* error_cov_post; /* posteriori error estimate covariance matrix (P(k)):
P(k)=(I-K(k)*H)*P'(k) */
CvMat* temp1; /* temporary matrices */
CvMat* temp2;
CvMat* temp3;
CvMat* temp4;
CvMat* temp5;
}
CvKalman;
/*********************** Haar-like Object Detection structures **************************/
#define CV_HAAR_MAGIC_VAL 0x42500000
#define CV_TYPE_NAME_HAAR "opencv-haar-classifier"
#define CV_IS_HAAR_CLASSIFIER( haar ) \
((haar) != NULL && \
(((const CvHaarClassifierCascade*)(haar))->flags & CV_MAGIC_MASK)==CV_HAAR_MAGIC_VAL)
#define CV_HAAR_FEATURE_MAX 3
typedef struct CvHaarFeature
{
int tilted;
struct
{
CvRect r;
float weight;
} rect[CV_HAAR_FEATURE_MAX];
}
CvHaarFeature;
typedef struct CvHaarClassifier
{
int count;
CvHaarFeature* haar_feature;
float* threshold;
int* left;
int* right;
float* alpha;
}
CvHaarClassifier;
typedef struct CvHaarStageClassifier
{
int count;
float threshold;
CvHaarClassifier* classifier;
int next;
int child;
int parent;
}
CvHaarStageClassifier;
typedef struct CvHidHaarClassifierCascade CvHidHaarClassifierCascade;
typedef struct CvHaarClassifierCascade
{
int flags;
int count;
CvSize orig_window_size;
CvSize real_window_size;
double scale;
CvHaarStageClassifier* stage_classifier;
CvHidHaarClassifierCascade* hid_cascade;
}
CvHaarClassifierCascade;
typedef struct CvAvgComp
{
CvRect rect;
int neighbors;
}
CvAvgComp;
#endif /*_CVTYPES_H_*/
/* End of file. */

View File

@@ -0,0 +1 @@
*.aps *.plg *.o *.lo Makefile .libs

View File

@@ -0,0 +1,32 @@
EXTRA_DIST = cv.dsp cv.vcproj cv.rc resource.h
INCLUDES = -I. -I$(top_srcdir)/cv/include -I$(top_srcdir)/cxcore/include -I$(top_srcdir)
noinst_HEADERS = _cv.h _cvgeom.h _cvimgproc.h _cvipp.h _cvlist.h _cvmatrix.h
noinst_LTLIBRARIES = lib_cv.la
lib_LTLIBRARIES = libcv.la
# convenience libraries
lib_cv_la_SOURCES = \
cvaccum.cpp cvadapthresh.cpp cvapprox.cpp cvcalccontrasthistogram.cpp \
cvcalcimagehomography.cpp cvcalibinit.cpp cvcalibration.cpp \
cvcamshift.cpp cvcanny.cpp cvcolor.cpp cvcondens.cpp cvcontours.cpp \
cvcontourtree.cpp cvconvhull.cpp cvcorner.cpp \
cvcornersubpix.cpp cvderiv.cpp cvdistransform.cpp cvdominants.cpp \
cvemd.cpp cvfeatureselect.cpp cvfilter.cpp cvfloodfill.cpp cvfundam.cpp \
cvgeometry.cpp cvhaar.cpp cvhistogram.cpp cvhough.cpp cvimgwarp.cpp \
cvinpaint.cpp cvkalman.cpp cvlinefit.cpp cvlkpyramid.cpp cvmatchcontours.cpp \
cvmoments.cpp cvmorph.cpp cvmotempl.cpp cvoptflowbm.cpp cvoptflowhs.cpp \
cvoptflowlk.cpp cvpgh.cpp cvposit.cpp cvprecomp.cpp cvpyramids.cpp \
cvpyrsegmentation.cpp cvrotcalipers.cpp cvsamplers.cpp cvsegmentation.cpp cvshapedescr.cpp \
cvsmooth.cpp cvsnakes.cpp cvsubdivision2d.cpp cvsumpixels.cpp \
cvswitcher.cpp cvtables.cpp cvtemplmatch.cpp cvthresh.cpp \
cvundistort.cpp cvutils.cpp
lib_cv_la_LDFLAGS = -no-undefined @LDFLAGS@
# real library
libcv_la_SOURCES = dummy.cpp
libcv_la_LDFLAGS = -no-undefined -version-info @LT_VERSION@ @LDFLAGS@
libcv_la_LIBADD = lib_cv.la \
$(top_builddir)/cxcore/src/libcxcore.la \
@LTLIBOBJS@

View File

@@ -0,0 +1,671 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = cv/src
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/autotools/aclocal/az_python.m4 \
$(top_srcdir)/autotools/aclocal/pkg.m4 \
$(top_srcdir)/autotools/aclocal/swig_complete.m4 \
$(top_srcdir)/autotools/aclocal/version_at_least.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/autotools/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/cvconfig.h
CONFIG_CLEAN_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
lib_cv_la_LIBADD =
am_lib_cv_la_OBJECTS = cvaccum.lo cvadapthresh.lo cvapprox.lo \
cvcalccontrasthistogram.lo cvcalcimagehomography.lo \
cvcalibinit.lo cvcalibration.lo cvcamshift.lo cvcanny.lo \
cvcolor.lo cvcondens.lo cvcontours.lo cvcontourtree.lo \
cvconvhull.lo cvcorner.lo cvcornersubpix.lo cvderiv.lo \
cvdistransform.lo cvdominants.lo cvemd.lo cvfeatureselect.lo \
cvfilter.lo cvfloodfill.lo cvfundam.lo cvgeometry.lo cvhaar.lo \
cvhistogram.lo cvhough.lo cvimgwarp.lo cvinpaint.lo \
cvkalman.lo cvlinefit.lo cvlkpyramid.lo cvmatchcontours.lo \
cvmoments.lo cvmorph.lo cvmotempl.lo cvoptflowbm.lo \
cvoptflowhs.lo cvoptflowlk.lo cvpgh.lo cvposit.lo cvprecomp.lo \
cvpyramids.lo cvpyrsegmentation.lo cvrotcalipers.lo \
cvsamplers.lo cvsegmentation.lo cvshapedescr.lo cvsmooth.lo \
cvsnakes.lo cvsubdivision2d.lo cvsumpixels.lo cvswitcher.lo \
cvtables.lo cvtemplmatch.lo cvthresh.lo cvundistort.lo \
cvutils.lo
lib_cv_la_OBJECTS = $(am_lib_cv_la_OBJECTS)
libcv_la_DEPENDENCIES = lib_cv.la \
$(top_builddir)/cxcore/src/libcxcore.la @LTLIBOBJS@
am_libcv_la_OBJECTS = dummy.lo
libcv_la_OBJECTS = $(am_libcv_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/autotools/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(lib_cv_la_SOURCES) $(libcv_la_SOURCES)
DIST_SOURCES = $(lib_cv_la_SOURCES) $(libcv_la_SOURCES)
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_APPS_FALSE = @BUILD_APPS_FALSE@
BUILD_APPS_TRUE = @BUILD_APPS_TRUE@
BUILD_CARBON_FALSE = @BUILD_CARBON_FALSE@
BUILD_CARBON_TRUE = @BUILD_CARBON_TRUE@
BUILD_DC1394_FALSE = @BUILD_DC1394_FALSE@
BUILD_DC1394_TRUE = @BUILD_DC1394_TRUE@
BUILD_FFMPEG_FALSE = @BUILD_FFMPEG_FALSE@
BUILD_FFMPEG_TRUE = @BUILD_FFMPEG_TRUE@
BUILD_GTK_FALSE = @BUILD_GTK_FALSE@
BUILD_GTK_TRUE = @BUILD_GTK_TRUE@
BUILD_PYTHON_WRAPPERS_FALSE = @BUILD_PYTHON_WRAPPERS_FALSE@
BUILD_PYTHON_WRAPPERS_TRUE = @BUILD_PYTHON_WRAPPERS_TRUE@
BUILD_QUICKTIME_FALSE = @BUILD_QUICKTIME_FALSE@
BUILD_QUICKTIME_TRUE = @BUILD_QUICKTIME_TRUE@
BUILD_V4L_FALSE = @BUILD_V4L_FALSE@
BUILD_V4L_TRUE = @BUILD_V4L_TRUE@
BUILD_XINE_FALSE = @BUILD_XINE_FALSE@
BUILD_XINE_TRUE = @BUILD_XINE_TRUE@
CARBON_CFLAGS = @CARBON_CFLAGS@
CARBON_LIBS = @CARBON_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEBUG = @DEBUG@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
FFMPEGLIBS = @FFMPEGLIBS@
GREP = @GREP@
GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
GTHREAD_LIBS = @GTHREAD_LIBS@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_LIBS = @GTK_LIBS@
IEEE1394LIBS = @IEEE1394LIBS@
IMAGELIBS = @IMAGELIBS@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_VERSION = @LT_VERSION@
MAKEINFO = @MAKEINFO@
MMAJOR = @MMAJOR@
MMINOR = @MMINOR@
MSUBMINOR = @MSUBMINOR@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PYTHON = @PYTHON@
PYTHON_CSPEC = @PYTHON_CSPEC@
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
PYTHON_LSPEC = @PYTHON_LSPEC@
PYTHON_PLATFORM = @PYTHON_PLATFORM@
PYTHON_PREFIX = @PYTHON_PREFIX@
PYTHON_VERSION = @PYTHON_VERSION@
QUICKTIME_CFLAGS = @QUICKTIME_CFLAGS@
QUICKTIME_LIBS = @QUICKTIME_LIBS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
SWIG = @SWIG@
SWIG_PYTHON_LIBS = @SWIG_PYTHON_LIBS@
SWIG_PYTHON_OPT = @SWIG_PYTHON_OPT@
SWIG_RUNTIME_LIBS_DIR = @SWIG_RUNTIME_LIBS_DIR@
SWIG_VERSION = @SWIG_VERSION@
UPDATE_SWIG_WRAPPERS_FALSE = @UPDATE_SWIG_WRAPPERS_FALSE@
UPDATE_SWIG_WRAPPERS_TRUE = @UPDATE_SWIG_WRAPPERS_TRUE@
VERSION = @VERSION@
XINE_LIBS = @XINE_LIBS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgpyexecdir = @pkgpyexecdir@
pkgpythondir = @pkgpythondir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
pyexecdir = @pyexecdir@
pythondir = @pythondir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
EXTRA_DIST = cv.dsp cv.vcproj cv.rc resource.h
INCLUDES = -I. -I$(top_srcdir)/cv/include -I$(top_srcdir)/cxcore/include -I$(top_srcdir)
noinst_HEADERS = _cv.h _cvgeom.h _cvimgproc.h _cvipp.h _cvlist.h _cvmatrix.h
noinst_LTLIBRARIES = lib_cv.la
lib_LTLIBRARIES = libcv.la
# convenience libraries
lib_cv_la_SOURCES = \
cvaccum.cpp cvadapthresh.cpp cvapprox.cpp cvcalccontrasthistogram.cpp \
cvcalcimagehomography.cpp cvcalibinit.cpp cvcalibration.cpp \
cvcamshift.cpp cvcanny.cpp cvcolor.cpp cvcondens.cpp cvcontours.cpp \
cvcontourtree.cpp cvconvhull.cpp cvcorner.cpp \
cvcornersubpix.cpp cvderiv.cpp cvdistransform.cpp cvdominants.cpp \
cvemd.cpp cvfeatureselect.cpp cvfilter.cpp cvfloodfill.cpp cvfundam.cpp \
cvgeometry.cpp cvhaar.cpp cvhistogram.cpp cvhough.cpp cvimgwarp.cpp \
cvinpaint.cpp cvkalman.cpp cvlinefit.cpp cvlkpyramid.cpp cvmatchcontours.cpp \
cvmoments.cpp cvmorph.cpp cvmotempl.cpp cvoptflowbm.cpp cvoptflowhs.cpp \
cvoptflowlk.cpp cvpgh.cpp cvposit.cpp cvprecomp.cpp cvpyramids.cpp \
cvpyrsegmentation.cpp cvrotcalipers.cpp cvsamplers.cpp cvsegmentation.cpp cvshapedescr.cpp \
cvsmooth.cpp cvsnakes.cpp cvsubdivision2d.cpp cvsumpixels.cpp \
cvswitcher.cpp cvtables.cpp cvtemplmatch.cpp cvthresh.cpp \
cvundistort.cpp cvutils.cpp
lib_cv_la_LDFLAGS = -no-undefined @LDFLAGS@
# real library
libcv_la_SOURCES = dummy.cpp
libcv_la_LDFLAGS = -no-undefined -version-info @LT_VERSION@ @LDFLAGS@
libcv_la_LIBADD = lib_cv.la \
$(top_builddir)/cxcore/src/libcxcore.la \
@LTLIBOBJS@
all: all-am
.SUFFIXES:
.SUFFIXES: .c .cpp .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cv/src/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu cv/src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
lib_cv.la: $(lib_cv_la_OBJECTS) $(lib_cv_la_DEPENDENCIES)
$(CXXLINK) $(lib_cv_la_LDFLAGS) $(lib_cv_la_OBJECTS) $(lib_cv_la_LIBADD) $(LIBS)
libcv.la: $(libcv_la_OBJECTS) $(libcv_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libdir) $(libcv_la_LDFLAGS) $(libcv_la_OBJECTS) $(libcv_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvaccum.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvadapthresh.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvapprox.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcalccontrasthistogram.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcalcimagehomography.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcalibinit.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcalibration.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcamshift.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcanny.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcolor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcondens.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcontours.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcontourtree.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvconvhull.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcorner.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvcornersubpix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvderiv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvdistransform.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvdominants.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvemd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvfeatureselect.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvfilter.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvfloodfill.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvfundam.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvgeometry.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvhaar.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvhistogram.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvhough.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvimgwarp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvinpaint.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvkalman.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvlinefit.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvlkpyramid.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvmatchcontours.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvmoments.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvmorph.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvmotempl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvoptflowbm.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvoptflowhs.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvoptflowlk.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvpgh.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvposit.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvprecomp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvpyramids.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvpyrsegmentation.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvrotcalipers.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvsamplers.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvsegmentation.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvshapedescr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvsmooth.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvsnakes.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvsubdivision2d.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvsumpixels.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvswitcher.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvtables.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvtemplmatch.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvthresh.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvundistort.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvutils.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
.cpp.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(libdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
clean-noinstLTLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am: install-libLTLIBRARIES
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \
ctags distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-libLTLIBRARIES install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am \
uninstall-info-am uninstall-libLTLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,118 @@
/*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 _CV_INTERNAL_H_
#define _CV_INTERNAL_H_
#if defined _MSC_VER && _MSC_VER >= 1200
/* disable warnings related to inline functions */
#pragma warning( disable: 4711 4710 4514 )
#endif
#include "cv.h"
#include "cxmisc.h"
#include <math.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <float.h>
typedef unsigned char uchar;
typedef unsigned short ushort;
#ifdef __BORLANDC__
#define WIN32
#define CV_DLL
#undef _CV_ALWAYS_PROFILE_
#define _CV_ALWAYS_NO_PROFILE_
#endif
/* helper tables */
extern const uchar icvSaturate8u_cv[];
#define CV_FAST_CAST_8U(t) (assert(-256 <= (t) || (t) <= 512), icvSaturate8u_cv[(t)+256])
#define CV_CALC_MIN_8U(a,b) (a) -= CV_FAST_CAST_8U((a) - (b))
#define CV_CALC_MAX_8U(a,b) (a) += CV_FAST_CAST_8U((b) - (a))
// -256.f ... 511.f
extern const float icv8x32fTab_cv[];
#define CV_8TO32F(x) icv8x32fTab_cv[(x)+256]
// (-128.f)^2 ... (255.f)^2
extern const float icv8x32fSqrTab[];
#define CV_8TO32F_SQR(x) icv8x32fSqrTab[(x)+128]
CV_INLINE CvDataType icvDepthToDataType( int type );
CV_INLINE CvDataType icvDepthToDataType( int type )
{
return (CvDataType)(
((((int)cv8u)|((int)cv8s << 4)|((int)cv16u << 8)|
((int)cv16s << 12)|((int)cv32s << 16)|((int)cv32f << 20)|
((int)cv64f << 24)) >> CV_MAT_DEPTH(type)*4) & 15);
}
#define CV_HIST_DEFAULT_TYPE CV_32F
CV_EXTERN_C_FUNCPTR( void (CV_CDECL * CvWriteNodeFunction)(void* seq,void* node) )
#define _CvConvState CvFilterState
typedef struct CvPyramid
{
uchar **ptr;
CvSize *sz;
double *rate;
int *step;
uchar *state;
int level;
}
CvPyramid;
#include "_cvipp.h"
#include "_cvmatrix.h"
#include "_cvgeom.h"
#include "_cvimgproc.h"
// default face cascade
//extern const char* icvDefaultFaceCascade[];
#endif /*_CV_INTERNAL_H_*/

View File

@@ -0,0 +1,93 @@
/*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 _CV_GEOM_H_
#define _CV_GEOM_H_
/* Finds distance between two points */
CV_INLINE float icvDistanceL2_32f( CvPoint2D32f pt1, CvPoint2D32f pt2 )
{
float dx = pt2.x - pt1.x;
float dy = pt2.y - pt1.y;
return cvSqrt( dx*dx + dy*dy );
}
int icvIntersectLines( double x1, double dx1, double y1, double dy1,
double x2, double dx2, double y2, double dy2,
double* t2 );
void icvCreateCenterNormalLine( CvSubdiv2DEdge edge, double* a, double* b, double* c );
void icvIntersectLines3( double* a0, double* b0, double* c0,
double* a1, double* b1, double* c1,
CvPoint2D32f* point );
#define _CV_BINTREE_LIST() \
struct _CvTrianAttr* prev_v; /* pointer to the parent element on the previous level of the tree */ \
struct _CvTrianAttr* next_v1; /* pointer to the child element on the next level of the tree */ \
struct _CvTrianAttr* next_v2; /* pointer to the child element on the next level of the tree */
typedef struct _CvTrianAttr
{
CvPoint pt; /* Coordinates x and y of the vertex which don't lie on the base line LMIAT */
char sign; /* sign of the triangle */
double area; /* area of the triangle */
double r1; /* The ratio of the height of triangle to the base of the triangle */
double r2; /* The ratio of the projection of the left side of the triangle on the base to the base */
_CV_BINTREE_LIST() /* structure double list */
}
_CvTrianAttr;
/* curvature: 0 - 1-curvature, 1 - k-cosine curvature. */
CvStatus icvApproximateChainTC89( CvChain* chain,
int header_size,
CvMemStorage* storage,
CvSeq** contour,
int method );
#endif /*_IPCVGEOM_H_*/
/* End of file. */

View File

@@ -0,0 +1,113 @@
/*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 _CV_IMG_PROC_H_
#define _CV_IMG_PROC_H_
#define CV_COPY( dst, src, len, idx ) \
for( (idx) = 0; (idx) < (len); (idx)++) (dst)[idx] = (src)[idx]
#define CV_SET( dst, val, len, idx ) \
for( (idx) = 0; (idx) < (len); (idx)++) (dst)[idx] = (val)
/* performs convolution of 2d floating-point array with 3x1, 1x3 or separable 3x3 mask */
void icvSepConvSmall3_32f( float* src, int src_step, float* dst, int dst_step,
CvSize src_size, const float* kx, const float* ky, float* buffer );
typedef CvStatus (CV_STDCALL * CvSobelFixedIPPFunc)
( const void* src, int srcstep, void* dst, int dststep, CvSize roi, int aperture );
typedef CvStatus (CV_STDCALL * CvFilterFixedIPPFunc)
( const void* src, int srcstep, void* dst, int dststep, CvSize roi );
#undef CV_CALC_MIN
#define CV_CALC_MIN(a, b) if((a) > (b)) (a) = (b)
#undef CV_CALC_MAX
#define CV_CALC_MAX(a, b) if((a) < (b)) (a) = (b)
#define CV_MORPH_ALIGN 4
#define CV_WHOLE 0
#define CV_START 1
#define CV_END 2
#define CV_MIDDLE 4
void
icvCrossCorr( const CvArr* _img, const CvArr* _templ,
CvArr* _corr, CvPoint anchor=cvPoint(0,0) );
CvStatus CV_STDCALL
icvCopyReplicateBorder_8u( const uchar* src, int srcstep, CvSize srcroi,
uchar* dst, int dststep, CvSize dstroi,
int left, int right, int cn, const uchar* value = 0 );
CvMat* icvIPPFilterInit( const CvMat* src, int stripe_size, CvSize ksize );
int icvIPPFilterNextStripe( const CvMat* src, CvMat* temp, int y,
CvSize ksize, CvPoint anchor );
int icvIPPSepFilter( const CvMat* src, CvMat* dst, const CvMat* kernelX,
const CvMat* kernelY, CvPoint anchor );
#define ICV_WARP_SHIFT 10
#define ICV_WARP_MASK ((1 << ICV_WARP_SHIFT) - 1)
#define ICV_LINEAR_TAB_SIZE (ICV_WARP_MASK+1)
extern float icvLinearCoeffs[(ICV_LINEAR_TAB_SIZE+1)*2];
void icvInitLinearCoeffTab();
#define ICV_CUBIC_TAB_SIZE (ICV_WARP_MASK+1)
extern float icvCubicCoeffs[(ICV_CUBIC_TAB_SIZE+1)*2];
void icvInitCubicCoeffTab();
CvStatus CV_STDCALL icvGetRectSubPix_8u_C1R
( const uchar* src, int src_step, CvSize src_size,
uchar* dst, int dst_step, CvSize win_size, CvPoint2D32f center );
CvStatus CV_STDCALL icvGetRectSubPix_8u32f_C1R
( const uchar* src, int src_step, CvSize src_size,
float* dst, int dst_step, CvSize win_size, CvPoint2D32f center );
CvStatus CV_STDCALL icvGetRectSubPix_32f_C1R
( const float* src, int src_step, CvSize src_size,
float* dst, int dst_step, CvSize win_size, CvPoint2D32f center );
#endif /*_CV_INTERNAL_H_*/

View File

@@ -0,0 +1,741 @@
/*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 _CV_IPP_H_
#define _CV_IPP_H_
/****************************************************************************************\
* Creating Borders *
\****************************************************************************************/
#define IPCV_COPY_BORDER( bordertype, flavor ) \
IPCVAPI_EX( CvStatus, icvCopy##bordertype##Border_##flavor##R, \
"ippiCopy" #bordertype "Border_" #flavor "R", CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const void* pSrc, int srcStep, CvSize srcRoiSize, void* pDst, int dstStep, \
CvSize dstRoiSize, int topBorderHeight, int leftBorderWidth )) \
\
IPCVAPI_EX( CvStatus, icvCopy##bordertype##Border_##flavor##IR, \
"ippiCopy" #bordertype "Border_" #flavor "IR", CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const void* pSrc, int srcDstStep, CvSize srcRoiSize, \
CvSize dstRoiSize, int topBorderHeight, int leftBorderWidth ))
IPCV_COPY_BORDER( Replicate, 8u_C1 )
IPCV_COPY_BORDER( Replicate, 16s_C1 )
IPCV_COPY_BORDER( Replicate, 8u_C3 )
IPCV_COPY_BORDER( Replicate, 32s_C1 )
IPCV_COPY_BORDER( Replicate, 16s_C3 )
IPCV_COPY_BORDER( Replicate, 16s_C4 )
IPCV_COPY_BORDER( Replicate, 32s_C3 )
IPCV_COPY_BORDER( Replicate, 32s_C4 )
/****************************************************************************************\
* Moments *
\****************************************************************************************/
#define IPCV_MOMENTS( suffix, ipp_suffix, cn ) \
IPCVAPI_EX( CvStatus, icvMoments##suffix##_C##cn##R, \
"ippiMoments" #ipp_suffix "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
( const void* img, int step, CvSize size, void* momentstate ))
IPCV_MOMENTS( _8u, 64f_8u, 1 )
IPCV_MOMENTS( _32f, 64f_32f, 1 )
#undef IPCV_MOMENTS
IPCVAPI_EX( CvStatus, icvMomentInitAlloc_64f,
"ippiMomentInitAlloc_64f", CV_PLUGINS1(CV_PLUGIN_IPPI),
(void** momentstate, CvHintAlgorithm hint ))
IPCVAPI_EX( CvStatus, icvMomentFree_64f,
"ippiMomentFree_64f", CV_PLUGINS1(CV_PLUGIN_IPPI),
(void* momentstate ))
IPCVAPI_EX( CvStatus, icvGetSpatialMoment_64f,
"ippiGetSpatialMoment_64f", CV_PLUGINS1(CV_PLUGIN_IPPI),
(const void* momentstate, int mOrd, int nOrd,
int nChannel, CvPoint roiOffset, double* value ))
/****************************************************************************************\
* Background differencing *
\****************************************************************************************/
/////////////////////////////////// Accumulation /////////////////////////////////////////
#define IPCV_ACCUM( flavor, arrtype, acctype ) \
IPCVAPI_EX( CvStatus, icvAdd_##flavor##_C1IR, \
"ippiAdd_" #flavor "_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src, int srcstep, acctype* dst, int dststep, CvSize size )) \
IPCVAPI_EX( CvStatus, icvAddSquare_##flavor##_C1IR, \
"ippiAddSquare_" #flavor "_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src, int srcstep, acctype* dst, int dststep, CvSize size )) \
IPCVAPI_EX( CvStatus, icvAddProduct_##flavor##_C1IR, \
"ippiAddProduct_" #flavor "_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src1, int srcstep1, const arrtype* src2, int srcstep2, \
acctype* dst, int dststep, CvSize size )) \
IPCVAPI_EX( CvStatus, icvAddWeighted_##flavor##_C1IR, \
"ippiAddWeighted_" #flavor "_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src, int srcstep, acctype* dst, int dststep, \
CvSize size, acctype alpha )) \
\
IPCVAPI_EX( CvStatus, icvAdd_##flavor##_C1IMR, \
"ippiAdd_" #flavor "_C1IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src, int srcstep, const uchar* mask, int maskstep, \
acctype* dst, int dststep, CvSize size )) \
IPCVAPI_EX( CvStatus, icvAddSquare_##flavor##_C1IMR, \
"ippiAddSquare_" #flavor "_C1IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src, int srcstep, const uchar* mask, int maskstep, \
acctype* dst, int dststep, CvSize size )) \
IPCVAPI_EX( CvStatus, icvAddProduct_##flavor##_C1IMR, \
"ippiAddProduct_" #flavor "_C1IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src1, int srcstep1, const arrtype* src2, int srcstep2, \
const uchar* mask, int maskstep, acctype* dst, int dststep, CvSize size )) \
IPCVAPI_EX( CvStatus, icvAddWeighted_##flavor##_C1IMR, \
"ippiAddWeighted_" #flavor "_C1IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src, int srcstep, const uchar* mask, int maskstep, \
acctype* dst, int dststep, CvSize size, acctype alpha )) \
\
IPCVAPI_EX( CvStatus, icvAdd_##flavor##_C3IMR, \
"ippiAdd_" #flavor "_C3IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src, int srcstep, const uchar* mask, int maskstep, \
acctype* dst, int dststep, CvSize size )) \
IPCVAPI_EX( CvStatus, icvAddSquare_##flavor##_C3IMR, \
"ippiAddSquare_" #flavor "_C3IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src, int srcstep, const uchar* mask, int maskstep, \
acctype* dst, int dststep, CvSize size )) \
IPCVAPI_EX( CvStatus, icvAddProduct_##flavor##_C3IMR, \
"ippiAddProduct_" #flavor "_C3IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src1, int srcstep1, const arrtype* src2, int srcstep2, \
const uchar* mask, int maskstep, acctype* dst, int dststep, CvSize size )) \
IPCVAPI_EX( CvStatus, icvAddWeighted_##flavor##_C3IMR, \
"ippiAddWeighted_" #flavor "_C3IMR", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* src, int srcstep, const uchar* mask, int maskstep, \
acctype* dst, int dststep, CvSize size, acctype alpha ))
IPCV_ACCUM( 8u32f, uchar, float )
IPCV_ACCUM( 32f, float, float )
#undef IPCV_ACCUM
/****************************************************************************************\
* Pyramids *
\****************************************************************************************/
IPCVAPI_EX( CvStatus, icvPyrDownGetBufSize_Gauss5x5,
"ippiPyrDownGetBufSize_Gauss5x5", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( int roiWidth, CvDataType dataType, int channels, int* bufSize ))
IPCVAPI_EX( CvStatus, icvPyrUpGetBufSize_Gauss5x5,
"ippiPyrUpGetBufSize_Gauss5x5", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( int roiWidth, CvDataType dataType, int channels, int* bufSize ))
#define ICV_PYRDOWN( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvPyrDown_Gauss5x5_##flavor##_C##cn##R, \
"ippiPyrDown_Gauss5x5_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const void* pSrc, int srcStep, void* pDst, int dstStep, \
CvSize roiSize, void* pBuffer ))
#define ICV_PYRUP( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvPyrUp_Gauss5x5_##flavor##_C##cn##R, \
"ippiPyrUp_Gauss5x5_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const void* pSrc, int srcStep, void* pDst, int dstStep, \
CvSize roiSize, void* pBuffer ))
ICV_PYRDOWN( 8u, 1 )
ICV_PYRDOWN( 8u, 3 )
ICV_PYRDOWN( 32f, 1 )
ICV_PYRDOWN( 32f, 3 )
ICV_PYRUP( 8u, 1 )
ICV_PYRUP( 8u, 3 )
ICV_PYRUP( 32f, 1 )
ICV_PYRUP( 32f, 3 )
#undef ICV_PYRDOWN
#undef ICV_PYRUP
/****************************************************************************************\
* Geometric Transformations *
\****************************************************************************************/
#define IPCV_RESIZE( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvResize_##flavor##_C##cn##R, \
"ippiResize_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
(const void* src, CvSize srcsize, int srcstep, CvRect srcroi, \
void* dst, int dststep, CvSize dstroi, \
double xfactor, double yfactor, int interpolation ))
IPCV_RESIZE( 8u, 1 )
IPCV_RESIZE( 8u, 3 )
IPCV_RESIZE( 8u, 4 )
IPCV_RESIZE( 16u, 1 )
IPCV_RESIZE( 16u, 3 )
IPCV_RESIZE( 16u, 4 )
IPCV_RESIZE( 32f, 1 )
IPCV_RESIZE( 32f, 3 )
IPCV_RESIZE( 32f, 4 )
#undef IPCV_RESIZE
#define IPCV_WARPAFFINE_BACK( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvWarpAffineBack_##flavor##_C##cn##R, \
"ippiWarpAffineBack_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
(const void* src, CvSize srcsize, int srcstep, CvRect srcroi, \
void* dst, int dststep, CvRect dstroi, \
const double* coeffs, int interpolate ))
IPCV_WARPAFFINE_BACK( 8u, 1 )
IPCV_WARPAFFINE_BACK( 8u, 3 )
IPCV_WARPAFFINE_BACK( 8u, 4 )
IPCV_WARPAFFINE_BACK( 32f, 1 )
IPCV_WARPAFFINE_BACK( 32f, 3 )
IPCV_WARPAFFINE_BACK( 32f, 4 )
#undef IPCV_WARPAFFINE_BACK
#define IPCV_WARPPERSPECTIVE_BACK( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvWarpPerspectiveBack_##flavor##_C##cn##R, \
"ippiWarpPerspectiveBack_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
(const void* src, CvSize srcsize, int srcstep, CvRect srcroi, \
void* dst, int dststep, CvRect dstroi, \
const double* coeffs, int interpolate ))
IPCV_WARPPERSPECTIVE_BACK( 8u, 1 )
IPCV_WARPPERSPECTIVE_BACK( 8u, 3 )
IPCV_WARPPERSPECTIVE_BACK( 8u, 4 )
IPCV_WARPPERSPECTIVE_BACK( 32f, 1 )
IPCV_WARPPERSPECTIVE_BACK( 32f, 3 )
IPCV_WARPPERSPECTIVE_BACK( 32f, 4 )
#undef IPCV_WARPPERSPECTIVE_BACK
#define IPCV_WARPPERSPECTIVE( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvWarpPerspective_##flavor##_C##cn##R, \
"ippiWarpPerspective_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI),\
(const void* src, CvSize srcsize, int srcstep, CvRect srcroi, \
void* dst, int dststep, CvRect dstroi, \
const double* coeffs, int interpolate ))
IPCV_WARPPERSPECTIVE( 8u, 1 )
IPCV_WARPPERSPECTIVE( 8u, 3 )
IPCV_WARPPERSPECTIVE( 8u, 4 )
IPCV_WARPPERSPECTIVE( 32f, 1 )
IPCV_WARPPERSPECTIVE( 32f, 3 )
IPCV_WARPPERSPECTIVE( 32f, 4 )
#undef IPCV_WARPPERSPECTIVE
#define IPCV_REMAP( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvRemap_##flavor##_C##cn##R, \
"ippiRemap_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const void* src, CvSize srcsize, int srcstep, CvRect srcroi, \
const float* xmap, int xmapstep, const float* ymap, int ymapstep, \
void* dst, int dststep, CvSize dstsize, int interpolation ))
IPCV_REMAP( 8u, 1 )
IPCV_REMAP( 8u, 3 )
IPCV_REMAP( 8u, 4 )
IPCV_REMAP( 32f, 1 )
IPCV_REMAP( 32f, 3 )
IPCV_REMAP( 32f, 4 )
#undef IPCV_REMAP
/****************************************************************************************\
* Morphology *
\****************************************************************************************/
#define IPCV_MORPHOLOGY( minmaxtype, morphtype, flavor, cn ) \
IPCVAPI_EX( CvStatus, icv##morphtype##Rect_##flavor##_C##cn##R, \
"ippiFilter" #minmaxtype "BorderReplicate_" #flavor "_C" #cn "R", \
CV_PLUGINS1(CV_PLUGIN_IPPCV), ( const void* src, int srcstep, void* dst, \
int dststep, CvSize roi, CvSize esize, CvPoint anchor, void* buffer )) \
IPCVAPI_EX( CvStatus, icv##morphtype##Rect_GetBufSize_##flavor##_C##cn##R, \
"ippiFilter" #minmaxtype "GetBufferSize_" #flavor "_C" #cn "R", \
CV_PLUGINS1(CV_PLUGIN_IPPCV), ( int width, CvSize esize, int* bufsize )) \
\
IPCVAPI_EX( CvStatus, icv##morphtype##_##flavor##_C##cn##R, \
"ippi" #morphtype "BorderReplicate_" #flavor "_C" #cn "R", \
CV_PLUGINS1(CV_PLUGIN_IPPCV), ( const void* src, int srcstep, \
void* dst, int dststep, CvSize roi, int bordertype, void* morphstate ))
IPCV_MORPHOLOGY( Min, Erode, 8u, 1 )
IPCV_MORPHOLOGY( Min, Erode, 8u, 3 )
IPCV_MORPHOLOGY( Min, Erode, 8u, 4 )
IPCV_MORPHOLOGY( Min, Erode, 32f, 1 )
IPCV_MORPHOLOGY( Min, Erode, 32f, 3 )
IPCV_MORPHOLOGY( Min, Erode, 32f, 4 )
IPCV_MORPHOLOGY( Max, Dilate, 8u, 1 )
IPCV_MORPHOLOGY( Max, Dilate, 8u, 3 )
IPCV_MORPHOLOGY( Max, Dilate, 8u, 4 )
IPCV_MORPHOLOGY( Max, Dilate, 32f, 1 )
IPCV_MORPHOLOGY( Max, Dilate, 32f, 3 )
IPCV_MORPHOLOGY( Max, Dilate, 32f, 4 )
#undef IPCV_MORPHOLOGY
#define IPCV_MORPHOLOGY_INIT_ALLOC( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvMorphInitAlloc_##flavor##_C##cn##R, \
"ippiMorphologyInitAlloc_" #flavor "_C" #cn "R", \
CV_PLUGINS1(CV_PLUGIN_IPPCV), ( int width, const uchar* element, \
CvSize esize, CvPoint anchor, void** morphstate ))
IPCV_MORPHOLOGY_INIT_ALLOC( 8u, 1 )
IPCV_MORPHOLOGY_INIT_ALLOC( 8u, 3 )
IPCV_MORPHOLOGY_INIT_ALLOC( 8u, 4 )
IPCV_MORPHOLOGY_INIT_ALLOC( 32f, 1 )
IPCV_MORPHOLOGY_INIT_ALLOC( 32f, 3 )
IPCV_MORPHOLOGY_INIT_ALLOC( 32f, 4 )
#undef IPCV_MORPHOLOGY_INIT_ALLOC
IPCVAPI_EX( CvStatus, icvMorphFree, "ippiMorphologyFree",
CV_PLUGINS1(CV_PLUGIN_IPPCV), ( void* morphstate ))
/****************************************************************************************\
* Smoothing Filters *
\****************************************************************************************/
#define IPCV_FILTER_MEDIAN( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvFilterMedian_##flavor##_C##cn##R, \
"ippiFilterMedian_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const void* src, int srcstep, void* dst, int dststep, \
CvSize roi, CvSize ksize, CvPoint anchor ))
IPCV_FILTER_MEDIAN( 8u, 1 )
IPCV_FILTER_MEDIAN( 8u, 3 )
IPCV_FILTER_MEDIAN( 8u, 4 )
#define IPCV_FILTER_BOX( flavor, cn ) \
IPCVAPI_EX( CvStatus, icvFilterBox_##flavor##_C##cn##R, \
"ippiFilterBox_" #flavor "_C" #cn "R", 0/*CV_PLUGINS1(CV_PLUGIN_IPPI)*/,\
( const void* src, int srcstep, void* dst, int dststep, \
CvSize roi, CvSize ksize, CvPoint anchor ))
IPCV_FILTER_BOX( 8u, 1 )
IPCV_FILTER_BOX( 8u, 3 )
IPCV_FILTER_BOX( 8u, 4 )
IPCV_FILTER_BOX( 32f, 1 )
IPCV_FILTER_BOX( 32f, 3 )
IPCV_FILTER_BOX( 32f, 4 )
#undef IPCV_FILTER_BOX
/****************************************************************************************\
* Derivative Filters *
\****************************************************************************************/
#define IPCV_FILTER_SOBEL_BORDER( suffix, flavor, srctype ) \
IPCVAPI_EX( CvStatus, icvFilterSobel##suffix##GetBufSize_##flavor##_C1R, \
"ippiFilterSobel" #suffix "GetBufferSize_" #flavor "_C1R", \
CV_PLUGINS1(CV_PLUGIN_IPPCV), ( CvSize roi, int masksize, int* buffersize )) \
IPCVAPI_EX( CvStatus, icvFilterSobel##suffix##Border_##flavor##_C1R, \
"ippiFilterSobel" #suffix "Border_" #flavor "_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const void* src, int srcstep, void* dst, int dststep, CvSize roi, int masksize, \
int bordertype, srctype bordervalue, void* buffer ))
IPCV_FILTER_SOBEL_BORDER( NegVert, 8u16s, uchar )
IPCV_FILTER_SOBEL_BORDER( Horiz, 8u16s, uchar )
IPCV_FILTER_SOBEL_BORDER( VertSecond, 8u16s, uchar )
IPCV_FILTER_SOBEL_BORDER( HorizSecond, 8u16s, uchar )
IPCV_FILTER_SOBEL_BORDER( Cross, 8u16s, uchar )
IPCV_FILTER_SOBEL_BORDER( NegVert, 32f, float )
IPCV_FILTER_SOBEL_BORDER( Horiz, 32f, float )
IPCV_FILTER_SOBEL_BORDER( VertSecond, 32f, float )
IPCV_FILTER_SOBEL_BORDER( HorizSecond, 32f, float )
IPCV_FILTER_SOBEL_BORDER( Cross, 32f, float )
#undef IPCV_FILTER_SOBEL_BORDER
#define IPCV_FILTER_SCHARR_BORDER( suffix, flavor, srctype ) \
IPCVAPI_EX( CvStatus, icvFilterScharr##suffix##GetBufSize_##flavor##_C1R, \
"ippiFilterScharr" #suffix "GetBufferSize_" #flavor "_C1R", \
CV_PLUGINS1(CV_PLUGIN_IPPCV), ( CvSize roi, int* buffersize )) \
IPCVAPI_EX( CvStatus, icvFilterScharr##suffix##Border_##flavor##_C1R, \
"ippiFilterScharr" #suffix "Border_" #flavor "_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const void* src, int srcstep, void* dst, int dststep, CvSize roi, \
int bordertype, srctype bordervalue, void* buffer ))
IPCV_FILTER_SCHARR_BORDER( Vert, 8u16s, uchar )
IPCV_FILTER_SCHARR_BORDER( Horiz, 8u16s, uchar )
IPCV_FILTER_SCHARR_BORDER( Vert, 32f, float )
IPCV_FILTER_SCHARR_BORDER( Horiz, 32f, float )
#undef IPCV_FILTER_SCHARR_BORDER
#define IPCV_FILTER_LAPLACIAN_BORDER( flavor, srctype ) \
IPCVAPI_EX( CvStatus, icvFilterLaplacianGetBufSize_##flavor##_C1R, \
"ippiFilterLaplacianGetBufferSize_" #flavor "_C1R", \
CV_PLUGINS1(CV_PLUGIN_IPPCV), ( CvSize roi, int masksize, int* buffersize )) \
IPCVAPI_EX( CvStatus, icvFilterLaplacianBorder_##flavor##_C1R, \
"ippiFilterLaplacianBorder_" #flavor "_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const void* src, int srcstep, void* dst, int dststep, CvSize roi, int masksize, \
int bordertype, srctype bordervalue, void* buffer ))
IPCV_FILTER_LAPLACIAN_BORDER( 8u16s, uchar )
IPCV_FILTER_LAPLACIAN_BORDER( 32f, float )
#undef IPCV_FILTER_LAPLACIAN_BORDER
/////////////////////////////////////////////////////////////////////////////////////////
#define IPCV_FILTER_SOBEL( suffix, ipp_suffix, flavor ) \
IPCVAPI_EX( CvStatus, icvFilterSobel##suffix##_##flavor##_C1R, \
"ippiFilterSobel" #ipp_suffix "_" #flavor "_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const void* src, int srcstep, void* dst, int dststep, CvSize roi, int aperture ))
IPCV_FILTER_SOBEL( Vert, Vert, 8u16s )
IPCV_FILTER_SOBEL( Horiz, Horiz, 8u16s )
IPCV_FILTER_SOBEL( VertSecond, VertSecond, 8u16s )
IPCV_FILTER_SOBEL( HorizSecond, HorizSecond, 8u16s )
IPCV_FILTER_SOBEL( Cross, Cross, 8u16s )
IPCV_FILTER_SOBEL( Vert, VertMask, 32f )
IPCV_FILTER_SOBEL( Horiz, HorizMask, 32f )
IPCV_FILTER_SOBEL( VertSecond, VertSecond, 32f )
IPCV_FILTER_SOBEL( HorizSecond, HorizSecond, 32f )
IPCV_FILTER_SOBEL( Cross, Cross, 32f )
#undef IPCV_FILTER_SOBEL
#define IPCV_FILTER_SCHARR( suffix, ipp_suffix, flavor ) \
IPCVAPI_EX( CvStatus, icvFilterScharr##suffix##_##flavor##_C1R, \
"ippiFilterScharr" #ipp_suffix "_" #flavor "_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const void* src, int srcstep, void* dst, int dststep, CvSize roi ))
IPCV_FILTER_SCHARR( Vert, Vert, 8u16s )
IPCV_FILTER_SCHARR( Horiz, Horiz, 8u16s )
IPCV_FILTER_SCHARR( Vert, Vert, 32f )
IPCV_FILTER_SCHARR( Horiz, Horiz, 32f )
#undef IPCV_FILTER_SCHARR
/****************************************************************************************\
* Generic Filters *
\****************************************************************************************/
#define IPCV_FILTER( suffix, ipp_suffix, cn, ksizetype, anchortype ) \
IPCVAPI_EX( CvStatus, icvFilter##suffix##_C##cn##R, \
"ippiFilter" #ipp_suffix "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const void* src, int srcstep, void* dst, int dststep, CvSize size, \
const float* kernel, ksizetype ksize, anchortype anchor ))
IPCV_FILTER( _8u, 32f_8u, 1, CvSize, CvPoint )
IPCV_FILTER( _8u, 32f_8u, 3, CvSize, CvPoint )
IPCV_FILTER( _8u, 32f_8u, 4, CvSize, CvPoint )
IPCV_FILTER( _16s, 32f_16s, 1, CvSize, CvPoint )
IPCV_FILTER( _16s, 32f_16s, 3, CvSize, CvPoint )
IPCV_FILTER( _16s, 32f_16s, 4, CvSize, CvPoint )
IPCV_FILTER( _32f, _32f, 1, CvSize, CvPoint )
IPCV_FILTER( _32f, _32f, 3, CvSize, CvPoint )
IPCV_FILTER( _32f, _32f, 4, CvSize, CvPoint )
IPCV_FILTER( Column_8u, Column32f_8u, 1, int, int )
IPCV_FILTER( Column_8u, Column32f_8u, 3, int, int )
IPCV_FILTER( Column_8u, Column32f_8u, 4, int, int )
IPCV_FILTER( Column_16s, Column32f_16s, 1, int, int )
IPCV_FILTER( Column_16s, Column32f_16s, 3, int, int )
IPCV_FILTER( Column_16s, Column32f_16s, 4, int, int )
IPCV_FILTER( Column_32f, Column_32f, 1, int, int )
IPCV_FILTER( Column_32f, Column_32f, 3, int, int )
IPCV_FILTER( Column_32f, Column_32f, 4, int, int )
IPCV_FILTER( Row_8u, Row32f_8u, 1, int, int )
IPCV_FILTER( Row_8u, Row32f_8u, 3, int, int )
IPCV_FILTER( Row_8u, Row32f_8u, 4, int, int )
IPCV_FILTER( Row_16s, Row32f_16s, 1, int, int )
IPCV_FILTER( Row_16s, Row32f_16s, 3, int, int )
IPCV_FILTER( Row_16s, Row32f_16s, 4, int, int )
IPCV_FILTER( Row_32f, Row_32f, 1, int, int )
IPCV_FILTER( Row_32f, Row_32f, 3, int, int )
IPCV_FILTER( Row_32f, Row_32f, 4, int, int )
#undef IPCV_FILTER
/****************************************************************************************\
* Color Transformations *
\****************************************************************************************/
#define IPCV_COLOR( funcname, ipp_funcname, flavor ) \
IPCVAPI_EX( CvStatus, icv##funcname##_##flavor##_C3R, \
"ippi" #ipp_funcname "_" #flavor "_C3R," \
"ippi" #ipp_funcname "_" #flavor "_C3R", \
CV_PLUGINS2(CV_PLUGIN_IPPI,CV_PLUGIN_IPPCC), \
( const void* src, int srcstep, void* dst, int dststep, CvSize size ))
IPCV_COLOR( RGB2XYZ, RGBToXYZ, 8u )
IPCV_COLOR( RGB2XYZ, RGBToXYZ, 16u )
IPCV_COLOR( RGB2XYZ, RGBToXYZ, 32f )
IPCV_COLOR( XYZ2RGB, XYZToRGB, 8u )
IPCV_COLOR( XYZ2RGB, XYZToRGB, 16u )
IPCV_COLOR( XYZ2RGB, XYZToRGB, 32f )
IPCV_COLOR( RGB2HSV, RGBToHSV, 8u )
IPCV_COLOR( HSV2RGB, HSVToRGB, 8u )
IPCV_COLOR( RGB2HLS, RGBToHLS, 8u )
IPCV_COLOR( RGB2HLS, RGBToHLS, 32f )
IPCV_COLOR( HLS2RGB, HLSToRGB, 8u )
IPCV_COLOR( HLS2RGB, HLSToRGB, 32f )
IPCV_COLOR( BGR2Lab, BGRToLab, 8u )
IPCV_COLOR( Lab2BGR, LabToBGR, 8u )
IPCV_COLOR( RGB2Luv, RGBToLUV, 8u )
/*IPCV_COLOR( RGB2Luv, RGBToLUV, 32f )*/
IPCV_COLOR( Luv2RGB, LUVToRGB, 8u )
/*IPCV_COLOR( Luv2RGB, LUVToRGB, 32f )*/
/****************************************************************************************\
* Motion Templates *
\****************************************************************************************/
IPCVAPI_EX( CvStatus, icvUpdateMotionHistory_8u32f_C1IR,
"ippiUpdateMotionHistory_8u32f_C1IR", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( const uchar* silIm, int silStep, float* mhiIm, int mhiStep,
CvSize size,float timestamp, float mhi_duration ))
/****************************************************************************************\
* Template Matching *
\****************************************************************************************/
#define ICV_MATCHTEMPLATE( flavor, arrtype ) \
IPCVAPI_EX( CvStatus, icvCrossCorrValid_Norm_##flavor##_C1R, \
"ippiCrossCorrValid_Norm_" #flavor "_C1R", \
CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const arrtype* pSrc, int srcStep, CvSize srcRoiSize, \
const arrtype* pTpl, int tplStep, CvSize tplRoiSize, \
float* pDst, int dstStep )) \
IPCVAPI_EX( CvStatus, icvCrossCorrValid_NormLevel_##flavor##_C1R, \
"ippiCrossCorrValid_NormLevel_" #flavor "_C1R", \
CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const arrtype* pSrc, int srcStep, CvSize srcRoiSize, \
const arrtype* pTpl, int tplStep, CvSize tplRoiSize, \
float* pDst, int dstStep )) \
IPCVAPI_EX( CvStatus, icvSqrDistanceValid_Norm_##flavor##_C1R, \
"ippiSqrDistanceValid_Norm_" #flavor "_C1R", \
CV_PLUGINS1(CV_PLUGIN_IPPI), \
( const arrtype* pSrc, int srcStep, CvSize srcRoiSize, \
const arrtype* pTpl, int tplStep, CvSize tplRoiSize, \
float* pDst, int dstStep ))
ICV_MATCHTEMPLATE( 8u32f, uchar )
ICV_MATCHTEMPLATE( 32f, float )
/****************************************************************************************/
/* Distance Transform */
/****************************************************************************************/
IPCVAPI_EX(CvStatus, icvDistanceTransform_3x3_8u32f_C1R,
"ippiDistanceTransform_3x3_8u32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( const uchar* pSrc, int srcStep, float* pDst,
int dstStep, CvSize roiSize, const float* pMetrics ))
IPCVAPI_EX(CvStatus, icvDistanceTransform_5x5_8u32f_C1R,
"ippiDistanceTransform_5x5_8u32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( const uchar* pSrc, int srcStep, float* pDst,
int dstStep, CvSize roiSize, const float* pMetrics ))
/****************************************************************************************\
* Thresholding functions *
\****************************************************************************************/
IPCVAPI_EX( CvStatus, icvCompareC_8u_C1R_cv,
"ippiCompareC_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
( const uchar* src1, int srcstep1, uchar scalar,
uchar* dst, int dststep, CvSize size, int cmp_op ))
IPCVAPI_EX( CvStatus, icvAndC_8u_C1R,
"ippiAndC_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
( const uchar* src1, int srcstep1, uchar scalar,
uchar* dst, int dststep, CvSize size ))
IPCVAPI_EX( CvStatus, icvThreshold_GTVal_8u_C1R,
"ippiThreshold_GTVal_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
( const uchar* pSrc, int srcstep, uchar* pDst, int dststep,
CvSize size, uchar threshold, uchar value ))
IPCVAPI_EX( CvStatus, icvThreshold_GTVal_32f_C1R,
"ippiThreshold_GTVal_32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
( const float* pSrc, int srcstep, float* pDst, int dststep,
CvSize size, float threshold, float value ))
IPCVAPI_EX( CvStatus, icvThreshold_LTVal_8u_C1R,
"ippiThreshold_LTVal_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
( const uchar* pSrc, int srcstep, uchar* pDst, int dststep,
CvSize size, uchar threshold, uchar value ))
IPCVAPI_EX( CvStatus, icvThreshold_LTVal_32f_C1R,
"ippiThreshold_LTVal_32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPI),
( const float* pSrc, int srcstep, float* pDst, int dststep,
CvSize size, float threshold, float value ))
/****************************************************************************************\
* Canny Edge Detector *
\****************************************************************************************/
IPCVAPI_EX( CvStatus, icvCannyGetSize, "ippiCannyGetSize", 0/*CV_PLUGINS1(CV_PLUGIN_IPPCV)*/,
( CvSize roiSize, int* bufferSize ))
IPCVAPI_EX( CvStatus, icvCanny_16s8u_C1R, "ippiCanny_16s8u_C1R", 0/*CV_PLUGINS1(CV_PLUGIN_IPPCV)*/,
( const short* pSrcDx, int srcDxStep, const short* pSrcDy, int srcDyStep,
uchar* pDstEdges, int dstEdgeStep, CvSize roiSize, float lowThresh,
float highThresh, void* pBuffer ))
/****************************************************************************************\
* Radial Distortion Removal *
\****************************************************************************************/
IPCVAPI_EX( CvStatus, icvUndistortGetSize, "ippiUndistortGetSize",
CV_PLUGINS1(CV_PLUGIN_IPPCV), ( CvSize roiSize, int *pBufsize ))
IPCVAPI_EX( CvStatus, icvCreateMapCameraUndistort_32f_C1R,
"ippiCreateMapCameraUndistort_32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
(float *pxMap, int xStep, float *pyMap, int yStep, CvSize roiSize,
float fx, float fy, float cx, float cy, float k1, float k2,
float p1, float p2, uchar *pBuffer ))
#define ICV_UNDISTORT_RADIAL( flavor, cn, arrtype ) \
IPCVAPI_EX( CvStatus, icvUndistortRadial_##flavor##_C##cn##R, \
"ippiUndistortRadial_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const arrtype* pSrc, int srcStep, uchar* pDst, int dstStep, CvSize roiSize, \
float fx, float fy, float cx, float cy, float k1, float k2, uchar *pBuffer ))
ICV_UNDISTORT_RADIAL( 8u, 1, uchar )
ICV_UNDISTORT_RADIAL( 8u, 3, uchar )
#undef ICV_UNDISTORT_RADIAL
/****************************************************************************************\
* Subpixel-accurate rectangle extraction *
\****************************************************************************************/
#define ICV_COPY_SUBPIX( flavor, cn, srctype, dsttype ) \
IPCVAPI_EX( CvStatus, icvCopySubpix_##flavor##_C##cn##R, \
"ippiCopySubpix_" #flavor "_C" #cn "R", CV_PLUGINS1(CV_PLUGIN_IPPCV), \
( const srctype* pSrc, int srcStep, dsttype* pDst, int dstStep, \
CvSize size, float dx, float dy ))
ICV_COPY_SUBPIX( 8u, 1, uchar, uchar )
ICV_COPY_SUBPIX( 8u32f, 1, uchar, float )
//ICV_COPY_SUBPIX( 32f, 1, float, float )
IPCVAPI_EX( CvStatus, icvCopySubpix_32f_C1R,
"ippiCopySubpix_32f_C1R", 0,
( const float* pSrc, int srcStep, float* pDst, int dstStep,
CvSize size, float dx, float dy ))
#undef ICV_COPY_SUBPIX
/****************************************************************************************\
* Lucas-Kanade Optical Flow *
\****************************************************************************************/
IPCVAPI_EX( CvStatus, icvOpticalFlowPyrLKInitAlloc_8u_C1R,
"ippiOpticalFlowPyrLKInitAlloc_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( void** ppState, CvSize roiSize, int winSize, int hint ))
IPCVAPI_EX( CvStatus, icvOpticalFlowPyrLKFree_8u_C1R,
"ippiOpticalFlowPyrLKFree_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( void* pState ))
IPCVAPI_EX( CvStatus, icvOpticalFlowPyrLK_8u_C1R,
"ippiOpticalFlowPyrLK_8u_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( CvPyramid *pPyr1, CvPyramid *pPyr2,
const float *pPrev, float* pNext, char *pStatus,
float *pError, int numFeat, int winSize,
int maxLev, int maxIter, float threshold, void* state ))
/****************************************************************************************\
* Haar Object Detector *
\****************************************************************************************/
IPCVAPI_EX( CvStatus, icvIntegral_8u32s_C1R,
"ippiIntegral_8u32s_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( const uchar* pSrc, int srcStep, int* pDst, int dstStep,
CvSize roiSize, int val ))
IPCVAPI_EX( CvStatus, icvSqrIntegral_8u32s64f_C1R,
"ippiSqrIntegral_8u32s64f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( const uchar* pSrc, int srcStep,
int* pDst, int dstStep, double* pSqr, int sqrStep,
CvSize roiSize, int val, double valSqr ))
IPCVAPI_EX( CvStatus, icvRectStdDev_32s32f_C1R,
"ippiRectStdDev_32s32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( const int* pSrc, int srcStep,
const double* pSqr, int sqrStep, float* pDst, int dstStep,
CvSize roiSize, CvRect rect ))
IPCVAPI_EX( CvStatus, icvHaarClassifierInitAlloc_32f,
"ippiHaarClassifierInitAlloc_32f", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( void **pState, const CvRect* pFeature, const float* pWeight,
const float* pThreshold, const float* pVal1,
const float* pVal2, const int* pNum, int length ))
IPCVAPI_EX( CvStatus, icvHaarClassifierFree_32f,
"ippiHaarClassifierFree_32f", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( void *pState ))
IPCVAPI_EX( CvStatus, icvApplyHaarClassifier_32s32f_C1R,
"ippiApplyHaarClassifier_32s32f_C1R", CV_PLUGINS1(CV_PLUGIN_IPPCV),
( const int* pSrc, int srcStep, const float* pNorm,
int normStep, uchar* pMask, int maskStep,
CvSize roi, int *pPositive, float threshold,
void *pState ))
#endif /*_CV_IPP_H_*/

View File

@@ -0,0 +1,373 @@
/*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 _CV_LIST_H_
#define _CV_LIST_H_
#include <stdlib.h>
#include <assert.h>
#define CV_FORCE_INLINE CV_INLINE
#if !defined(_LIST_INLINE)
#define _LIST_INLINE CV_FORCE_INLINE
#endif /*_LIST_INLINE*/
#if defined DECLARE_LIST
#if defined _MSC_VER && _MSC_VER >= 1200
#pragma warning("DECLARE_LIST macro is already defined!")
#endif
#endif /*DECLARE_LIST*/
static const long default_size = 10;
static const long default_inc_size = 10;
struct _pos
{
void* m_pos;
#ifdef _DEBUG
struct _list* m_list;
#endif /*_DEBUG*/
};
typedef struct _pos CVPOS;
struct _list
{
void* m_buffer;
void* m_first_buffer;
long m_buf_size; /* The size of the buffer */
long m_size; /* The number of elements */
CVPOS m_head;
CVPOS m_tail;
CVPOS m_head_free;
};
typedef struct _list _CVLIST;
#define DECLARE_LIST(type, prefix)\
/* Basic element of a list*/\
struct prefix##element_##type\
{\
struct prefix##element_##type* m_prev;\
struct prefix##element_##type* m_next;\
type m_data;\
};\
typedef struct prefix##element_##type ELEMENT_##type;\
/* Initialization and destruction*/\
_LIST_INLINE _CVLIST* prefix##create_list_##type(long);\
_LIST_INLINE void prefix##destroy_list_##type(_CVLIST*);\
/* Access functions*/\
_LIST_INLINE CVPOS prefix##get_head_pos_##type(_CVLIST*);\
_LIST_INLINE CVPOS prefix##get_tail_pos_##type(_CVLIST*);\
_LIST_INLINE type* prefix##get_next_##type(CVPOS*);\
_LIST_INLINE type* prefix##get_prev_##type(CVPOS*);\
/* Modification functions*/\
_LIST_INLINE void prefix##clear_list_##type(_CVLIST*);\
_LIST_INLINE CVPOS prefix##add_head_##type(_CVLIST*, type*);\
_LIST_INLINE CVPOS prefix##add_tail_##type(_CVLIST*, type*);\
_LIST_INLINE void prefix##remove_head_##type(_CVLIST*);\
_LIST_INLINE void prefix##remove_tail_##type(_CVLIST*);\
_LIST_INLINE CVPOS prefix##insert_before_##type(_CVLIST*, CVPOS, type*);\
_LIST_INLINE CVPOS prefix##insert_after_##type(_CVLIST*, CVPOS, type*);\
_LIST_INLINE void prefix##remove_at_##type(_CVLIST*, CVPOS);\
_LIST_INLINE void prefix##set_##type(CVPOS, type*);\
_LIST_INLINE type* prefix##get_##type(CVPOS);\
/* Statistics functions*/\
_LIST_INLINE int prefix##get_count_##type(_CVLIST*);
/* This macro finds a space for a new element and puts in into 'element' pointer */
#define INSERT_NEW(element_type, l, element)\
l->m_size++;\
if(l->m_head_free.m_pos != NULL)\
{\
element = (element_type*)(l->m_head_free.m_pos);\
if(element->m_next != NULL)\
{\
element->m_next->m_prev = NULL;\
l->m_head_free.m_pos = element->m_next;\
}\
else\
{\
l->m_head_free.m_pos = NULL;\
}\
}\
else\
{\
if(l->m_buf_size < l->m_size && l->m_head_free.m_pos == NULL)\
{\
*(void**)l->m_buffer = cvAlloc(l->m_buf_size*sizeof(element_type) + sizeof(void*));\
l->m_buffer = *(void**)l->m_buffer;\
*(void**)l->m_buffer = NULL;\
element = (element_type*)((char*)l->m_buffer + sizeof(void*));\
}\
else\
{\
element = (element_type*)((char*)l->m_buffer + sizeof(void*)) + l->m_size - 1;\
}\
}
/* This macro adds 'element' to the list of free elements*/
#define INSERT_FREE(element_type, l, element)\
if(l->m_head_free.m_pos != NULL)\
{\
((element_type*)l->m_head_free.m_pos)->m_prev = element;\
}\
element->m_next = ((element_type*)l->m_head_free.m_pos);\
l->m_head_free.m_pos = element;
/*#define GET_FIRST_FREE(l) ((ELEMENT_##type*)(l->m_head_free.m_pos))*/
#define IMPLEMENT_LIST(type, prefix)\
_CVLIST* prefix##create_list_##type(long size)\
{\
_CVLIST* pl = (_CVLIST*)cvAlloc(sizeof(_CVLIST));\
pl->m_buf_size = size > 0 ? size : default_size;\
pl->m_first_buffer = cvAlloc(pl->m_buf_size*sizeof(ELEMENT_##type) + sizeof(void*));\
pl->m_buffer = pl->m_first_buffer;\
*(void**)pl->m_buffer = NULL;\
pl->m_size = 0;\
pl->m_head.m_pos = NULL;\
pl->m_tail.m_pos = NULL;\
pl->m_head_free.m_pos = NULL;\
return pl;\
}\
void prefix##destroy_list_##type(_CVLIST* l)\
{\
void* cur = l->m_first_buffer;\
void* next;\
while(cur)\
{\
next = *(void**)cur;\
cvFree(&cur);\
cur = next;\
}\
cvFree(&l);\
}\
CVPOS prefix##get_head_pos_##type(_CVLIST* l)\
{\
return l->m_head;\
}\
CVPOS prefix##get_tail_pos_##type(_CVLIST* l)\
{\
return l->m_tail;\
}\
type* prefix##get_next_##type(CVPOS* pos)\
{\
if(pos->m_pos)\
{\
ELEMENT_##type* element = (ELEMENT_##type*)(pos->m_pos);\
pos->m_pos = element->m_next;\
return &element->m_data;\
}\
else\
{\
return NULL;\
}\
}\
type* prefix##get_prev_##type(CVPOS* pos)\
{\
if(pos->m_pos)\
{\
ELEMENT_##type* element = (ELEMENT_##type*)(pos->m_pos);\
pos->m_pos = element->m_prev;\
return &element->m_data;\
}\
else\
{\
return NULL;\
}\
}\
int prefix##is_pos_##type(CVPOS pos)\
{\
return !!pos.m_pos;\
}\
void prefix##clear_list_##type(_CVLIST* l)\
{\
l->m_head.m_pos = NULL;\
l->m_tail.m_pos = NULL;\
l->m_size = 0;\
l->m_head_free.m_pos = NULL;\
}\
CVPOS prefix##add_head_##type(_CVLIST* l, type* data)\
{\
ELEMENT_##type* element;\
INSERT_NEW(ELEMENT_##type, l, element);\
element->m_prev = NULL;\
element->m_next = (ELEMENT_##type*)(l->m_head.m_pos);\
memcpy(&(element->m_data), data, sizeof(*data));\
if(element->m_next)\
{\
element->m_next->m_prev = element;\
}\
else\
{\
l->m_tail.m_pos = element;\
}\
l->m_head.m_pos = element;\
return l->m_head;\
}\
CVPOS prefix##add_tail_##type(_CVLIST* l, type* data)\
{\
ELEMENT_##type* element;\
INSERT_NEW(ELEMENT_##type, l, element);\
element->m_next = NULL;\
element->m_prev = (ELEMENT_##type*)(l->m_tail.m_pos);\
memcpy(&(element->m_data), data, sizeof(*data));\
if(element->m_prev)\
{\
element->m_prev->m_next = element;\
}\
else\
{\
l->m_head.m_pos = element;\
}\
l->m_tail.m_pos = element;\
return l->m_tail;\
}\
void prefix##remove_head_##type(_CVLIST* l)\
{\
ELEMENT_##type* element = ((ELEMENT_##type*)(l->m_head.m_pos));\
if(element->m_next != NULL)\
{\
element->m_next->m_prev = NULL;\
}\
l->m_head.m_pos = element->m_next;\
INSERT_FREE(ELEMENT_##type, l, element);\
l->m_size--;\
}\
void prefix##remove_tail_##type(_CVLIST* l)\
{\
ELEMENT_##type* element = ((ELEMENT_##type*)(l->m_tail.m_pos));\
if(element->m_prev != NULL)\
{\
element->m_prev->m_next = NULL;\
}\
l->m_tail.m_pos = element->m_prev;\
INSERT_FREE(ELEMENT_##type, l, element);\
l->m_size--;\
}\
CVPOS prefix##insert_after_##type(_CVLIST* l, CVPOS pos, type* data)\
{\
ELEMENT_##type* element;\
ELEMENT_##type* before;\
CVPOS newpos;\
INSERT_NEW(ELEMENT_##type, l, element);\
memcpy(&(element->m_data), data, sizeof(*data));\
before = (ELEMENT_##type*)pos.m_pos;\
element->m_prev = before;\
element->m_next = before->m_next;\
before->m_next = element;\
if(element->m_next != NULL)\
element->m_next->m_prev = element;\
else\
l->m_tail.m_pos = element;\
newpos.m_pos = element;\
return newpos;\
}\
CVPOS prefix##insert_before_##type(_CVLIST* l, CVPOS pos, type* data)\
{\
ELEMENT_##type* element;\
ELEMENT_##type* after;\
CVPOS newpos;\
INSERT_NEW(ELEMENT_##type, l, element);\
memcpy(&(element->m_data), data, sizeof(*data));\
after = (ELEMENT_##type*)pos.m_pos;\
element->m_prev = after->m_prev;\
element->m_next = after;\
after->m_prev = element;\
if(element->m_prev != NULL)\
element->m_prev->m_next = element;\
else\
l->m_head.m_pos = element;\
newpos.m_pos = element;\
return newpos;\
}\
void prefix##remove_at_##type(_CVLIST* l, CVPOS pos)\
{\
ELEMENT_##type* element = ((ELEMENT_##type*)pos.m_pos);\
if(element->m_prev != NULL)\
{\
element->m_prev->m_next = element->m_next;\
}\
else\
{\
l->m_head.m_pos = element->m_next;\
}\
if(element->m_next != NULL)\
{\
element->m_next->m_prev = element->m_prev;\
}\
else\
{\
l->m_tail.m_pos = element->m_prev;\
}\
INSERT_FREE(ELEMENT_##type, l, element);\
l->m_size--;\
}\
void prefix##set_##type(CVPOS pos, type* data)\
{\
ELEMENT_##type* element = ((ELEMENT_##type*)(pos.m_pos));\
memcpy(&(element->m_data), data, sizeof(data));\
}\
type* prefix##get_##type(CVPOS pos)\
{\
ELEMENT_##type* element = ((ELEMENT_##type*)(pos.m_pos));\
return &(element->m_data);\
}\
int prefix##get_count_##type(_CVLIST* list)\
{\
return list->m_size;\
}
#define DECLARE_AND_IMPLEMENT_LIST(type, prefix)\
DECLARE_LIST(type, prefix)\
IMPLEMENT_LIST(type, prefix)
typedef struct __index
{
int value;
float rho, theta;
}
_index;
DECLARE_LIST( _index, h_ )
#endif/*_CV_LIST_H_*/

View File

@@ -0,0 +1,405 @@
/*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 _CV_MATRIX_H_
#define _CV_MATRIX_H_
#define icvCopyVector( src, dst, len ) memcpy( (dst), (src), (len)*sizeof((dst)[0]))
#define icvSetZero( dst, len ) memset( (dst), 0, (len)*sizeof((dst)[0]))
#define icvCopyVector_32f( src, len, dst ) memcpy((dst),(src),(len)*sizeof(float))
#define icvSetZero_32f( dst, cols, rows ) memset((dst),0,(rows)*(cols)*sizeof(float))
#define icvCopyVector_64d( src, len, dst ) memcpy((dst),(src),(len)*sizeof(double))
#define icvSetZero_64d( dst, cols, rows ) memset((dst),0,(rows)*(cols)*sizeof(double))
#define icvCopyMatrix_32f( src, w, h, dst ) memcpy((dst),(src),(w)*(h)*sizeof(float))
#define icvCopyMatrix_64d( src, w, h, dst ) memcpy((dst),(src),(w)*(h)*sizeof(double))
#define icvCreateVector_32f( len ) (float*)cvAlloc( (len)*sizeof(float))
#define icvCreateVector_64d( len ) (double*)cvAlloc( (len)*sizeof(double))
#define icvCreateMatrix_32f( w, h ) (float*)cvAlloc( (w)*(h)*sizeof(float))
#define icvCreateMatrix_64d( w, h ) (double*)cvAlloc( (w)*(h)*sizeof(double))
#define icvDeleteVector( vec ) cvFree( &(vec) )
#define icvDeleteMatrix icvDeleteVector
#define icvAddMatrix_32f( src1, src2, dst, w, h ) \
icvAddVector_32f( (src1), (src2), (dst), (w)*(h))
#define icvSubMatrix_32f( src1, src2, dst, w, h ) \
icvSubVector_32f( (src1), (src2), (dst), (w)*(h))
#define icvNormVector_32f( src, len ) \
sqrt(icvDotProduct_32f( src, src, len ))
#define icvNormVector_64d( src, len ) \
sqrt(icvDotProduct_64d( src, src, len ))
#define icvDeleteMatrix icvDeleteVector
#define icvCheckVector_64f( ptr, len )
#define icvCheckVector_32f( ptr, len )
CV_INLINE double icvSum_32f( const float* src, int len )
{
double s = 0;
for( int i = 0; i < len; i++ ) s += src[i];
icvCheckVector_64f( &s, 1 );
return s;
}
CV_INLINE double icvDotProduct_32f( const float* src1, const float* src2, int len )
{
double s = 0;
for( int i = 0; i < len; i++ ) s += src1[i]*src2[i];
icvCheckVector_64f( &s, 1 );
return s;
}
CV_INLINE double icvDotProduct_64f( const double* src1, const double* src2, int len )
{
double s = 0;
for( int i = 0; i < len; i++ ) s += src1[i]*src2[i];
icvCheckVector_64f( &s, 1 );
return s;
}
CV_INLINE void icvMulVectors_32f( const float* src1, const float* src2,
float* dst, int len )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = src1[i] * src2[i];
icvCheckVector_32f( dst, len );
}
CV_INLINE void icvMulVectors_64d( const double* src1, const double* src2,
double* dst, int len )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = src1[i] * src2[i];
icvCheckVector_64f( dst, len );
}
CV_INLINE void icvAddVector_32f( const float* src1, const float* src2,
float* dst, int len )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = src1[i] + src2[i];
icvCheckVector_32f( dst, len );
}
CV_INLINE void icvAddVector_64d( const double* src1, const double* src2,
double* dst, int len )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = src1[i] + src2[i];
icvCheckVector_64f( dst, len );
}
CV_INLINE void icvSubVector_32f( const float* src1, const float* src2,
float* dst, int len )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = src1[i] - src2[i];
icvCheckVector_32f( dst, len );
}
CV_INLINE void icvSubVector_64d( const double* src1, const double* src2,
double* dst, int len )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = src1[i] - src2[i];
icvCheckVector_64f( dst, len );
}
#define icvAddMatrix_64d( src1, src2, dst, w, h ) \
icvAddVector_64d( (src1), (src2), (dst), (w)*(h))
#define icvSubMatrix_64d( src1, src2, dst, w, h ) \
icvSubVector_64d( (src1), (src2), (dst), (w)*(h))
CV_INLINE void icvSetIdentity_32f( float* dst, int w, int h )
{
int i, len = MIN( w, h );
icvSetZero_32f( dst, w, h );
for( i = 0; len--; i += w+1 )
dst[i] = 1.f;
}
CV_INLINE void icvSetIdentity_64d( double* dst, int w, int h )
{
int i, len = MIN( w, h );
icvSetZero_64d( dst, w, h );
for( i = 0; len--; i += w+1 )
dst[i] = 1.;
}
CV_INLINE void icvTrace_32f( const float* src, int w, int h, float* trace )
{
int i, len = MIN( w, h );
double sum = 0;
for( i = 0; len--; i += w+1 )
sum += src[i];
*trace = (float)sum;
icvCheckVector_64f( &sum, 1 );
}
CV_INLINE void icvTrace_64d( const double* src, int w, int h, double* trace )
{
int i, len = MIN( w, h );
double sum = 0;
for( i = 0; len--; i += w+1 )
sum += src[i];
*trace = sum;
icvCheckVector_64f( &sum, 1 );
}
CV_INLINE void icvScaleVector_32f( const float* src, float* dst,
int len, double scale )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = (float)(src[i]*scale);
icvCheckVector_32f( dst, len );
}
CV_INLINE void icvScaleVector_64d( const double* src, double* dst,
int len, double scale )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = src[i]*scale;
icvCheckVector_64f( dst, len );
}
CV_INLINE void icvTransposeMatrix_32f( const float* src, int w, int h, float* dst )
{
int i, j;
for( i = 0; i < w; i++ )
for( j = 0; j < h; j++ )
*dst++ = src[j*w + i];
icvCheckVector_32f( dst, w*h );
}
CV_INLINE void icvTransposeMatrix_64d( const double* src, int w, int h, double* dst )
{
int i, j;
for( i = 0; i < w; i++ )
for( j = 0; j < h; j++ )
*dst++ = src[j*w + i];
icvCheckVector_64f( dst, w*h );
}
CV_INLINE void icvDetMatrix3x3_64d( const double* mat, double* det )
{
#define m(y,x) mat[(y)*3 + (x)]
*det = m(0,0)*(m(1,1)*m(2,2) - m(1,2)*m(2,1)) -
m(0,1)*(m(1,0)*m(2,2) - m(1,2)*m(2,0)) +
m(0,2)*(m(1,0)*m(2,1) - m(1,1)*m(2,0));
#undef m
icvCheckVector_64f( det, 1 );
}
CV_INLINE void icvMulMatrix_32f( const float* src1, int w1, int h1,
const float* src2, int w2, int h2,
float* dst )
{
int i, j, k;
if( w1 != h2 )
{
assert(0);
return;
}
for( i = 0; i < h1; i++, src1 += w1, dst += w2 )
for( j = 0; j < w2; j++ )
{
double s = 0;
for( k = 0; k < w1; k++ )
s += src1[k]*src2[j + k*w2];
dst[j] = (float)s;
}
icvCheckVector_32f( dst, h1*w2 );
}
CV_INLINE void icvMulMatrix_64d( const double* src1, int w1, int h1,
const double* src2, int w2, int h2,
double* dst )
{
int i, j, k;
if( w1 != h2 )
{
assert(0);
return;
}
for( i = 0; i < h1; i++, src1 += w1, dst += w2 )
for( j = 0; j < w2; j++ )
{
double s = 0;
for( k = 0; k < w1; k++ )
s += src1[k]*src2[j + k*w2];
dst[j] = s;
}
icvCheckVector_64f( dst, h1*w2 );
}
#define icvTransformVector_32f( matr, src, dst, w, h ) \
icvMulMatrix_32f( matr, w, h, src, 1, w, dst )
#define icvTransformVector_64d( matr, src, dst, w, h ) \
icvMulMatrix_64d( matr, w, h, src, 1, w, dst )
#define icvScaleMatrix_32f( src, dst, w, h, scale ) \
icvScaleVector_32f( (src), (dst), (w)*(h), (scale) )
#define icvScaleMatrix_64d( src, dst, w, h, scale ) \
icvScaleVector_64d( (src), (dst), (w)*(h), (scale) )
#define icvDotProduct_64d icvDotProduct_64f
CV_INLINE void icvInvertMatrix_64d( double* A, int n, double* invA )
{
CvMat Am = cvMat( n, n, CV_64F, A );
CvMat invAm = cvMat( n, n, CV_64F, invA );
cvInvert( &Am, &invAm, CV_SVD );
}
CV_INLINE void icvMulTransMatrixR_64d( double* src, int width, int height, double* dst )
{
CvMat srcMat = cvMat( height, width, CV_64F, src );
CvMat dstMat = cvMat( width, width, CV_64F, dst );
cvMulTransposed( &srcMat, &dstMat, 1 );
}
CV_INLINE void icvMulTransMatrixL_64d( double* src, int width, int height, double* dst )
{
CvMat srcMat = cvMat( height, width, CV_64F, src );
CvMat dstMat = cvMat( height, height, CV_64F, dst );
cvMulTransposed( &srcMat, &dstMat, 0 );
}
CV_INLINE void icvMulTransMatrixR_32f( float* src, int width, int height, float* dst )
{
CvMat srcMat = cvMat( height, width, CV_32F, src );
CvMat dstMat = cvMat( width, width, CV_32F, dst );
cvMulTransposed( &srcMat, &dstMat, 1 );
}
CV_INLINE void icvMulTransMatrixL_32f( float* src, int width, int height, float* dst )
{
CvMat srcMat = cvMat( height, width, CV_32F, src );
CvMat dstMat = cvMat( height, height, CV_32F, dst );
cvMulTransposed( &srcMat, &dstMat, 0 );
}
CV_INLINE void icvCvt_32f_64d( const float* src, double* dst, int len )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = src[i];
}
CV_INLINE void icvCvt_64d_32f( const double* src, float* dst, int len )
{
int i;
for( i = 0; i < len; i++ )
dst[i] = (float)src[i];
}
#endif/*_CV_MATRIX_H_*/
/* End of file. */

View File

@@ -0,0 +1,544 @@
# Microsoft Developer Studio Project File - Name="cv" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=cv - Win32 Debug64 Itanium
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "cv.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "cv.mak" CFG="cv - Win32 Debug64 Itanium"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "cv - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "cv - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "cv - Win32 Release64" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "cv - Win32 Debug64" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "cv - Win32 Release64 Itanium" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "cv - Win32 Debug64 Itanium" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=xicl6.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "cv - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\_temp\CV_Rls"
# PROP Intermediate_Dir "..\..\_temp\CV_Rls"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /G6 /MD /W4 /Zi /O2 /Ob2 /I "..\..\cxcore\include" /I "." /I "..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "CVAPI_EXPORTS" /FR /Yu"_cv.h" /FD /Zm200 /Qopenmp /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib cxcore.lib /nologo /subsystem:windows /dll /pdb:"..\..\bin/cv100.pdb" /debug /machine:I386 /nodefaultlib:"libmmd.lib" /out:"..\..\bin\cv100.dll" /implib:"../../lib/cv.lib" /libpath:"..\..\lib"
# SUBTRACT LINK32 /profile /pdb:none /map
!ELSEIF "$(CFG)" == "cv - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\_temp\CV_Dbg"
# PROP Intermediate_Dir "..\..\_temp\CV_Dbg"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /G6 /MDd /W4 /Gm /Zi /Od /I "..\..\cxcore\include" /I "." /I "..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "CVAPI_EXPORTS" /FR /Yu"_cv.h" /FD /GZ /Zm200 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib cxcored.lib /nologo /subsystem:windows /dll /pdb:"..\..\bin/cv100d.pdb" /debug /machine:I386 /nodefaultlib:"libmmdd.lib" /out:"..\..\bin\cv100d.dll" /implib:"../../lib/cvd.lib" /libpath:"..\..\lib"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "cv - Win32 Release64"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "cv___Win32_Release64"
# PROP BASE Intermediate_Dir "cv___Win32_Release64"
# PROP BASE Ignore_Export_Lib 1
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\_temp\cv_Rls64"
# PROP Intermediate_Dir "..\..\_temp\cv_Rls64"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE CPP /nologo /G6 /MD /W4 /Zi /O2 /Ob2 /I "..\..\cxcore\include" /I "." /I "..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "CVAPI_EXPORTS" /FR /Yu"_cv.h" /FD /Zm200 /c
# ADD CPP /nologo /MD /W4 /Zi /O2 /Ob2 /I "..\..\cxcore\include" /I "." /I "..\include" /D "_WINDOWS" /D "CVAPI_EXPORTS" /D "NDEBUG" /D "WIN32" /D "WIN64" /D "EM64T" /FR /Yu"_cv.h" /FD /Zm200 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib cxcore.lib /nologo /subsystem:windows /dll /debug /machine:IX86 /nodefaultlib:"libmmd.lib" /out:"..\..\bin\cv100.dll" /implib:"../../lib/cv.lib" /libpath:"..\..\lib" /machine:AMD64
# SUBTRACT BASE LINK32 /profile /map
# ADD LINK32 kernel32.lib user32.lib gdi32.lib cxcore_64.lib /nologo /subsystem:windows /dll /debug /machine:IX86 /nodefaultlib:"libmmd.lib" /out:"..\..\bin\cv100_64.dll" /implib:"../../lib/cv_64.lib" /libpath:"..\..\lib" /machine:AMD64
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "cv - Win32 Debug64"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "cv___Win32_Debug64"
# PROP BASE Intermediate_Dir "cv___Win32_Debug64"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\_temp\cv_Dbg64"
# PROP Intermediate_Dir "..\..\_temp\cv_Dbg64"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE CPP /nologo /G6 /MDd /W4 /Gm /Zi /Od /I "..\..\cxcore\include" /I "." /I "..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "CVAPI_EXPORTS" /FR /Yu"_cv.h" /FD /GZ /Zm200 /c
# ADD CPP /nologo /MDd /W4 /Gm /Zi /Od /I "..\..\cxcore\include" /I "." /I "..\include" /D "_WINDOWS" /D "CVAPI_EXPORTS" /D "_DEBUG" /D "WIN32" /D "WIN64" /D "EM64T" /FR /Yu"_cv.h" /FD /Zm200 /Wp64 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib cxcored.lib /nologo /subsystem:windows /dll /debug /machine:IX86 /nodefaultlib:"libmmdd.lib" /out:"..\..\bin\cv100d.dll" /implib:"../../lib/cvd.lib" /libpath:"..\..\lib" /machine:AMD64
# SUBTRACT BASE LINK32 /pdb:none
# ADD LINK32 kernel32.lib user32.lib gdi32.lib cxcored_64.lib /nologo /subsystem:windows /dll /pdb:"..\..\bin/cv100d_64.pdb" /debug /machine:IX86 /nodefaultlib:"libmmdd.lib" /out:"..\..\bin\cv100d_64.dll" /implib:"../../lib/cvd_64.lib" /libpath:"..\..\lib" /machine:AMD64
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "cv - Win32 Release64 Itanium"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "cv___Win32_Release64_Itanium"
# PROP BASE Intermediate_Dir "cv___Win32_Release64_Itanium"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\_temp\cv_RlsI7"
# PROP Intermediate_Dir "..\..\_temp\cv_RlsI7"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE CPP /nologo /MD /W4 /Zi /O2 /Ob2 /I "..\..\cxcore\include" /I "." /I "..\include" /D "_WINDOWS" /D "CVAPI_EXPORTS" /D "NDEBUG" /D "WIN32" /D "WIN64" /FR /Yu"_cv.h" /FD /Zm200 /c
# ADD CPP /nologo /MD /w /W0 /Zi /O2 /Ob2 /I "..\..\cxcore\include" /I "." /I "..\include" /D "_WINDOWS" /D "CVAPI_EXPORTS" /D "NDEBUG" /D "WIN32" /D "WIN64" /FR /Yu"_cv.h" /FD /Zm200 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib cxcore_i7.lib /nologo /subsystem:windows /dll /debug /machine:IX86 /nodefaultlib:"libmmd.lib" /out:"..\..\bin\cv100_i7.dll" /implib:"../../lib/cv_i7.lib" /libpath:"..\..\lib" /machine:IA64
# SUBTRACT BASE LINK32 /pdb:none
# ADD LINK32 kernel32.lib user32.lib gdi32.lib cxcore_i7.lib /nologo /subsystem:windows /dll /debug /machine:IX86 /out:"..\..\bin\cv100_i7.dll" /implib:"../../lib/cv_i7.lib" /libpath:"..\..\lib" /machine:IA64
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "cv - Win32 Debug64 Itanium"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "cv___Win32_Debug64_Itanium"
# PROP BASE Intermediate_Dir "cv___Win32_Debug64_Itanium"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\_temp\cv_DbgI7"
# PROP Intermediate_Dir "..\..\_temp\cv_DbgI7"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE CPP /nologo /MDd /W4 /Gm /Zi /Od /I "..\..\cxcore\include" /I "." /I "..\include" /D "_WINDOWS" /D "CVAPI_EXPORTS" /D "_DEBUG" /D "WIN32" /D "WIN64" /D "EM64T" /FR /Yu"_cv.h" /FD /Zm200 /Wp64 /c
# ADD CPP /nologo /MDd /W3 /Gm /Zi /Od /I "..\..\cxcore\include" /I "." /I "..\include" /D "_WINDOWS" /D "CVAPI_EXPORTS" /D "_DEBUG" /D "WIN32" /D "WIN64" /FR /Yu"_cv.h" /FD /Zm200 /Qwd167 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib cxcored_i7.lib /nologo /subsystem:windows /dll /pdb:"..\..\bin/cv100d_i7.pdb" /debug /machine:IX86 /nodefaultlib:"libmmdd.lib" /out:"..\..\bin\cv100d_i7.dll" /implib:"../../lib/cvd_i7.lib" /libpath:"..\..\lib" /machine:IA64
# SUBTRACT BASE LINK32 /pdb:none
# ADD LINK32 kernel32.lib user32.lib gdi32.lib cxcored_i7.lib /nologo /subsystem:windows /dll /pdb:"..\..\bin/cv100d_i7.pdb" /debug /machine:IX86 /out:"..\..\bin\cv100d_i7.dll" /implib:"../../lib/cvd_i7.lib" /libpath:"..\..\lib" /machine:IA64
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "cv - Win32 Release"
# Name "cv - Win32 Debug"
# Name "cv - Win32 Release64"
# Name "cv - Win32 Debug64"
# Name "cv - Win32 Release64 Itanium"
# Name "cv - Win32 Debug64 Itanium"
# Begin Group "Src"
# PROP Default_Filter ""
# Begin Group "ImageProcessing"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\cvadapthresh.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcalccontrasthistogram.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcanny.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcolor.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcontours.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcorner.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcornersubpix.cpp
# End Source File
# Begin Source File
SOURCE=.\cvderiv.cpp
# End Source File
# Begin Source File
SOURCE=.\cvfeatureselect.cpp
# End Source File
# Begin Source File
SOURCE=.\cvfilter.cpp
# End Source File
# Begin Source File
SOURCE=.\cvfloodfill.cpp
# End Source File
# Begin Source File
SOURCE=.\cvhistogram.cpp
# End Source File
# Begin Source File
SOURCE=.\cvimgwarp.cpp
# End Source File
# Begin Source File
SOURCE=.\cvinpaint.cpp
# End Source File
# Begin Source File
SOURCE=.\cvmoments.cpp
# End Source File
# Begin Source File
SOURCE=.\cvmorph.cpp
# End Source File
# Begin Source File
SOURCE=.\cvpyramids.cpp
# End Source File
# Begin Source File
SOURCE=.\cvsamplers.cpp
# End Source File
# Begin Source File
SOURCE=.\cvsegmentation.cpp
# End Source File
# Begin Source File
SOURCE=.\cvsmooth.cpp
# End Source File
# Begin Source File
SOURCE=.\cvtemplmatch.cpp
# End Source File
# Begin Source File
SOURCE=.\cvthresh.cpp
# End Source File
# End Group
# Begin Group "StructuralAnalysis"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\cvapprox.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcontourtree.cpp
# End Source File
# Begin Source File
SOURCE=.\cvconvhull.cpp
# End Source File
# Begin Source File
SOURCE=.\cvdistransform.cpp
# End Source File
# Begin Source File
SOURCE=.\cvdominants.cpp
# End Source File
# Begin Source File
SOURCE=.\cvemd.cpp
# End Source File
# Begin Source File
SOURCE=.\cvgeometry.cpp
# End Source File
# Begin Source File
SOURCE=.\cvhough.cpp
# End Source File
# Begin Source File
SOURCE=.\cvlinefit.cpp
# End Source File
# Begin Source File
SOURCE=.\cvmatchcontours.cpp
# End Source File
# Begin Source File
SOURCE=.\cvpgh.cpp
# End Source File
# Begin Source File
SOURCE=.\cvpyrsegmentation.cpp
# End Source File
# Begin Source File
SOURCE=.\cvrotcalipers.cpp
# End Source File
# Begin Source File
SOURCE=.\cvshapedescr.cpp
# End Source File
# Begin Source File
SOURCE=.\cvsubdivision2d.cpp
# End Source File
# End Group
# Begin Group "MotionAndTracking"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\cvcamshift.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcondens.cpp
# End Source File
# Begin Source File
SOURCE=.\cvkalman.cpp
# End Source File
# Begin Source File
SOURCE=.\cvlkpyramid.cpp
# End Source File
# Begin Source File
SOURCE=.\cvmotempl.cpp
# End Source File
# Begin Source File
SOURCE=.\cvoptflowbm.cpp
# End Source File
# Begin Source File
SOURCE=.\cvoptflowhs.cpp
# End Source File
# Begin Source File
SOURCE=.\cvoptflowlk.cpp
# End Source File
# Begin Source File
SOURCE=.\cvsnakes.cpp
# End Source File
# End Group
# Begin Group "3D"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\cvcalcimagehomography.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcalibinit.cpp
# End Source File
# Begin Source File
SOURCE=.\cvcalibration.cpp
# End Source File
# Begin Source File
SOURCE=.\cvfundam.cpp
# End Source File
# Begin Source File
SOURCE=.\cvposit.cpp
# End Source File
# Begin Source File
SOURCE=.\cvundistort.cpp
# End Source File
# End Group
# Begin Group "PatternRecognition"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\cvhaar.cpp
# End Source File
# End Group
# Begin Group "CoreEx"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\cvaccum.cpp
# End Source File
# Begin Source File
SOURCE=.\cvsumpixels.cpp
# End Source File
# Begin Source File
SOURCE=.\cvswitcher.cpp
# End Source File
# Begin Source File
SOURCE=.\cvtables.cpp
# End Source File
# Begin Source File
SOURCE=.\cvutils.cpp
# End Source File
# End Group
# Begin Source File
SOURCE=.\cv.rc
# End Source File
# Begin Source File
SOURCE=.\cvprecomp.cpp
# ADD CPP /Yc"_cv.h"
# End Source File
# End Group
# Begin Group "Include"
# PROP Default_Filter ""
# Begin Group "External"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\include\cv.h
# End Source File
# Begin Source File
SOURCE=..\include\cv.hpp
# End Source File
# Begin Source File
SOURCE=..\include\cvcompat.h
# End Source File
# Begin Source File
SOURCE=..\include\cvtypes.h
# End Source File
# End Group
# Begin Group "Internal"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\_cv.h
# End Source File
# Begin Source File
SOURCE=.\_cvgeom.h
# End Source File
# Begin Source File
SOURCE=.\_cvimgproc.h
# End Source File
# Begin Source File
SOURCE=.\_cvipp.h
# End Source File
# Begin Source File
SOURCE=.\_cvlist.h
# End Source File
# Begin Source File
SOURCE=.\_cvmatrix.h
# End Source File
# End Group
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,121 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Russian resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
#ifdef _WIN32
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // Russian resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Intel® Open Source Computer Vision Library: The vision part.\0"
VALUE "CompanyName", "Intel Corporation.\0"
VALUE "FileDescription", "The vision component of OpenCV\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "cv100.dll\0"
VALUE "LegalCopyright", "Copyright © 2002-2006\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "cv100.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Intel® Open Source Computer Vision Library\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,786 @@
/*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*/
#include "_cv.h"
#define ICV_DEF_ACC_FUNC( name, srctype, dsttype, cvtmacro ) \
IPCVAPI_IMPL( CvStatus, \
name,( const srctype *src, int srcstep, dsttype *dst, \
int dststep, CvSize size ), (src, srcstep, dst, dststep, size )) \
\
{ \
srcstep /= sizeof(src[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src += srcstep, dst += dststep ) \
{ \
int x; \
for( x = 0; x <= size.width - 4; x += 4 ) \
{ \
dsttype t0 = dst[x] + cvtmacro(src[x]); \
dsttype t1 = dst[x + 1] + cvtmacro(src[x + 1]); \
dst[x] = t0; dst[x + 1] = t1; \
\
t0 = dst[x + 2] + cvtmacro(src[x + 2]); \
t1 = dst[x + 3] + cvtmacro(src[x + 3]); \
dst[x + 2] = t0; dst[x + 3] = t1; \
} \
\
for( ; x < size.width; x++ ) \
dst[x] += cvtmacro(src[x]); \
} \
\
return CV_OK; \
}
ICV_DEF_ACC_FUNC( icvAdd_8u32f_C1IR, uchar, float, CV_8TO32F )
ICV_DEF_ACC_FUNC( icvAdd_32f_C1IR, float, float, CV_NOP )
ICV_DEF_ACC_FUNC( icvAddSquare_8u32f_C1IR, uchar, float, CV_8TO32F_SQR )
ICV_DEF_ACC_FUNC( icvAddSquare_32f_C1IR, float, float, CV_SQR )
#define ICV_DEF_ACCPROD_FUNC( flavor, srctype, dsttype, cvtmacro ) \
IPCVAPI_IMPL( CvStatus, icvAddProduct_##flavor##_C1IR, \
( const srctype *src1, int step1, const srctype *src2, int step2, \
dsttype *dst, int dststep, CvSize size ), \
(src1, step1, src2, step2, dst, dststep, size) ) \
{ \
step1 /= sizeof(src1[0]); \
step2 /= sizeof(src2[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src1 += step1, src2 += step2, dst += dststep ) \
{ \
int x; \
for( x = 0; x <= size.width - 4; x += 4 ) \
{ \
dsttype t0 = dst[x] + cvtmacro(src1[x])*cvtmacro(src2[x]); \
dsttype t1 = dst[x+1] + cvtmacro(src1[x+1])*cvtmacro(src2[x+1]);\
dst[x] = t0; dst[x + 1] = t1; \
\
t0 = dst[x + 2] + cvtmacro(src1[x + 2])*cvtmacro(src2[x + 2]); \
t1 = dst[x + 3] + cvtmacro(src1[x + 3])*cvtmacro(src2[x + 3]); \
dst[x + 2] = t0; dst[x + 3] = t1; \
} \
\
for( ; x < size.width; x++ ) \
dst[x] += cvtmacro(src1[x])*cvtmacro(src2[x]); \
} \
\
return CV_OK; \
}
ICV_DEF_ACCPROD_FUNC( 8u32f, uchar, float, CV_8TO32F )
ICV_DEF_ACCPROD_FUNC( 32f, float, float, CV_NOP )
#define ICV_DEF_ACCWEIGHT_FUNC( flavor, srctype, dsttype, cvtmacro ) \
IPCVAPI_IMPL( CvStatus, icvAddWeighted_##flavor##_C1IR, \
( const srctype *src, int srcstep, dsttype *dst, int dststep, \
CvSize size, dsttype alpha ), (src, srcstep, dst, dststep, size, alpha) )\
{ \
dsttype beta = (dsttype)(1 - alpha); \
srcstep /= sizeof(src[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src += srcstep, dst += dststep ) \
{ \
int x; \
for( x = 0; x <= size.width - 4; x += 4 ) \
{ \
dsttype t0 = dst[x]*beta + cvtmacro(src[x])*alpha; \
dsttype t1 = dst[x+1]*beta + cvtmacro(src[x+1])*alpha; \
dst[x] = t0; dst[x + 1] = t1; \
\
t0 = dst[x + 2]*beta + cvtmacro(src[x + 2])*alpha; \
t1 = dst[x + 3]*beta + cvtmacro(src[x + 3])*alpha; \
dst[x + 2] = t0; dst[x + 3] = t1; \
} \
\
for( ; x < size.width; x++ ) \
dst[x] = dst[x]*beta + cvtmacro(src[x])*alpha; \
} \
\
return CV_OK; \
}
ICV_DEF_ACCWEIGHT_FUNC( 8u32f, uchar, float, CV_8TO32F )
ICV_DEF_ACCWEIGHT_FUNC( 32f, float, float, CV_NOP )
#define ICV_DEF_ACCMASK_FUNC_C1( name, srctype, dsttype, cvtmacro ) \
IPCVAPI_IMPL( CvStatus, \
name,( const srctype *src, int srcstep, const uchar* mask, int maskstep,\
dsttype *dst, int dststep, CvSize size ), \
(src, srcstep, mask, maskstep, dst, dststep, size )) \
{ \
srcstep /= sizeof(src[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src += srcstep, \
dst += dststep, mask += maskstep ) \
{ \
int x; \
for( x = 0; x <= size.width - 2; x += 2 ) \
{ \
if( mask[x] ) \
dst[x] += cvtmacro(src[x]); \
if( mask[x+1] ) \
dst[x+1] += cvtmacro(src[x+1]); \
} \
\
for( ; x < size.width; x++ ) \
if( mask[x] ) \
dst[x] += cvtmacro(src[x]); \
} \
\
return CV_OK; \
}
ICV_DEF_ACCMASK_FUNC_C1( icvAdd_8u32f_C1IMR, uchar, float, CV_8TO32F )
ICV_DEF_ACCMASK_FUNC_C1( icvAdd_32f_C1IMR, float, float, CV_NOP )
ICV_DEF_ACCMASK_FUNC_C1( icvAddSquare_8u32f_C1IMR, uchar, float, CV_8TO32F_SQR )
ICV_DEF_ACCMASK_FUNC_C1( icvAddSquare_32f_C1IMR, float, float, CV_SQR )
#define ICV_DEF_ACCPRODUCTMASK_FUNC_C1( flavor, srctype, dsttype, cvtmacro ) \
IPCVAPI_IMPL( CvStatus, icvAddProduct_##flavor##_C1IMR, \
( const srctype *src1, int step1, const srctype* src2, int step2, \
const uchar* mask, int maskstep, dsttype *dst, int dststep, CvSize size ),\
(src1, step1, src2, step2, mask, maskstep, dst, dststep, size )) \
{ \
step1 /= sizeof(src1[0]); \
step2 /= sizeof(src2[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src1 += step1, src2 += step2, \
dst += dststep, mask += maskstep ) \
{ \
int x; \
for( x = 0; x <= size.width - 2; x += 2 ) \
{ \
if( mask[x] ) \
dst[x] += cvtmacro(src1[x])*cvtmacro(src2[x]); \
if( mask[x+1] ) \
dst[x+1] += cvtmacro(src1[x+1])*cvtmacro(src2[x+1]); \
} \
\
for( ; x < size.width; x++ ) \
if( mask[x] ) \
dst[x] += cvtmacro(src1[x])*cvtmacro(src2[x]); \
} \
\
return CV_OK; \
}
ICV_DEF_ACCPRODUCTMASK_FUNC_C1( 8u32f, uchar, float, CV_8TO32F )
ICV_DEF_ACCPRODUCTMASK_FUNC_C1( 32f, float, float, CV_NOP )
#define ICV_DEF_ACCWEIGHTMASK_FUNC_C1( flavor, srctype, dsttype, cvtmacro ) \
IPCVAPI_IMPL( CvStatus, icvAddWeighted_##flavor##_C1IMR, \
( const srctype *src, int srcstep, const uchar* mask, int maskstep, \
dsttype *dst, int dststep, CvSize size, dsttype alpha ), \
(src, srcstep, mask, maskstep, dst, dststep, size, alpha )) \
{ \
dsttype beta = (dsttype)(1 - alpha); \
srcstep /= sizeof(src[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src += srcstep, \
dst += dststep, mask += maskstep ) \
{ \
int x; \
for( x = 0; x <= size.width - 2; x += 2 ) \
{ \
if( mask[x] ) \
dst[x] = dst[x]*beta + cvtmacro(src[x])*alpha; \
if( mask[x+1] ) \
dst[x+1] = dst[x+1]*beta + cvtmacro(src[x+1])*alpha; \
} \
\
for( ; x < size.width; x++ ) \
if( mask[x] ) \
dst[x] = dst[x]*beta + cvtmacro(src[x])*alpha; \
} \
\
return CV_OK; \
}
ICV_DEF_ACCWEIGHTMASK_FUNC_C1( 8u32f, uchar, float, CV_8TO32F )
ICV_DEF_ACCWEIGHTMASK_FUNC_C1( 32f, float, float, CV_NOP )
#define ICV_DEF_ACCMASK_FUNC_C3( name, srctype, dsttype, cvtmacro ) \
IPCVAPI_IMPL( CvStatus, \
name,( const srctype *src, int srcstep, const uchar* mask, int maskstep,\
dsttype *dst, int dststep, CvSize size ), \
(src, srcstep, mask, maskstep, dst, dststep, size )) \
{ \
srcstep /= sizeof(src[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src += srcstep, \
dst += dststep, mask += maskstep ) \
{ \
int x; \
for( x = 0; x < size.width; x++ ) \
if( mask[x] ) \
{ \
dsttype t0, t1, t2; \
t0 = dst[x*3] + cvtmacro(src[x*3]); \
t1 = dst[x*3+1] + cvtmacro(src[x*3+1]); \
t2 = dst[x*3+2] + cvtmacro(src[x*3+2]); \
dst[x*3] = t0; \
dst[x*3+1] = t1; \
dst[x*3+2] = t2; \
} \
} \
\
return CV_OK; \
}
ICV_DEF_ACCMASK_FUNC_C3( icvAdd_8u32f_C3IMR, uchar, float, CV_8TO32F )
ICV_DEF_ACCMASK_FUNC_C3( icvAdd_32f_C3IMR, float, float, CV_NOP )
ICV_DEF_ACCMASK_FUNC_C3( icvAddSquare_8u32f_C3IMR, uchar, float, CV_8TO32F_SQR )
ICV_DEF_ACCMASK_FUNC_C3( icvAddSquare_32f_C3IMR, float, float, CV_SQR )
#define ICV_DEF_ACCPRODUCTMASK_FUNC_C3( flavor, srctype, dsttype, cvtmacro ) \
IPCVAPI_IMPL( CvStatus, icvAddProduct_##flavor##_C3IMR, \
( const srctype *src1, int step1, const srctype* src2, int step2, \
const uchar* mask, int maskstep, dsttype *dst, int dststep, CvSize size ),\
(src1, step1, src2, step2, mask, maskstep, dst, dststep, size )) \
{ \
step1 /= sizeof(src1[0]); \
step2 /= sizeof(src2[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src1 += step1, src2 += step2, \
dst += dststep, mask += maskstep ) \
{ \
int x; \
for( x = 0; x < size.width; x++ ) \
if( mask[x] ) \
{ \
dsttype t0, t1, t2; \
t0 = dst[x*3]+cvtmacro(src1[x*3])*cvtmacro(src2[x*3]); \
t1 = dst[x*3+1]+cvtmacro(src1[x*3+1])*cvtmacro(src2[x*3+1]);\
t2 = dst[x*3+2]+cvtmacro(src1[x*3+2])*cvtmacro(src2[x*3+2]);\
dst[x*3] = t0; \
dst[x*3+1] = t1; \
dst[x*3+2] = t2; \
} \
} \
\
return CV_OK; \
}
ICV_DEF_ACCPRODUCTMASK_FUNC_C3( 8u32f, uchar, float, CV_8TO32F )
ICV_DEF_ACCPRODUCTMASK_FUNC_C3( 32f, float, float, CV_NOP )
#define ICV_DEF_ACCWEIGHTMASK_FUNC_C3( flavor, srctype, dsttype, cvtmacro ) \
IPCVAPI_IMPL( CvStatus, icvAddWeighted_##flavor##_C3IMR, \
( const srctype *src, int srcstep, const uchar* mask, int maskstep, \
dsttype *dst, int dststep, CvSize size, dsttype alpha ), \
(src, srcstep, mask, maskstep, dst, dststep, size, alpha )) \
{ \
dsttype beta = (dsttype)(1 - alpha); \
srcstep /= sizeof(src[0]); \
dststep /= sizeof(dst[0]); \
\
for( ; size.height--; src += srcstep, \
dst += dststep, mask += maskstep ) \
{ \
int x; \
for( x = 0; x < size.width; x++ ) \
if( mask[x] ) \
{ \
dsttype t0, t1, t2; \
t0 = dst[x*3]*beta + cvtmacro(src[x*3])*alpha; \
t1 = dst[x*3+1]*beta + cvtmacro(src[x*3+1])*alpha; \
t2 = dst[x*3+2]*beta + cvtmacro(src[x*3+2])*alpha; \
dst[x*3] = t0; \
dst[x*3+1] = t1; \
dst[x*3+2] = t2; \
} \
} \
\
return CV_OK; \
}
ICV_DEF_ACCWEIGHTMASK_FUNC_C3( 8u32f, uchar, float, CV_8TO32F )
ICV_DEF_ACCWEIGHTMASK_FUNC_C3( 32f, float, float, CV_NOP )
#define ICV_DEF_INIT_ACC_TAB( FUNCNAME ) \
static void icvInit##FUNCNAME##Table( CvFuncTable* tab, CvBigFuncTable* masktab ) \
{ \
tab->fn_2d[CV_8U] = (void*)icv##FUNCNAME##_8u32f_C1IR; \
tab->fn_2d[CV_32F] = (void*)icv##FUNCNAME##_32f_C1IR; \
\
masktab->fn_2d[CV_8UC1] = (void*)icv##FUNCNAME##_8u32f_C1IMR; \
masktab->fn_2d[CV_32FC1] = (void*)icv##FUNCNAME##_32f_C1IMR; \
\
masktab->fn_2d[CV_8UC3] = (void*)icv##FUNCNAME##_8u32f_C3IMR; \
masktab->fn_2d[CV_32FC3] = (void*)icv##FUNCNAME##_32f_C3IMR; \
}
ICV_DEF_INIT_ACC_TAB( Add )
ICV_DEF_INIT_ACC_TAB( AddSquare )
ICV_DEF_INIT_ACC_TAB( AddProduct )
ICV_DEF_INIT_ACC_TAB( AddWeighted )
CV_IMPL void
cvAcc( const void* arr, void* sumarr, const void* maskarr )
{
static CvFuncTable acc_tab;
static CvBigFuncTable accmask_tab;
static int inittab = 0;
CV_FUNCNAME( "cvAcc" );
__BEGIN__;
int type, sumdepth;
int mat_step, sum_step, mask_step = 0;
CvSize size;
CvMat stub, *mat = (CvMat*)arr;
CvMat sumstub, *sum = (CvMat*)sumarr;
CvMat maskstub, *mask = (CvMat*)maskarr;
if( !inittab )
{
icvInitAddTable( &acc_tab, &accmask_tab );
inittab = 1;
}
if( !CV_IS_MAT( mat ) || !CV_IS_MAT( sum ))
{
int coi1 = 0, coi2 = 0;
CV_CALL( mat = cvGetMat( mat, &stub, &coi1 ));
CV_CALL( sum = cvGetMat( sum, &sumstub, &coi2 ));
if( coi1 + coi2 != 0 )
CV_ERROR( CV_BadCOI, "" );
}
if( CV_MAT_DEPTH( sum->type ) != CV_32F )
CV_ERROR( CV_BadDepth, "" );
if( !CV_ARE_CNS_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
sumdepth = CV_MAT_DEPTH( sum->type );
if( sumdepth != CV_32F && (maskarr != 0 || sumdepth != CV_64F))
CV_ERROR( CV_BadDepth, "Bad accumulator type" );
if( !CV_ARE_SIZES_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
size = cvGetMatSize( mat );
type = CV_MAT_TYPE( mat->type );
mat_step = mat->step;
sum_step = sum->step;
if( !mask )
{
CvFunc2D_2A func=(CvFunc2D_2A)acc_tab.fn_2d[CV_MAT_DEPTH(type)];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "Unsupported type combination" );
size.width *= CV_MAT_CN(type);
if( CV_IS_MAT_CONT( mat->type & sum->type ))
{
size.width *= size.height;
mat_step = sum_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step, sum->data.ptr, sum_step, size ));
}
else
{
CvFunc2D_3A func = (CvFunc2D_3A)accmask_tab.fn_2d[type];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
CV_CALL( mask = cvGetMat( mask, &maskstub ));
if( !CV_IS_MASK_ARR( mask ))
CV_ERROR( CV_StsBadMask, "" );
if( !CV_ARE_SIZES_EQ( mat, mask ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
mask_step = mask->step;
if( CV_IS_MAT_CONT( mat->type & sum->type & mask->type ))
{
size.width *= size.height;
mat_step = sum_step = mask_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step, mask->data.ptr, mask_step,
sum->data.ptr, sum_step, size ));
}
__END__;
}
CV_IMPL void
cvSquareAcc( const void* arr, void* sq_sum, const void* maskarr )
{
static CvFuncTable acc_tab;
static CvBigFuncTable accmask_tab;
static int inittab = 0;
CV_FUNCNAME( "cvSquareAcc" );
__BEGIN__;
int coi1, coi2;
int type;
int mat_step, sum_step, mask_step = 0;
CvSize size;
CvMat stub, *mat = (CvMat*)arr;
CvMat sumstub, *sum = (CvMat*)sq_sum;
CvMat maskstub, *mask = (CvMat*)maskarr;
if( !inittab )
{
icvInitAddSquareTable( &acc_tab, &accmask_tab );
inittab = 1;
}
CV_CALL( mat = cvGetMat( mat, &stub, &coi1 ));
CV_CALL( sum = cvGetMat( sum, &sumstub, &coi2 ));
if( coi1 != 0 || coi2 != 0 )
CV_ERROR( CV_BadCOI, "" );
if( !CV_ARE_CNS_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( CV_MAT_DEPTH( sum->type ) != CV_32F )
CV_ERROR( CV_BadDepth, "" );
if( !CV_ARE_SIZES_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
size = cvGetMatSize( mat );
type = CV_MAT_TYPE( mat->type );
mat_step = mat->step;
sum_step = sum->step;
if( !mask )
{
CvFunc2D_2A func = (CvFunc2D_2A)acc_tab.fn_2d[CV_MAT_DEPTH(type)];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
size.width *= CV_MAT_CN(type);
if( CV_IS_MAT_CONT( mat->type & sum->type ))
{
size.width *= size.height;
mat_step = sum_step = CV_STUB_STEP;;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step, sum->data.ptr, sum_step, size ));
}
else
{
CvFunc2D_3A func = (CvFunc2D_3A)accmask_tab.fn_2d[type];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
CV_CALL( mask = cvGetMat( mask, &maskstub ));
if( !CV_IS_MASK_ARR( mask ))
CV_ERROR( CV_StsBadMask, "" );
if( !CV_ARE_SIZES_EQ( mat, mask ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
mask_step = mask->step;
if( CV_IS_MAT_CONT( mat->type & sum->type & mask->type ))
{
size.width *= size.height;
mat_step = sum_step = mask_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step, mask->data.ptr, mask_step,
sum->data.ptr, sum_step, size ));
}
__END__;
}
CV_IMPL void
cvMultiplyAcc( const void* arrA, const void* arrB,
void* acc, const void* maskarr )
{
static CvFuncTable acc_tab;
static CvBigFuncTable accmask_tab;
static int inittab = 0;
CV_FUNCNAME( "cvMultiplyAcc" );
__BEGIN__;
int coi1, coi2, coi3;
int type;
int mat1_step, mat2_step, sum_step, mask_step = 0;
CvSize size;
CvMat stub1, *mat1 = (CvMat*)arrA;
CvMat stub2, *mat2 = (CvMat*)arrB;
CvMat sumstub, *sum = (CvMat*)acc;
CvMat maskstub, *mask = (CvMat*)maskarr;
if( !inittab )
{
icvInitAddProductTable( &acc_tab, &accmask_tab );
inittab = 1;
}
CV_CALL( mat1 = cvGetMat( mat1, &stub1, &coi1 ));
CV_CALL( mat2 = cvGetMat( mat2, &stub2, &coi2 ));
CV_CALL( sum = cvGetMat( sum, &sumstub, &coi3 ));
if( coi1 != 0 || coi2 != 0 || coi3 != 0 )
CV_ERROR( CV_BadCOI, "" );
if( !CV_ARE_CNS_EQ( mat1, mat2 ) || !CV_ARE_CNS_EQ( mat1, sum ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( CV_MAT_DEPTH( sum->type ) != CV_32F )
CV_ERROR( CV_BadDepth, "" );
if( !CV_ARE_SIZES_EQ( mat1, sum ) || !CV_ARE_SIZES_EQ( mat2, sum ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
size = cvGetMatSize( mat1 );
type = CV_MAT_TYPE( mat1->type );
mat1_step = mat1->step;
mat2_step = mat2->step;
sum_step = sum->step;
if( !mask )
{
CvFunc2D_3A func = (CvFunc2D_3A)acc_tab.fn_2d[CV_MAT_DEPTH(type)];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
size.width *= CV_MAT_CN(type);
if( CV_IS_MAT_CONT( mat1->type & mat2->type & sum->type ))
{
size.width *= size.height;
mat1_step = mat2_step = sum_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat1->data.ptr, mat1_step, mat2->data.ptr, mat2_step,
sum->data.ptr, sum_step, size ));
}
else
{
CvFunc2D_4A func = (CvFunc2D_4A)accmask_tab.fn_2d[type];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
CV_CALL( mask = cvGetMat( mask, &maskstub ));
if( !CV_IS_MASK_ARR( mask ))
CV_ERROR( CV_StsBadMask, "" );
if( !CV_ARE_SIZES_EQ( mat1, mask ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
mask_step = mask->step;
if( CV_IS_MAT_CONT( mat1->type & mat2->type & sum->type & mask->type ))
{
size.width *= size.height;
mat1_step = mat2_step = sum_step = mask_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat1->data.ptr, mat1_step, mat2->data.ptr, mat2_step,
mask->data.ptr, mask_step,
sum->data.ptr, sum_step, size ));
}
__END__;
}
typedef CvStatus (CV_STDCALL *CvAddWeightedFunc)( const void* src, int srcstep,
void* dst, int dststep,
CvSize size, float alpha );
typedef CvStatus (CV_STDCALL *CvAddWeightedMaskFunc)( const void* src, int srcstep,
void* dst, int dststep,
const void* mask, int maskstep,
CvSize size, float alpha );
CV_IMPL void
cvRunningAvg( const void* arrY, void* arrU,
double alpha, const void* maskarr )
{
static CvFuncTable acc_tab;
static CvBigFuncTable accmask_tab;
static int inittab = 0;
CV_FUNCNAME( "cvRunningAvg" );
__BEGIN__;
int coi1, coi2;
int type;
int mat_step, sum_step, mask_step = 0;
CvSize size;
CvMat stub, *mat = (CvMat*)arrY;
CvMat sumstub, *sum = (CvMat*)arrU;
CvMat maskstub, *mask = (CvMat*)maskarr;
if( !inittab )
{
icvInitAddWeightedTable( &acc_tab, &accmask_tab );
inittab = 1;
}
CV_CALL( mat = cvGetMat( mat, &stub, &coi1 ));
CV_CALL( sum = cvGetMat( sum, &sumstub, &coi2 ));
if( coi1 != 0 || coi2 != 0 )
CV_ERROR( CV_BadCOI, "" );
if( !CV_ARE_CNS_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( CV_MAT_DEPTH( sum->type ) != CV_32F )
CV_ERROR( CV_BadDepth, "" );
if( !CV_ARE_SIZES_EQ( mat, sum ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
size = cvGetMatSize( mat );
type = CV_MAT_TYPE( mat->type );
mat_step = mat->step;
sum_step = sum->step;
if( !mask )
{
CvAddWeightedFunc func = (CvAddWeightedFunc)acc_tab.fn_2d[CV_MAT_DEPTH(type)];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
size.width *= CV_MAT_CN(type);
if( CV_IS_MAT_CONT( mat->type & sum->type ))
{
size.width *= size.height;
mat_step = sum_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step,
sum->data.ptr, sum_step, size, (float)alpha ));
}
else
{
CvAddWeightedMaskFunc func = (CvAddWeightedMaskFunc)accmask_tab.fn_2d[type];
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
CV_CALL( mask = cvGetMat( mask, &maskstub ));
if( !CV_IS_MASK_ARR( mask ))
CV_ERROR( CV_StsBadMask, "" );
if( !CV_ARE_SIZES_EQ( mat, mask ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
mask_step = mask->step;
if( CV_IS_MAT_CONT( mat->type & sum->type & mask->type ))
{
size.width *= size.height;
mat_step = sum_step = mask_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( func( mat->data.ptr, mat_step, mask->data.ptr, mask_step,
sum->data.ptr, sum_step, size, (float)alpha ));
}
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,144 @@
/*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*/
#include "_cv.h"
static void
icvAdaptiveThreshold_MeanC( const CvMat* src, CvMat* dst, int method,
int maxValue, int type, int size, double delta )
{
CvMat* mean = 0;
CV_FUNCNAME( "icvAdaptiveThreshold_MeanC" );
__BEGIN__;
int i, j, rows, cols;
int idelta = type == CV_THRESH_BINARY ? cvCeil(delta) : cvFloor(delta);
uchar tab[768];
if( size <= 1 || (size&1) == 0 )
CV_ERROR( CV_StsOutOfRange, "Neighborhood size must be >=3 and odd (3, 5, 7, ...)" );
if( maxValue < 0 )
{
CV_CALL( cvSetZero( dst ));
EXIT;
}
rows = src->rows;
cols = src->cols;
if( src->data.ptr != dst->data.ptr )
mean = dst;
else
CV_CALL( mean = cvCreateMat( rows, cols, CV_8UC1 ));
CV_CALL( cvSmooth( src, mean, method == CV_ADAPTIVE_THRESH_MEAN_C ?
CV_BLUR : CV_GAUSSIAN, size, size ));
if( maxValue > 255 )
maxValue = 255;
if( type == CV_THRESH_BINARY )
for( i = 0; i < 768; i++ )
tab[i] = (uchar)(i - 255 > -idelta ? maxValue : 0);
else
for( i = 0; i < 768; i++ )
tab[i] = (uchar)(i - 255 <= -idelta ? maxValue : 0);
for( i = 0; i < rows; i++ )
{
const uchar* s = src->data.ptr + i*src->step;
const uchar* m = mean->data.ptr + i*mean->step;
uchar* d = dst->data.ptr + i*dst->step;
for( j = 0; j < cols; j++ )
d[j] = tab[s[j] - m[j] + 255];
}
__END__;
if( mean != dst )
cvReleaseMat( &mean );
}
CV_IMPL void
cvAdaptiveThreshold( const void *srcIm, void *dstIm, double maxValue,
int method, int type, int blockSize, double param1 )
{
CvMat src_stub, dst_stub;
CvMat *src = 0, *dst = 0;
CV_FUNCNAME( "cvAdaptiveThreshold" );
__BEGIN__;
if( type != CV_THRESH_BINARY && type != CV_THRESH_BINARY_INV )
CV_ERROR( CV_StsBadArg, "Only CV_TRESH_BINARY and CV_THRESH_BINARY_INV "
"threshold types are acceptable" );
CV_CALL( src = cvGetMat( srcIm, &src_stub ));
CV_CALL( dst = cvGetMat( dstIm, &dst_stub ));
if( !CV_ARE_CNS_EQ( src, dst ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( CV_MAT_TYPE(dst->type) != CV_8UC1 )
CV_ERROR( CV_StsUnsupportedFormat, "" );
if( !CV_ARE_SIZES_EQ( src, dst ) )
CV_ERROR( CV_StsUnmatchedSizes, "" );
switch( method )
{
case CV_ADAPTIVE_THRESH_MEAN_C:
case CV_ADAPTIVE_THRESH_GAUSSIAN_C:
CV_CALL( icvAdaptiveThreshold_MeanC( src, dst, method, cvRound(maxValue),type,
blockSize, param1 ));
break;
default:
CV_ERROR( CV_BADCOEF_ERR, "" );
}
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,385 @@
/*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*/
#include "_cv.h"
#if 0
IPCVAPI(CvStatus, icvCalcContrastHist8uC1R, ( uchar** img, int step, CvSize size,
CvHistogram* hist, int dont_clear ))
IPCVAPI(CvStatus, icvCalcContrastHistMask8uC1R, ( uchar** img, int step,
uchar* mask, int mask_step, CvSize size,
CvHistogram* hist, int dont_clear ))
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvCalcContrastHist8uC1R
// Purpose: Calculating the histogram of contrast from one-channel images
// Context:
// Parameters:
// Returns:
// Notes: if dont_clear parameter is NULL then histogram clearing before
// calculating (all values sets to NULL)
//F*/
static CvStatus CV_STDCALL
icvCalcContrastHist8uC1R( uchar** img, int step, CvSize size,
CvHistogram* hist, int dont_clear )
{
int i, j, t, x = 0, y = 0;
int dims;
if( !hist || !img )
return CV_NULLPTR_ERR;
dims = hist->c_dims;
if( dims != 1 )
return CV_BADSIZE_ERR;
if( hist->type != CV_HIST_ARRAY )
return CV_BADFLAG_ERR;
for( i = 0; i < dims; i++ )
if( !img[i] )
return CV_NULLPTR_ERR;
for( i = 0; i < hist->c_dims; i++ )
{
if( !hist->thresh[i] )
return CV_NULLPTR_ERR;
assert( hist->chdims[i] );
}
j = hist->dims[0] * hist->mdims[0];
int *n = (int *)cvAlloc( (size_t)hist->dims[0] * sizeof( int ));
if( hist->type == CV_HIST_ARRAY )
{
if( !dont_clear )
for( i = 0; i < j; i++ )
{
hist->array[i] = 0;
n[i] = 0;
}
switch (hist->c_dims)
{
case 1:
{
uchar *data0 = img[0];
int *array = (int *) hist->array;
int *chdims = hist->chdims[0];
for( i = 0; i < j; i++ )
array[i] = cvRound( hist->array[i] );
for( y = 0; y < size.height; y++, data0 += step )
{
for( x = 0; x <= size.width - 1; x += 2 )
{
int v1_r = MIN( data0[x], data0[x + 1] );
int v2_r = MAX( data0[x], data0[x + 1] );
// calculate contrast for the right-left pair
for( t = v1_r; t < v2_r; t++ )
{
int val0 = chdims[t + 128];
array[val0] += MIN( t - v1_r, v2_r - t );
n[val0]++;
}
if( y < size.height - 1 )
{
int v1_d = MIN( data0[x], data0[x + step] );
int v2_d = MAX( data0[x], data0[x + step] );
// calculate contrast for the top-down pair
for( t = v1_d; t < v2_d; t++ )
{
int val0 = chdims[t + 128];
array[val0] += MIN( t - v1_d, v2_d - t );
n[val0]++;
}
}
}
}
// convert int to float
for( i = 0; i < j; i++ )
{
if( n[i] != 0 )
hist->array[i] = (float) array[i] / n[i];
else
hist->array[i] = 0;
}
}
break;
default:
return CV_BADSIZE_ERR;
}
}
cvFree( &n );
return CV_NO_ERR;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvCalcContrastHistMask8uC1R
// Purpose: Calculating the mask histogram of contrast from one-channel images
// Context:
// Parameters:
// Returns:
// Notes: if dont_clear parameter is NULL then histogram clearing before
// calculating (all values sets to NULL)
//F*/
static CvStatus CV_STDCALL
icvCalcContrastHistMask8uC1R( uchar** img, int step, uchar* mask, int mask_step,
CvSize size, CvHistogram * hist, int dont_clear )
{
int i, j, t, x = 0, y = 0;
int dims;
if( !hist || !img || !mask )
return CV_NULLPTR_ERR;
dims = hist->c_dims;
if( dims != 1 )
return CV_BADSIZE_ERR;
if( hist->type != CV_HIST_ARRAY )
return CV_BADFLAG_ERR;
for( i = 0; i < dims; i++ )
if( !img[i] )
return CV_NULLPTR_ERR;
for( i = 0; i < hist->c_dims; i++ )
{
if( !hist->thresh[i] )
return CV_NULLPTR_ERR;
assert( hist->chdims[i] );
}
j = hist->dims[0] * hist->mdims[0];
int *n = (int *)cvAlloc( (size_t) hist->dims[0] * sizeof( int ));
if( hist->type == CV_HIST_ARRAY )
{
if( !dont_clear )
for( i = 0; i < j; i++ )
{
hist->array[i] = 0;
n[i] = 0;
}
switch (hist->c_dims)
{
case 1:
{
uchar *data0 = img[0];
uchar *maskp = mask;
int *array = (int *) hist->array;
int *chdims = hist->chdims[0];
for( i = 0; i < j; i++ )
array[i] = cvRound( hist->array[i] );
for( y = 0; y < size.height; y++, data0 += step, maskp += mask_step )
{
for( x = 0; x <= size.width - 2; x++ )
{
if( maskp[x] )
{
if( maskp[x + 1] )
{
int v1_r = MIN( data0[x], data0[x + 1] );
int v2_r = MAX( data0[x], data0[x + 1] );
// calculate contrast for the right-left pair
for( t = v1_r; t < v2_r; t++ )
{
int val0 = chdims[t + 128];
array[val0] += MIN( t - v1_r, v2_r - t );
n[val0]++;
}
}
if( y < size.height - 1 )
{
if( maskp[x + mask_step] )
{
int v1_d = MIN( data0[x], data0[x + step] );
int v2_d = MAX( data0[x], data0[x + step] );
// calculate contrast for the top-down pair
for( t = v1_d; t < v2_d; t++ )
{
int val0 = chdims[t + 128];
array[val0] += MIN( t - v1_d, v2_d - t );
n[val0]++;
}
}
}
}
}
}
// convert int to float
for( i = 0; i < j; i++ )
{
if( n[i] != 0 )
hist->array[i] = (float) array[i] / n[i];
else
hist->array[i] = 0;
}
}
break;
default:
return CV_BADSIZE_ERR;
}
}
cvFree( &n );
return CV_NO_ERR;
}
/*
CV_IMPL void cvCalcContrastHist( IplImage** img, CvHistogram* hist, int dont_clear )
{
CV_FUNCNAME( "cvCalcContrastHist" );
uchar* data[CV_HIST_MAX_DIM];
int step = 0;
CvSize roi = {0,0};
__BEGIN__;
{for( int i = 0; i < hist->c_dims; i++ )
CV_CALL( CV_CHECK_IMAGE( img[i] ) );}
{for( int i = 0; i < hist->c_dims; i++ )
cvGetImageRawData( img[i], &data[i], &step, &roi );}
if(img[0]->nChannels != 1)
CV_ERROR( IPL_BadNumChannels, "bad channels numbers" );
if(img[0]->depth != IPL_DEPTH_8U)
CV_ERROR( IPL_BadDepth, "bad image depth" );
switch(img[0]->depth)
{
case IPL_DEPTH_8U:
IPPI_CALL( icvCalcContrastHist8uC1R( data, step, roi, hist, dont_clear ) );
break;
default: CV_ERROR( IPL_BadDepth, "bad image depth" );
}
__CLEANUP__;
__END__;
}
*/
CV_IMPL void
cvCalcContrastHist( IplImage ** img, CvHistogram * hist, int dont_clear, IplImage * mask )
{
CV_FUNCNAME( "cvCalcContrastHist" );
uchar *data[CV_HIST_MAX_DIM];
uchar *mask_data = 0;
int step = 0;
int mask_step = 0;
CvSize roi = { 0, 0 };
__BEGIN__;
{
for( int i = 0; i < hist->c_dims; i++ )
CV_CALL( CV_CHECK_IMAGE( img[i] ));
}
if( mask )
{
CV_CALL( CV_CHECK_IMAGE( mask ));
if( mask->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, "bad mask depth" );
cvGetImageRawData( mask, &mask_data, &mask_step, 0 );
}
{
for( int i = 0; i < hist->c_dims; i++ )
cvGetImageRawData( img[i], &data[i], &step, &roi );
}
if( img[0]->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, "bad channels numbers" );
if( img[0]->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, "bad image depth" );
switch (img[0]->depth)
{
case IPL_DEPTH_8U:
if( !mask )
{
IPPI_CALL( icvCalcContrastHist8uC1R( data, step, roi, hist, dont_clear ));
}
else
{
IPPI_CALL( icvCalcContrastHistMask8uC1R( data, step, mask_data,
mask_step, roi, hist, dont_clear ));
}
break;
default:
CV_ERROR( CV_BadDepth, "bad image depth" );
}
__CLEANUP__;
__END__;
}
#endif

View File

@@ -0,0 +1,120 @@
/*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*/
#include "_cv.h"
/****************************************************************************************\
calculate image homography
\****************************************************************************************/
CV_IMPL void
cvCalcImageHomography( float* line, CvPoint3D32f* _center,
float* _intrinsic, float* _homography )
{
CV_FUNCNAME( "cvCalcImageHomography" );
__BEGIN__;
double norm_xy, norm_xz, xy_sina, xy_cosa, xz_sina, xz_cosa, nx1, plane_dist;
float _ry[3], _rz[3], _r_trans[9];
CvMat rx = cvMat( 1, 3, CV_32F, line );
CvMat ry = cvMat( 1, 3, CV_32F, _ry );
CvMat rz = cvMat( 1, 3, CV_32F, _rz );
CvMat r_trans = cvMat( 3, 3, CV_32F, _r_trans );
CvMat center = cvMat( 3, 1, CV_32F, _center );
float _sub[9];
CvMat sub = cvMat( 3, 3, CV_32F, _sub );
float _t_trans[3];
CvMat t_trans = cvMat( 3, 1, CV_32F, _t_trans );
CvMat intrinsic = cvMat( 3, 3, CV_32F, _intrinsic );
CvMat homography = cvMat( 3, 3, CV_32F, _homography );
if( !line || !_center || !_intrinsic || !_homography )
CV_ERROR( CV_StsNullPtr, "" );
norm_xy = cvSqrt( line[0] * line[0] + line[1] * line[1] );
xy_cosa = line[0] / norm_xy;
xy_sina = line[1] / norm_xy;
norm_xz = cvSqrt( line[0] * line[0] + line[2] * line[2] );
xz_cosa = line[0] / norm_xz;
xz_sina = line[2] / norm_xz;
nx1 = -xz_sina;
_rz[0] = (float)(xy_cosa * nx1);
_rz[1] = (float)(xy_sina * nx1);
_rz[2] = (float)xz_cosa;
cvScale( &rz, &rz, 1./cvNorm(&rz,0,CV_L2) );
/* new axe y */
cvCrossProduct( &rz, &rx, &ry );
cvScale( &ry, &ry, 1./cvNorm( &ry, 0, CV_L2 ) );
/* transpone rotation matrix */
memcpy( &_r_trans[0], line, 3*sizeof(float));
memcpy( &_r_trans[3], _ry, 3*sizeof(float));
memcpy( &_r_trans[6], _rz, 3*sizeof(float));
/* calculate center distanse from arm plane */
plane_dist = cvDotProduct( &center, &rz );
/* calculate (I - r_trans)*center */
cvSetIdentity( &sub );
cvSub( &sub, &r_trans, &sub );
cvMatMul( &sub, &center, &t_trans );
cvMatMul( &t_trans, &rz, &sub );
cvScaleAdd( &sub, cvRealScalar(1./plane_dist), &r_trans, &sub ); /* ? */
cvMatMul( &intrinsic, &sub, &r_trans );
cvInvert( &intrinsic, &sub, CV_SVD );
cvMatMul( &r_trans, &sub, &homography );
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,300 @@
/*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*/
#include "_cv.h"
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvMeanShift
// Purpose: MeanShift algorithm
// Context:
// Parameters:
// imgProb - 2D object probability distribution
// windowIn - CvRect of CAMSHIFT Window intial size
// numIters - If CAMSHIFT iterates this many times, stop
// windowOut - Location, height and width of converged CAMSHIFT window
// len - If != NULL, return equivalent len
// width - If != NULL, return equivalent width
// itersUsed - Returns number of iterations CAMSHIFT took to converge
// Returns:
// The function itself returns the area found
// Notes:
//F*/
CV_IMPL int
cvMeanShift( const void* imgProb, CvRect windowIn,
CvTermCriteria criteria, CvConnectedComp* comp )
{
CvMoments moments;
int i = 0, eps;
CvMat stub, *mat = (CvMat*)imgProb;
CvMat cur_win;
CvRect cur_rect = windowIn;
CV_FUNCNAME( "cvMeanShift" );
if( comp )
comp->rect = windowIn;
moments.m00 = moments.m10 = moments.m01 = 0;
__BEGIN__;
CV_CALL( mat = cvGetMat( mat, &stub ));
if( CV_MAT_CN( mat->type ) > 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
if( windowIn.height <= 0 || windowIn.width <= 0 )
CV_ERROR( CV_StsBadArg, "Input window has non-positive sizes" );
if( windowIn.x < 0 || windowIn.x + windowIn.width > mat->cols ||
windowIn.y < 0 || windowIn.y + windowIn.height > mat->rows )
CV_ERROR( CV_StsBadArg, "Initial window is not inside the image ROI" );
CV_CALL( criteria = cvCheckTermCriteria( criteria, 1., 100 ));
eps = cvRound( criteria.epsilon * criteria.epsilon );
for( i = 0; i < criteria.max_iter; i++ )
{
int dx, dy, nx, ny;
double inv_m00;
CV_CALL( cvGetSubRect( mat, &cur_win, cur_rect ));
CV_CALL( cvMoments( &cur_win, &moments ));
/* Calculating center of mass */
if( fabs(moments.m00) < DBL_EPSILON )
break;
inv_m00 = moments.inv_sqrt_m00*moments.inv_sqrt_m00;
dx = cvRound( moments.m10 * inv_m00 - windowIn.width*0.5 );
dy = cvRound( moments.m01 * inv_m00 - windowIn.height*0.5 );
nx = cur_rect.x + dx;
ny = cur_rect.y + dy;
if( nx < 0 )
nx = 0;
else if( nx + cur_rect.width > mat->cols )
nx = mat->cols - cur_rect.width;
if( ny < 0 )
ny = 0;
else if( ny + cur_rect.height > mat->rows )
ny = mat->rows - cur_rect.height;
dx = nx - cur_rect.x;
dy = ny - cur_rect.y;
cur_rect.x = nx;
cur_rect.y = ny;
/* Check for coverage centers mass & window */
if( dx*dx + dy*dy < eps )
break;
}
__END__;
if( comp )
{
comp->rect = cur_rect;
comp->area = (float)moments.m00;
}
return i;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvCamShift
// Purpose: CAMSHIFT algorithm
// Context:
// Parameters:
// imgProb - 2D object probability distribution
// windowIn - CvRect of CAMSHIFT Window intial size
// criteria - criteria of stop finding window
// windowOut - Location, height and width of converged CAMSHIFT window
// orientation - If != NULL, return distribution orientation
// len - If != NULL, return equivalent len
// width - If != NULL, return equivalent width
// area - sum of all elements in result window
// itersUsed - Returns number of iterations CAMSHIFT took to converge
// Returns:
// The function itself returns the area found
// Notes:
//F*/
CV_IMPL int
cvCamShift( const void* imgProb, CvRect windowIn,
CvTermCriteria criteria,
CvConnectedComp* _comp,
CvBox2D* box )
{
const int TOLERANCE = 10;
CvMoments moments;
double m00 = 0, m10, m01, mu20, mu11, mu02, inv_m00;
double a, b, c, xc, yc;
double rotate_a, rotate_c;
double theta = 0, square;
double cs, sn;
double length = 0, width = 0;
int itersUsed = 0;
CvConnectedComp comp;
CvMat cur_win, stub, *mat = (CvMat*)imgProb;
CV_FUNCNAME( "cvCamShift" );
comp.rect = windowIn;
__BEGIN__;
CV_CALL( mat = cvGetMat( mat, &stub ));
CV_CALL( itersUsed = cvMeanShift( mat, windowIn, criteria, &comp ));
windowIn = comp.rect;
windowIn.x -= TOLERANCE;
if( windowIn.x < 0 )
windowIn.x = 0;
windowIn.y -= TOLERANCE;
if( windowIn.y < 0 )
windowIn.y = 0;
windowIn.width += 2 * TOLERANCE;
if( windowIn.x + windowIn.width > mat->width )
windowIn.width = mat->width - windowIn.x;
windowIn.height += 2 * TOLERANCE;
if( windowIn.y + windowIn.height > mat->height )
windowIn.height = mat->height - windowIn.y;
CV_CALL( cvGetSubRect( mat, &cur_win, windowIn ));
/* Calculating moments in new center mass */
CV_CALL( cvMoments( &cur_win, &moments ));
m00 = moments.m00;
m10 = moments.m10;
m01 = moments.m01;
mu11 = moments.mu11;
mu20 = moments.mu20;
mu02 = moments.mu02;
if( fabs(m00) < DBL_EPSILON )
EXIT;
inv_m00 = 1. / m00;
xc = cvRound( m10 * inv_m00 + windowIn.x );
yc = cvRound( m01 * inv_m00 + windowIn.y );
a = mu20 * inv_m00;
b = mu11 * inv_m00;
c = mu02 * inv_m00;
/* Calculating width & height */
square = sqrt( 4 * b * b + (a - c) * (a - c) );
/* Calculating orientation */
theta = atan2( 2 * b, a - c + square );
/* Calculating width & length of figure */
cs = cos( theta );
sn = sin( theta );
rotate_a = cs * cs * mu20 + 2 * cs * sn * mu11 + sn * sn * mu02;
rotate_c = sn * sn * mu20 - 2 * cs * sn * mu11 + cs * cs * mu02;
length = sqrt( rotate_a * inv_m00 ) * 4;
width = sqrt( rotate_c * inv_m00 ) * 4;
/* In case, when tetta is 0 or 1.57... the Length & Width may be exchanged */
if( length < width )
{
double t;
CV_SWAP( length, width, t );
CV_SWAP( cs, sn, t );
theta = CV_PI*0.5 - theta;
}
/* Saving results */
if( _comp || box )
{
int t0, t1;
int _xc = cvRound( xc );
int _yc = cvRound( yc );
t0 = cvRound( fabs( length * cs ));
t1 = cvRound( fabs( width * sn ));
t0 = MAX( t0, t1 ) + 2;
comp.rect.width = MIN( t0, (mat->width - _xc) * 2 );
t0 = cvRound( fabs( length * sn ));
t1 = cvRound( fabs( width * cs ));
t0 = MAX( t0, t1 ) + 2;
comp.rect.height = MIN( t0, (mat->height - _yc) * 2 );
comp.rect.x = MAX( 0, _xc - comp.rect.width / 2 );
comp.rect.y = MAX( 0, _yc - comp.rect.height / 2 );
comp.rect.width = MIN( mat->width - comp.rect.x, comp.rect.width );
comp.rect.height = MIN( mat->height - comp.rect.y, comp.rect.height );
comp.area = (float) m00;
}
__END__;
if( _comp )
*_comp = comp;
if( box )
{
box->size.height = (float)length;
box->size.width = (float)width;
box->angle = (float)(theta*180./CV_PI);
box->center = cvPoint2D32f( comp.rect.x + comp.rect.width*0.5f,
comp.rect.y + comp.rect.height*0.5f);
}
return itersUsed;
}
/* End of file. */

View File

@@ -0,0 +1,358 @@
/*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*/
#include "_cv.h"
icvCannyGetSize_t icvCannyGetSize_p = 0;
icvCanny_16s8u_C1R_t icvCanny_16s8u_C1R_p = 0;
CV_IMPL void
cvCanny( const void* srcarr, void* dstarr,
double low_thresh, double high_thresh, int aperture_size )
{
static const int sec_tab[] = { 1, 3, 0, 0, 2, 2, 2, 2 };
CvMat *dx = 0, *dy = 0;
void *buffer = 0;
uchar **stack_top, **stack_bottom = 0;
CV_FUNCNAME( "cvCanny" );
__BEGIN__;
CvMat srcstub, *src = (CvMat*)srcarr;
CvMat dststub, *dst = (CvMat*)dstarr;
CvSize size;
int flags = aperture_size;
int low, high;
int* mag_buf[3];
uchar* map;
int mapstep, maxsize;
int i, j;
CvMat mag_row;
CV_CALL( src = cvGetMat( src, &srcstub ));
CV_CALL( dst = cvGetMat( dst, &dststub ));
if( CV_MAT_TYPE( src->type ) != CV_8UC1 ||
CV_MAT_TYPE( dst->type ) != CV_8UC1 )
CV_ERROR( CV_StsUnsupportedFormat, "" );
if( !CV_ARE_SIZES_EQ( src, dst ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( low_thresh > high_thresh )
{
double t;
CV_SWAP( low_thresh, high_thresh, t );
}
aperture_size &= INT_MAX;
if( (aperture_size & 1) == 0 || aperture_size < 3 || aperture_size > 7 )
CV_ERROR( CV_StsBadFlag, "" );
size = cvGetMatSize( src );
dx = cvCreateMat( size.height, size.width, CV_16SC1 );
dy = cvCreateMat( size.height, size.width, CV_16SC1 );
cvSobel( src, dx, 1, 0, aperture_size );
cvSobel( src, dy, 0, 1, aperture_size );
if( icvCannyGetSize_p && icvCanny_16s8u_C1R_p && !(flags & CV_CANNY_L2_GRADIENT) )
{
int buf_size= 0;
IPPI_CALL( icvCannyGetSize_p( size, &buf_size ));
CV_CALL( buffer = cvAlloc( buf_size ));
IPPI_CALL( icvCanny_16s8u_C1R_p( (short*)dx->data.ptr, dx->step,
(short*)dy->data.ptr, dy->step,
dst->data.ptr, dst->step,
size, (float)low_thresh,
(float)high_thresh, buffer ));
EXIT;
}
if( flags & CV_CANNY_L2_GRADIENT )
{
Cv32suf ul, uh;
ul.f = (float)low_thresh;
uh.f = (float)high_thresh;
low = ul.i;
high = uh.i;
}
else
{
low = cvFloor( low_thresh );
high = cvFloor( high_thresh );
}
CV_CALL( buffer = cvAlloc( (size.width+2)*(size.height+2) +
(size.width+2)*3*sizeof(int)) );
mag_buf[0] = (int*)buffer;
mag_buf[1] = mag_buf[0] + size.width + 2;
mag_buf[2] = mag_buf[1] + size.width + 2;
map = (uchar*)(mag_buf[2] + size.width + 2);
mapstep = size.width + 2;
maxsize = MAX( 1 << 10, size.width*size.height/10 );
CV_CALL( stack_top = stack_bottom = (uchar**)cvAlloc( maxsize*sizeof(stack_top[0]) ));
memset( mag_buf[0], 0, (size.width+2)*sizeof(int) );
memset( map, 1, mapstep );
memset( map + mapstep*(size.height + 1), 1, mapstep );
/* sector numbers
(Top-Left Origin)
1 2 3
* * *
* * *
0*******0
* * *
* * *
3 2 1
*/
#define CANNY_PUSH(d) *(d) = (uchar)2, *stack_top++ = (d)
#define CANNY_POP(d) (d) = *--stack_top
mag_row = cvMat( 1, size.width, CV_32F );
// calculate magnitude and angle of gradient, perform non-maxima supression.
// fill the map with one of the following values:
// 0 - the pixel might belong to an edge
// 1 - the pixel can not belong to an edge
// 2 - the pixel does belong to an edge
for( i = 0; i <= size.height; i++ )
{
int* _mag = mag_buf[(i > 0) + 1] + 1;
float* _magf = (float*)_mag;
const short* _dx = (short*)(dx->data.ptr + dx->step*i);
const short* _dy = (short*)(dy->data.ptr + dy->step*i);
uchar* _map;
int x, y;
int magstep1, magstep2;
int prev_flag = 0;
if( i < size.height )
{
_mag[-1] = _mag[size.width] = 0;
if( !(flags & CV_CANNY_L2_GRADIENT) )
for( j = 0; j < size.width; j++ )
_mag[j] = abs(_dx[j]) + abs(_dy[j]);
else if( icvFilterSobelVert_8u16s_C1R_p != 0 ) // check for IPP
{
// use vectorized sqrt
mag_row.data.fl = _magf;
for( j = 0; j < size.width; j++ )
{
x = _dx[j]; y = _dy[j];
_magf[j] = (float)((double)x*x + (double)y*y);
}
cvPow( &mag_row, &mag_row, 0.5 );
}
else
{
for( j = 0; j < size.width; j++ )
{
x = _dx[j]; y = _dy[j];
_magf[j] = (float)sqrt((double)x*x + (double)y*y);
}
}
}
else
memset( _mag-1, 0, (size.width + 2)*sizeof(int) );
// at the very beginning we do not have a complete ring
// buffer of 3 magnitude rows for non-maxima suppression
if( i == 0 )
continue;
_map = map + mapstep*i + 1;
_map[-1] = _map[size.width] = 1;
_mag = mag_buf[1] + 1; // take the central row
_dx = (short*)(dx->data.ptr + dx->step*(i-1));
_dy = (short*)(dy->data.ptr + dy->step*(i-1));
magstep1 = (int)(mag_buf[2] - mag_buf[1]);
magstep2 = (int)(mag_buf[0] - mag_buf[1]);
if( (stack_top - stack_bottom) + size.width > maxsize )
{
uchar** new_stack_bottom;
maxsize = MAX( maxsize * 3/2, maxsize + size.width );
CV_CALL( new_stack_bottom = (uchar**)cvAlloc( maxsize * sizeof(stack_top[0])) );
memcpy( new_stack_bottom, stack_bottom, (stack_top - stack_bottom)*sizeof(stack_top[0]) );
stack_top = new_stack_bottom + (stack_top - stack_bottom);
cvFree( &stack_bottom );
stack_bottom = new_stack_bottom;
}
for( j = 0; j < size.width; j++ )
{
#define CANNY_SHIFT 15
#define TG22 (int)(0.4142135623730950488016887242097*(1<<CANNY_SHIFT) + 0.5)
x = _dx[j];
y = _dy[j];
int s = x ^ y;
int m = _mag[j];
x = abs(x);
y = abs(y);
if( m > low )
{
int tg22x = x * TG22;
int tg67x = tg22x + ((x + x) << CANNY_SHIFT);
y <<= CANNY_SHIFT;
if( y < tg22x )
{
if( m > _mag[j-1] && m >= _mag[j+1] )
{
if( m > high && !prev_flag && _map[j-mapstep] != 2 )
{
CANNY_PUSH( _map + j );
prev_flag = 1;
}
else
_map[j] = (uchar)0;
continue;
}
}
else if( y > tg67x )
{
if( m > _mag[j+magstep2] && m >= _mag[j+magstep1] )
{
if( m > high && !prev_flag && _map[j-mapstep] != 2 )
{
CANNY_PUSH( _map + j );
prev_flag = 1;
}
else
_map[j] = (uchar)0;
continue;
}
}
else
{
s = s < 0 ? -1 : 1;
if( m > _mag[j+magstep2-s] && m > _mag[j+magstep1+s] )
{
if( m > high && !prev_flag && _map[j-mapstep] != 2 )
{
CANNY_PUSH( _map + j );
prev_flag = 1;
}
else
_map[j] = (uchar)0;
continue;
}
}
}
prev_flag = 0;
_map[j] = (uchar)1;
}
// scroll the ring buffer
_mag = mag_buf[0];
mag_buf[0] = mag_buf[1];
mag_buf[1] = mag_buf[2];
mag_buf[2] = _mag;
}
// now track the edges (hysteresis thresholding)
while( stack_top > stack_bottom )
{
uchar* m;
if( (stack_top - stack_bottom) + 8 > maxsize )
{
uchar** new_stack_bottom;
maxsize = MAX( maxsize * 3/2, maxsize + 8 );
CV_CALL( new_stack_bottom = (uchar**)cvAlloc( maxsize * sizeof(stack_top[0])) );
memcpy( new_stack_bottom, stack_bottom, (stack_top - stack_bottom)*sizeof(stack_top[0]) );
stack_top = new_stack_bottom + (stack_top - stack_bottom);
cvFree( &stack_bottom );
stack_bottom = new_stack_bottom;
}
CANNY_POP(m);
if( !m[-1] )
CANNY_PUSH( m - 1 );
if( !m[1] )
CANNY_PUSH( m + 1 );
if( !m[-mapstep-1] )
CANNY_PUSH( m - mapstep - 1 );
if( !m[-mapstep] )
CANNY_PUSH( m - mapstep );
if( !m[-mapstep+1] )
CANNY_PUSH( m - mapstep + 1 );
if( !m[mapstep-1] )
CANNY_PUSH( m + mapstep - 1 );
if( !m[mapstep] )
CANNY_PUSH( m + mapstep );
if( !m[mapstep+1] )
CANNY_PUSH( m + mapstep + 1 );
}
// the final pass, form the final image
for( i = 0; i < size.height; i++ )
{
const uchar* _map = map + mapstep*(i+1) + 1;
uchar* _dst = dst->data.ptr + dst->step*i;
for( j = 0; j < size.width; j++ )
_dst[j] = (uchar)-(_map[j] >> 1);
}
__END__;
cvReleaseMat( &dx );
cvReleaseMat( &dy );
cvFree( &buffer );
cvFree( &stack_bottom );
}
/* End of file. */

View File

@@ -0,0 +1,284 @@
/*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*/
#include "_cv.h"
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvCreateConDensation
// Purpose: Creating CvConDensation structure and allocating memory for it
// Context:
// Parameters:
// Kalman - double pointer to CvConDensation structure
// DP - dimension of the dynamical vector
// MP - dimension of the measurement vector
// SamplesNum - number of samples in sample set used in algorithm
// Returns:
// Notes:
//
//F*/
CV_IMPL CvConDensation* cvCreateConDensation( int DP, int MP, int SamplesNum )
{
int i;
CvConDensation *CD = 0;
CV_FUNCNAME( "cvCreateConDensation" );
__BEGIN__;
if( DP < 0 || MP < 0 || SamplesNum < 0 )
CV_ERROR( CV_StsOutOfRange, "" );
/* allocating memory for the structure */
CV_CALL( CD = (CvConDensation *) cvAlloc( sizeof( CvConDensation )));
/* setting structure params */
CD->SamplesNum = SamplesNum;
CD->DP = DP;
CD->MP = MP;
/* allocating memory for structure fields */
CV_CALL( CD->flSamples = (float **) cvAlloc( sizeof( float * ) * SamplesNum ));
CV_CALL( CD->flNewSamples = (float **) cvAlloc( sizeof( float * ) * SamplesNum ));
CV_CALL( CD->flSamples[0] = (float *) cvAlloc( sizeof( float ) * SamplesNum * DP ));
CV_CALL( CD->flNewSamples[0] = (float *) cvAlloc( sizeof( float ) * SamplesNum * DP ));
/* setting pointers in pointer's arrays */
for( i = 1; i < SamplesNum; i++ )
{
CD->flSamples[i] = CD->flSamples[i - 1] + DP;
CD->flNewSamples[i] = CD->flNewSamples[i - 1] + DP;
}
CV_CALL( CD->State = (float *) cvAlloc( sizeof( float ) * DP ));
CV_CALL( CD->DynamMatr = (float *) cvAlloc( sizeof( float ) * DP * DP ));
CV_CALL( CD->flConfidence = (float *) cvAlloc( sizeof( float ) * SamplesNum ));
CV_CALL( CD->flCumulative = (float *) cvAlloc( sizeof( float ) * SamplesNum ));
CV_CALL( CD->RandS = (CvRandState *) cvAlloc( sizeof( CvRandState ) * DP ));
CV_CALL( CD->Temp = (float *) cvAlloc( sizeof( float ) * DP ));
CV_CALL( CD->RandomSample = (float *) cvAlloc( sizeof( float ) * DP ));
/* Returning created structure */
__END__;
return CD;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvReleaseConDensation
// Purpose: Releases CvConDensation structure and frees memory allocated for it
// Context:
// Parameters:
// Kalman - double pointer to CvConDensation structure
// DP - dimension of the dynamical vector
// MP - dimension of the measurement vector
// SamplesNum - number of samples in sample set used in algorithm
// Returns:
// Notes:
//
//F*/
CV_IMPL void
cvReleaseConDensation( CvConDensation ** ConDensation )
{
CV_FUNCNAME( "cvReleaseConDensation" );
__BEGIN__;
CvConDensation *CD = *ConDensation;
if( !ConDensation )
CV_ERROR( CV_StsNullPtr, "" );
if( !CD )
EXIT;
/* freeing the memory */
cvFree( &CD->State );
cvFree( &CD->DynamMatr);
cvFree( &CD->flConfidence );
cvFree( &CD->flCumulative );
cvFree( &CD->flSamples[0] );
cvFree( &CD->flNewSamples[0] );
cvFree( &CD->flSamples );
cvFree( &CD->flNewSamples );
cvFree( &CD->Temp );
cvFree( &CD->RandS );
cvFree( &CD->RandomSample );
/* release structure */
cvFree( ConDensation );
__END__;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvConDensUpdateByTime
// Purpose: Performing Time Update routine for ConDensation algorithm
// Context:
// Parameters:
// Kalman - pointer to CvConDensation structure
// Returns:
// Notes:
//
//F*/
CV_IMPL void
cvConDensUpdateByTime( CvConDensation * ConDens )
{
int i, j;
float Sum = 0;
CV_FUNCNAME( "cvConDensUpdateByTime" );
__BEGIN__;
if( !ConDens )
CV_ERROR( CV_StsNullPtr, "" );
/* Sets Temp to Zero */
icvSetZero_32f( ConDens->Temp, ConDens->DP, 1 );
/* Calculating the Mean */
for( i = 0; i < ConDens->SamplesNum; i++ )
{
icvScaleVector_32f( ConDens->flSamples[i], ConDens->State, ConDens->DP,
ConDens->flConfidence[i] );
icvAddVector_32f( ConDens->Temp, ConDens->State, ConDens->Temp, ConDens->DP );
Sum += ConDens->flConfidence[i];
ConDens->flCumulative[i] = Sum;
}
/* Taking the new vector from transformation of mean by dynamics matrix */
icvScaleVector_32f( ConDens->Temp, ConDens->Temp, ConDens->DP, 1.f / Sum );
icvTransformVector_32f( ConDens->DynamMatr, ConDens->Temp, ConDens->State, ConDens->DP,
ConDens->DP );
Sum = Sum / ConDens->SamplesNum;
/* Updating the set of random samples */
for( i = 0; i < ConDens->SamplesNum; i++ )
{
j = 0;
while( (ConDens->flCumulative[j] <= (float) i * Sum)&&(j<ConDens->SamplesNum-1))
{
j++;
}
icvCopyVector_32f( ConDens->flSamples[j], ConDens->DP, ConDens->flNewSamples[i] );
}
/* Adding the random-generated vector to every vector in sample set */
for( i = 0; i < ConDens->SamplesNum; i++ )
{
for( j = 0; j < ConDens->DP; j++ )
{
cvbRand( ConDens->RandS + j, ConDens->RandomSample + j, 1 );
}
icvTransformVector_32f( ConDens->DynamMatr, ConDens->flNewSamples[i],
ConDens->flSamples[i], ConDens->DP, ConDens->DP );
icvAddVector_32f( ConDens->flSamples[i], ConDens->RandomSample, ConDens->flSamples[i],
ConDens->DP );
}
__END__;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvConDensInitSamplSet
// Purpose: Performing Time Update routine for ConDensation algorithm
// Context:
// Parameters:
// conDens - pointer to CvConDensation structure
// lowerBound - vector of lower bounds used to random update of sample set
// lowerBound - vector of upper bounds used to random update of sample set
// Returns:
// Notes:
//
//F*/
CV_IMPL void
cvConDensInitSampleSet( CvConDensation * conDens, CvMat * lowerBound, CvMat * upperBound )
{
int i, j;
float *LBound;
float *UBound;
float Prob = 1.f / conDens->SamplesNum;
CV_FUNCNAME( "cvConDensInitSampleSet" );
__BEGIN__;
if( !conDens || !lowerBound || !upperBound )
CV_ERROR( CV_StsNullPtr, "" );
if( CV_MAT_TYPE(lowerBound->type) != CV_32FC1 ||
!CV_ARE_TYPES_EQ(lowerBound,upperBound) )
CV_ERROR( CV_StsBadArg, "source has not appropriate format" );
if( (lowerBound->cols != 1) || (upperBound->cols != 1) )
CV_ERROR( CV_StsBadArg, "source has not appropriate size" );
if( (lowerBound->rows != conDens->DP) || (upperBound->rows != conDens->DP) )
CV_ERROR( CV_StsBadArg, "source has not appropriate size" );
LBound = lowerBound->data.fl;
UBound = upperBound->data.fl;
/* Initializing the structures to create initial Sample set */
for( i = 0; i < conDens->DP; i++ )
{
cvRandInit( &(conDens->RandS[i]),
LBound[i],
UBound[i],
i );
}
/* Generating the samples */
for( j = 0; j < conDens->SamplesNum; j++ )
{
for( i = 0; i < conDens->DP; i++ )
{
cvbRand( conDens->RandS + i, conDens->flSamples[j] + i, 1 );
}
conDens->flConfidence[j] = Prob;
}
/* Reinitializes the structures to update samples randomly */
for( i = 0; i < conDens->DP; i++ )
{
cvRandInit( &(conDens->RandS[i]),
(LBound[i] - UBound[i]) / 5,
(UBound[i] - LBound[i]) / 5,
i);
}
__END__;
}

View File

@@ -0,0 +1,805 @@
/*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*/
#include "_cv.h"
#define CV_MATCH_CHECK( status, cvFun ) \
{ \
status = cvFun; \
if( status != CV_OK ) \
goto M_END; \
}
static CvStatus
icvCalcTriAttr( const CvSeq * contour, CvPoint t2, CvPoint t1, int n1,
CvPoint t3, int n3, double *s, double *s_c,
double *h, double *a, double *b );
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvCreateContourTree
// Purpose:
// Create binary tree representation for the contour
// Context:
// Parameters:
// contour - pointer to input contour object.
// storage - pointer to the current storage block
// tree - output pointer to the binary tree representation
// threshold - threshold for the binary tree building
//
//F*/
static CvStatus
icvCreateContourTree( const CvSeq * contour, CvMemStorage * storage,
CvContourTree ** tree, double threshold )
{
CvPoint *pt_p; /* pointer to previos points */
CvPoint *pt_n; /* pointer to next points */
CvPoint *pt1, *pt2; /* pointer to current points */
CvPoint t, tp1, tp2, tp3, tn1, tn2, tn3;
int lpt, flag, i, j, i_tree, j_1, j_3, i_buf;
double s, sp1, sp2, sn1, sn2, s_c, sp1_c, sp2_c, sn1_c, sn2_c, h, hp1, hp2, hn1, hn2,
a, ap1, ap2, an1, an2, b, bp1, bp2, bn1, bn2;
double a_s_c, a_sp1_c;
_CvTrianAttr **ptr_p, **ptr_n, **ptr1, **ptr2; /* pointers to pointers of triangles */
_CvTrianAttr *cur_adr;
int *num_p, *num_n, *num1, *num2; /* numbers of input contour points */
int nm, nmp1, nmp2, nmp3, nmn1, nmn2, nmn3;
int seq_flags = 1, i_end, prev_null, prev2_null;
double koef = 1.5;
double eps = 1.e-7;
double e;
CvStatus status;
int hearder_size;
_CvTrianAttr tree_one, tree_two, *tree_end, *tree_root;
CvSeqWriter writer;
assert( contour != NULL && contour->total >= 4 );
status = CV_OK;
if( contour == NULL )
return CV_NULLPTR_ERR;
if( contour->total < 4 )
return CV_BADSIZE_ERR;
if( !CV_IS_SEQ_POLYGON( contour ))
return CV_BADFLAG_ERR;
/* Convert Sequence to array */
lpt = contour->total;
pt_p = pt_n = NULL;
num_p = num_n = NULL;
ptr_p = ptr_n = ptr1 = ptr2 = NULL;
tree_end = NULL;
pt_p = (CvPoint *) cvAlloc( lpt * sizeof( CvPoint ));
pt_n = (CvPoint *) cvAlloc( lpt * sizeof( CvPoint ));
num_p = (int *) cvAlloc( lpt * sizeof( int ));
num_n = (int *) cvAlloc( lpt * sizeof( int ));
hearder_size = sizeof( CvContourTree );
seq_flags = CV_SEQ_POLYGON_TREE;
cvStartWriteSeq( seq_flags, hearder_size, sizeof( _CvTrianAttr ), storage, &writer );
ptr_p = (_CvTrianAttr **) cvAlloc( lpt * sizeof( _CvTrianAttr * ));
ptr_n = (_CvTrianAttr **) cvAlloc( lpt * sizeof( _CvTrianAttr * ));
memset( ptr_p, 0, lpt * sizeof( _CvTrianAttr * ));
memset( ptr_n, 0, lpt * sizeof( _CvTrianAttr * ));
if( pt_p == NULL || pt_n == NULL )
return CV_OUTOFMEM_ERR;
if( ptr_p == NULL || ptr_n == NULL )
return CV_OUTOFMEM_ERR;
/* write fild for the binary tree root */
/* start_writer = writer; */
tree_one.pt.x = tree_one.pt.y = 0;
tree_one.sign = 0;
tree_one.area = 0;
tree_one.r1 = tree_one.r2 = 0;
tree_one.next_v1 = tree_one.next_v2 = tree_one.prev_v = NULL;
CV_WRITE_SEQ_ELEM( tree_one, writer );
tree_root = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( cvCvtSeqToArray( contour, (char *) pt_p ) == (char *) contour )
return CV_BADPOINT_ERR;
for( i = 0; i < lpt; i++ )
num_p[i] = i;
i = lpt;
flag = 0;
i_tree = 0;
e = 20.; /* initial threshold value */
ptr1 = ptr_p;
ptr2 = ptr_n;
pt1 = pt_p;
pt2 = pt_n;
num1 = num_p;
num2 = num_n;
/* binary tree constraction */
while( i > 4 )
{
if( flag == 0 )
{
ptr1 = ptr_p;
ptr2 = ptr_n;
pt1 = pt_p;
pt2 = pt_n;
num1 = num_p;
num2 = num_n;
flag = 1;
}
else
{
ptr1 = ptr_n;
ptr2 = ptr_p;
pt1 = pt_n;
pt2 = pt_p;
num1 = num_n;
num2 = num_p;
flag = 0;
}
t = pt1[0];
nm = num1[0];
tp1 = pt1[i - 1];
nmp1 = num1[i - 1];
tp2 = pt1[i - 2];
nmp2 = num1[i - 2];
tp3 = pt1[i - 3];
nmp3 = num1[i - 3];
tn1 = pt1[1];
nmn1 = num1[1];
tn2 = pt1[2];
nmn2 = num1[2];
i_buf = 0;
i_end = -1;
CV_MATCH_CHECK( status,
icvCalcTriAttr( contour, t, tp1, nmp1, tn1, nmn1, &s, &s_c, &h, &a,
&b ));
CV_MATCH_CHECK( status,
icvCalcTriAttr( contour, tp1, tp2, nmp2, t, nm, &sp1, &sp1_c, &hp1,
&ap1, &bp1 ));
CV_MATCH_CHECK( status,
icvCalcTriAttr( contour, tp2, tp3, nmp3, tp1, nmp1, &sp2, &sp2_c, &hp2,
&ap2, &bp2 ));
CV_MATCH_CHECK( status,
icvCalcTriAttr( contour, tn1, t, nm, tn2, nmn2, &sn1, &sn1_c, &hn1,
&an1, &bn1 ));
j_3 = 3;
prev_null = prev2_null = 0;
for( j = 0; j < i; j++ )
{
tn3 = pt1[j_3];
nmn3 = num1[j_3];
if( j == 0 )
j_1 = i - 1;
else
j_1 = j - 1;
CV_MATCH_CHECK( status, icvCalcTriAttr( contour, tn2, tn1, nmn1, tn3, nmn3,
&sn2, &sn2_c, &hn2, &an2, &bn2 ));
if( (s_c < sp1_c && s_c < sp2_c && s_c <= sn1_c && s_c <= sn2_c && s_c < e) ||
(s_c == sp1_c && s_c <= sp2_c || s_c == sp2_c && s_c <= sp1_c) && s_c <= sn1_c
&& s_c <= sn2_c && s_c < e && j > 1 && prev2_null == 0 || (s_c < eps && j > 0
&& prev_null == 0) )
{
prev_null = prev2_null = 1;
if( s_c < threshold )
{
if( ptr1[j_1] == NULL && ptr1[j] == NULL )
{
if( i_buf > 0 )
ptr2[i_buf - 1] = NULL;
else
i_end = 0;
}
else
{
/* form next vertex */
tree_one.pt = t;
tree_one.sign = (char) (CV_SIGN( s ));
tree_one.r1 = h / a;
tree_one.r2 = b / a;
tree_one.area = fabs( s );
tree_one.next_v1 = ptr1[j_1];
tree_one.next_v2 = ptr1[j];
CV_WRITE_SEQ_ELEM( tree_one, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( ptr1[j_1] != NULL )
ptr1[j_1]->prev_v = cur_adr;
if( ptr1[j] != NULL )
ptr1[j]->prev_v = cur_adr;
if( i_buf > 0 )
ptr2[i_buf - 1] = cur_adr;
else
{
tree_end = (_CvTrianAttr *) writer.ptr;
i_end = 1;
}
i_tree++;
}
}
else
/* form next vertex */
{
tree_one.pt = t;
tree_one.sign = (char) (CV_SIGN( s ));
tree_one.area = fabs( s );
tree_one.r1 = h / a;
tree_one.r2 = b / a;
tree_one.next_v1 = ptr1[j_1];
tree_one.next_v2 = ptr1[j];
CV_WRITE_SEQ_ELEM( tree_one, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( ptr1[j_1] != NULL )
ptr1[j_1]->prev_v = cur_adr;
if( ptr1[j] != NULL )
ptr1[j]->prev_v = cur_adr;
if( i_buf > 0 )
ptr2[i_buf - 1] = cur_adr;
else
{
tree_end = cur_adr;
i_end = 1;
}
i_tree++;
}
}
else
/* the current triangle is'not LMIAT */
{
prev_null = 0;
switch (prev2_null)
{
case 0:
break;
case 1:
{
prev2_null = 2;
break;
}
case 2:
{
prev2_null = 0;
break;
}
}
if( j != i - 1 || i_end == -1 )
ptr2[i_buf] = ptr1[j];
else if( i_end == 0 )
ptr2[i_buf] = NULL;
else
ptr2[i_buf] = tree_end;
pt2[i_buf] = t;
num2[i_buf] = num1[j];
i_buf++;
}
/* go to next vertex */
tp3 = tp2;
tp2 = tp1;
tp1 = t;
t = tn1;
tn1 = tn2;
tn2 = tn3;
nmp3 = nmp2;
nmp2 = nmp1;
nmp1 = nm;
nm = nmn1;
nmn1 = nmn2;
nmn2 = nmn3;
sp2 = sp1;
sp1 = s;
s = sn1;
sn1 = sn2;
sp2_c = sp1_c;
sp1_c = s_c;
s_c = sn1_c;
sn1_c = sn2_c;
ap2 = ap1;
ap1 = a;
a = an1;
an1 = an2;
bp2 = bp1;
bp1 = b;
b = bn1;
bn1 = bn2;
hp2 = hp1;
hp1 = h;
h = hn1;
hn1 = hn2;
j_3++;
if( j_3 >= i )
j_3 = 0;
}
i = i_buf;
e = e * koef;
}
/* constract tree root */
if( i != 4 )
return CV_BADFACTOR_ERR;
t = pt2[0];
tn1 = pt2[1];
tn2 = pt2[2];
tp1 = pt2[3];
nm = num2[0];
nmn1 = num2[1];
nmn2 = num2[2];
nmp1 = num2[3];
/* first pair of the triangles */
CV_MATCH_CHECK( status,
icvCalcTriAttr( contour, t, tp1, nmp1, tn1, nmn1, &s, &s_c, &h, &a, &b ));
CV_MATCH_CHECK( status,
icvCalcTriAttr( contour, tn2, tn1, nmn1, tp1, nmp1, &sn2, &sn2_c, &hn2,
&an2, &bn2 ));
/* second pair of the triangles */
CV_MATCH_CHECK( status,
icvCalcTriAttr( contour, tn1, t, nm, tn2, nmn2, &sn1, &sn1_c, &hn1, &an1,
&bn1 ));
CV_MATCH_CHECK( status,
icvCalcTriAttr( contour, tp1, tn2, nmn2, t, nm, &sp1, &sp1_c, &hp1, &ap1,
&bp1 ));
a_s_c = fabs( s_c - sn2_c );
a_sp1_c = fabs( sp1_c - sn1_c );
if( a_s_c > a_sp1_c )
/* form child vertexs for the root */
{
tree_one.pt = t;
tree_one.sign = (char) (CV_SIGN( s ));
tree_one.area = fabs( s );
tree_one.r1 = h / a;
tree_one.r2 = b / a;
tree_one.next_v1 = ptr2[3];
tree_one.next_v2 = ptr2[0];
tree_two.pt = tn2;
tree_two.sign = (char) (CV_SIGN( sn2 ));
tree_two.area = fabs( sn2 );
tree_two.r1 = hn2 / an2;
tree_two.r2 = bn2 / an2;
tree_two.next_v1 = ptr2[1];
tree_two.next_v2 = ptr2[2];
CV_WRITE_SEQ_ELEM( tree_one, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( s_c > sn2_c )
{
if( ptr2[3] != NULL )
ptr2[3]->prev_v = cur_adr;
if( ptr2[0] != NULL )
ptr2[0]->prev_v = cur_adr;
ptr1[0] = cur_adr;
i_tree++;
CV_WRITE_SEQ_ELEM( tree_two, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( ptr2[1] != NULL )
ptr2[1]->prev_v = cur_adr;
if( ptr2[2] != NULL )
ptr2[2]->prev_v = cur_adr;
ptr1[1] = cur_adr;
i_tree++;
pt1[0] = tp1;
pt1[1] = tn1;
}
else
{
CV_WRITE_SEQ_ELEM( tree_two, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( ptr2[1] != NULL )
ptr2[1]->prev_v = cur_adr;
if( ptr2[2] != NULL )
ptr2[2]->prev_v = cur_adr;
ptr1[0] = cur_adr;
i_tree++;
CV_WRITE_SEQ_ELEM( tree_one, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( ptr2[3] != NULL )
ptr2[3]->prev_v = cur_adr;
if( ptr2[0] != NULL )
ptr2[0]->prev_v = cur_adr;
ptr1[1] = cur_adr;
i_tree++;
pt1[0] = tn1;
pt1[1] = tp1;
}
}
else
{
tree_one.pt = tp1;
tree_one.sign = (char) (CV_SIGN( sp1 ));
tree_one.area = fabs( sp1 );
tree_one.r1 = hp1 / ap1;
tree_one.r2 = bp1 / ap1;
tree_one.next_v1 = ptr2[2];
tree_one.next_v2 = ptr2[3];
tree_two.pt = tn1;
tree_two.sign = (char) (CV_SIGN( sn1 ));
tree_two.area = fabs( sn1 );
tree_two.r1 = hn1 / an1;
tree_two.r2 = bn1 / an1;
tree_two.next_v1 = ptr2[0];
tree_two.next_v2 = ptr2[1];
CV_WRITE_SEQ_ELEM( tree_one, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( sp1_c > sn1_c )
{
if( ptr2[2] != NULL )
ptr2[2]->prev_v = cur_adr;
if( ptr2[3] != NULL )
ptr2[3]->prev_v = cur_adr;
ptr1[0] = cur_adr;
i_tree++;
CV_WRITE_SEQ_ELEM( tree_two, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( ptr2[0] != NULL )
ptr2[0]->prev_v = cur_adr;
if( ptr2[1] != NULL )
ptr2[1]->prev_v = cur_adr;
ptr1[1] = cur_adr;
i_tree++;
pt1[0] = tn2;
pt1[1] = t;
}
else
{
CV_WRITE_SEQ_ELEM( tree_two, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( ptr2[0] != NULL )
ptr2[0]->prev_v = cur_adr;
if( ptr2[1] != NULL )
ptr2[1]->prev_v = cur_adr;
ptr1[0] = cur_adr;
i_tree++;
CV_WRITE_SEQ_ELEM( tree_one, writer );
cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
if( ptr2[2] != NULL )
ptr2[2]->prev_v = cur_adr;
if( ptr2[3] != NULL )
ptr2[3]->prev_v = cur_adr;
ptr1[1] = cur_adr;
i_tree++;
pt1[0] = t;
pt1[1] = tn2;
}
}
/* form root */
s = cvContourArea( contour );
tree_root->pt = pt1[1];
tree_root->sign = 0;
tree_root->area = fabs( s );
tree_root->r1 = 0;
tree_root->r2 = 0;
tree_root->next_v1 = ptr1[0];
tree_root->next_v2 = ptr1[1];
tree_root->prev_v = NULL;
ptr1[0]->prev_v = (_CvTrianAttr *) tree_root;
ptr1[1]->prev_v = (_CvTrianAttr *) tree_root;
/* write binary tree root */
/* CV_WRITE_SEQ_ELEM (tree_one, start_writer); */
i_tree++;
/* create Sequence hearder */
*((CvSeq **) tree) = cvEndWriteSeq( &writer );
/* write points for the main segment into sequence header */
(*tree)->p1 = pt1[0];
M_END:
cvFree( &ptr_n );
cvFree( &ptr_p );
cvFree( &num_n );
cvFree( &num_p );
cvFree( &pt_n );
cvFree( &pt_p );
return status;
}
/****************************************************************************************\
triangle attributes calculations
\****************************************************************************************/
static CvStatus
icvCalcTriAttr( const CvSeq * contour, CvPoint t2, CvPoint t1, int n1,
CvPoint t3, int n3, double *s, double *s_c,
double *h, double *a, double *b )
{
double x13, y13, x12, y12, l_base, nx, ny, qq;
double eps = 1.e-5;
x13 = t3.x - t1.x;
y13 = t3.y - t1.y;
x12 = t2.x - t1.x;
y12 = t2.y - t1.y;
qq = x13 * x13 + y13 * y13;
l_base = cvSqrt( (float) (qq) );
if( l_base > eps )
{
nx = y13 / l_base;
ny = -x13 / l_base;
*h = nx * x12 + ny * y12;
*s = (*h) * l_base / 2.;
*b = nx * y12 - ny * x12;
*a = l_base;
/* calculate interceptive area */
*s_c = cvContourArea( contour, cvSlice(n1, n3+1));
}
else
{
*h = 0;
*s = 0;
*s_c = 0;
*b = 0;
*a = 0;
}
return CV_OK;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvCreateContourTree
// Purpose:
// Create binary tree representation for the contour
// Context:
// Parameters:
// contour - pointer to input contour object.
// storage - pointer to the current storage block
// tree - output pointer to the binary tree representation
// threshold - threshold for the binary tree building
//
//F*/
CV_IMPL CvContourTree*
cvCreateContourTree( const CvSeq* contour, CvMemStorage* storage, double threshold )
{
CvContourTree* tree = 0;
CV_FUNCNAME( "cvCreateContourTree" );
__BEGIN__;
IPPI_CALL( icvCreateContourTree( contour, storage, &tree, threshold ));
__CLEANUP__;
__END__;
return tree;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvContourFromContourTree
// Purpose:
// reconstracts contour from binary tree representation
// Context:
// Parameters:
// tree - pointer to the input binary tree representation
// storage - pointer to the current storage block
// contour - pointer to output contour object.
// criteria - criteria for the definition threshold value
// for the contour reconstracting (level or precision)
//F*/
CV_IMPL CvSeq*
cvContourFromContourTree( const CvContourTree* tree,
CvMemStorage* storage,
CvTermCriteria criteria )
{
CvSeq* contour = 0;
_CvTrianAttr **ptr_buf = 0; /* pointer to the pointer's buffer */
int *level_buf = 0;
int i_buf;
int lpt;
double area_all;
double threshold;
int cur_level;
int level;
int seq_flags;
char log_iter, log_eps;
int out_hearder_size;
_CvTrianAttr *tree_one = 0, tree_root; /* current vertex */
CvSeqReader reader;
CvSeqWriter writer;
CV_FUNCNAME("cvContourFromContourTree");
__BEGIN__;
if( !tree )
CV_ERROR( CV_StsNullPtr, "" );
if( !CV_IS_SEQ_POLYGON_TREE( tree ))
CV_ERROR_FROM_STATUS( CV_BADFLAG_ERR );
criteria = cvCheckTermCriteria( criteria, 0., 100 );
lpt = tree->total;
ptr_buf = NULL;
level_buf = NULL;
i_buf = 0;
cur_level = 0;
log_iter = (char) (criteria.type == CV_TERMCRIT_ITER ||
(criteria.type == CV_TERMCRIT_ITER + CV_TERMCRIT_EPS));
log_eps = (char) (criteria.type == CV_TERMCRIT_EPS ||
(criteria.type == CV_TERMCRIT_ITER + CV_TERMCRIT_EPS));
cvStartReadSeq( (CvSeq *) tree, &reader, 0 );
out_hearder_size = sizeof( CvContour );
seq_flags = CV_SEQ_POLYGON;
cvStartWriteSeq( seq_flags, out_hearder_size, sizeof( CvPoint ), storage, &writer );
ptr_buf = (_CvTrianAttr **) cvAlloc( lpt * sizeof( _CvTrianAttr * ));
if( ptr_buf == NULL )
CV_ERROR_FROM_STATUS( CV_OUTOFMEM_ERR );
if( log_iter )
{
level_buf = (int *) cvAlloc( lpt * (sizeof( int )));
if( level_buf == NULL )
CV_ERROR_FROM_STATUS( CV_OUTOFMEM_ERR );
}
memset( ptr_buf, 0, lpt * sizeof( _CvTrianAttr * ));
/* write the first tree root's point as a start point of the result contour */
CV_WRITE_SEQ_ELEM( tree->p1, writer );
/* write the second tree root"s point into buffer */
/* read the root of the tree */
CV_READ_SEQ_ELEM( tree_root, reader );
tree_one = &tree_root;
area_all = tree_one->area;
if( log_eps )
threshold = criteria.epsilon * area_all;
else
threshold = 10 * area_all;
if( log_iter )
level = criteria.max_iter;
else
level = -1;
/* contour from binary tree constraction */
while( i_buf >= 0 )
{
if( tree_one != NULL && (cur_level <= level || tree_one->area >= threshold) )
/* go to left sub tree for the vertex and save pointer to the right vertex */
/* into the buffer */
{
ptr_buf[i_buf] = tree_one;
if( log_iter )
{
level_buf[i_buf] = cur_level;
cur_level++;
}
i_buf++;
tree_one = tree_one->next_v1;
}
else
{
i_buf--;
if( i_buf >= 0 )
{
CvPoint pt = ptr_buf[i_buf]->pt;
CV_WRITE_SEQ_ELEM( pt, writer );
tree_one = ptr_buf[i_buf]->next_v2;
if( log_iter )
{
cur_level = level_buf[i_buf] + 1;
}
}
}
}
contour = cvEndWriteSeq( &writer );
cvBoundingRect( contour, 1 );
__CLEANUP__;
__END__;
cvFree( &level_buf );
cvFree( &ptr_buf );
return contour;
}

View File

@@ -0,0 +1,851 @@
/*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*/
#include "_cv.h"
static int
icvSklansky_32s( CvPoint** array, int start, int end, int* stack, int nsign, int sign2 )
{
int incr = end > start ? 1 : -1;
/* prepare first triangle */
int pprev = start, pcur = pprev + incr, pnext = pcur + incr;
int stacksize = 3;
if( start == end ||
(array[start]->x == array[end]->x &&
array[start]->y == array[end]->y) )
{
stack[0] = start;
return 1;
}
stack[0] = pprev;
stack[1] = pcur;
stack[2] = pnext;
end += incr; /* make end = afterend */
while( pnext != end )
{
/* check the angle p1,p2,p3 */
int cury = array[pcur]->y;
int nexty = array[pnext]->y;
int by = nexty - cury;
if( CV_SIGN(by) != nsign )
{
int ax = array[pcur]->x - array[pprev]->x;
int bx = array[pnext]->x - array[pcur]->x;
int ay = cury - array[pprev]->y;
int convexity = ay*bx - ax*by;/* if >0 then convex angle */
if( CV_SIGN(convexity) == sign2 && (ax != 0 || ay != 0) )
{
pprev = pcur;
pcur = pnext;
pnext += incr;
stack[stacksize] = pnext;
stacksize++;
}
else
{
if( pprev == start )
{
pcur = pnext;
stack[1] = pcur;
pnext += incr;
stack[2] = pnext;
}
else
{
stack[stacksize-2] = pnext;
pcur = pprev;
pprev = stack[stacksize-4];
stacksize--;
}
}
}
else
{
pnext += incr;
stack[stacksize-1] = pnext;
}
}
return --stacksize;
}
static int
icvSklansky_32f( CvPoint2D32f** array, int start, int end, int* stack, int nsign, int sign2 )
{
int incr = end > start ? 1 : -1;
/* prepare first triangle */
int pprev = start, pcur = pprev + incr, pnext = pcur + incr;
int stacksize = 3;
if( start == end ||
(array[start]->x == array[end]->x &&
array[start]->y == array[end]->y) )
{
stack[0] = start;
return 1;
}
stack[0] = pprev;
stack[1] = pcur;
stack[2] = pnext;
end += incr; /* make end = afterend */
while( pnext != end )
{
/* check the angle p1,p2,p3 */
float cury = array[pcur]->y;
float nexty = array[pnext]->y;
float by = nexty - cury;
if( CV_SIGN( by ) != nsign )
{
float ax = array[pcur]->x - array[pprev]->x;
float bx = array[pnext]->x - array[pcur]->x;
float ay = cury - array[pprev]->y;
float convexity = ay*bx - ax*by;/* if >0 then convex angle */
if( CV_SIGN( convexity ) == sign2 && (ax != 0 || ay != 0) )
{
pprev = pcur;
pcur = pnext;
pnext += incr;
stack[stacksize] = pnext;
stacksize++;
}
else
{
if( pprev == start )
{
pcur = pnext;
stack[1] = pcur;
pnext += incr;
stack[2] = pnext;
}
else
{
stack[stacksize-2] = pnext;
pcur = pprev;
pprev = stack[stacksize-4];
stacksize--;
}
}
}
else
{
pnext += incr;
stack[stacksize-1] = pnext;
}
}
return --stacksize;
}
typedef int (*sklansky_func)( CvPoint** points, int start, int end,
int* stack, int sign, int sign2 );
#define cmp_pts( pt1, pt2 ) \
((pt1)->x < (pt2)->x || (pt1)->x <= (pt2)->x && (pt1)->y < (pt2)->y)
static CV_IMPLEMENT_QSORT( icvSortPointsByPointers_32s, CvPoint*, cmp_pts )
static CV_IMPLEMENT_QSORT( icvSortPointsByPointers_32f, CvPoint2D32f*, cmp_pts )
static void
icvCalcAndWritePtIndices( CvPoint** pointer, int* stack, int start, int end,
CvSeq* ptseq, CvSeqWriter* writer )
{
CV_FUNCNAME( "icvCalcAndWritePtIndices" );
__BEGIN__;
int i, incr = start < end ? 1 : -1;
int idx, first_idx = ptseq->first->start_index;
for( i = start; i != end; i += incr )
{
CvPoint* ptr = (CvPoint*)pointer[stack[i]];
CvSeqBlock* block = ptseq->first;
while( (unsigned)(idx = (int)(ptr - (CvPoint*)block->data)) >= (unsigned)block->count )
{
block = block->next;
if( block == ptseq->first )
CV_ERROR( CV_StsError, "Internal error" );
}
idx += block->start_index - first_idx;
CV_WRITE_SEQ_ELEM( idx, *writer );
}
__END__;
}
CV_IMPL CvSeq*
cvConvexHull2( const CvArr* array, void* hull_storage,
int orientation, int return_points )
{
union { CvContour* c; CvSeq* s; } hull;
CvPoint** pointer = 0;
CvPoint2D32f** pointerf = 0;
int* stack = 0;
CV_FUNCNAME( "cvConvexHull2" );
hull.s = 0;
__BEGIN__;
CvMat* mat = 0;
CvSeqReader reader;
CvSeqWriter writer;
CvContour contour_header;
union { CvContour c; CvSeq s; } hull_header;
CvSeqBlock block, hullblock;
CvSeq* ptseq = 0;
CvSeq* hullseq = 0;
int is_float;
int* t_stack;
int t_count;
int i, miny_ind = 0, maxy_ind = 0, total;
int hulltype;
int stop_idx;
sklansky_func sklansky;
if( CV_IS_SEQ( array ))
{
ptseq = (CvSeq*)array;
if( !CV_IS_SEQ_POINT_SET( ptseq ))
CV_ERROR( CV_StsBadArg, "Unsupported sequence type" );
if( hull_storage == 0 )
hull_storage = ptseq->storage;
}
else
{
CV_CALL( ptseq = cvPointSeqFromMat(
CV_SEQ_KIND_GENERIC, array, &contour_header, &block ));
}
if( CV_IS_STORAGE( hull_storage ))
{
if( return_points )
{
CV_CALL( hullseq = cvCreateSeq(
CV_SEQ_KIND_CURVE|CV_SEQ_ELTYPE(ptseq)|
CV_SEQ_FLAG_CLOSED|CV_SEQ_FLAG_CONVEX,
sizeof(CvContour), sizeof(CvPoint),(CvMemStorage*)hull_storage ));
}
else
{
CV_CALL( hullseq = cvCreateSeq(
CV_SEQ_KIND_CURVE|CV_SEQ_ELTYPE_PPOINT|
CV_SEQ_FLAG_CLOSED|CV_SEQ_FLAG_CONVEX,
sizeof(CvContour), sizeof(CvPoint*), (CvMemStorage*)hull_storage ));
}
}
else
{
if( !CV_IS_MAT( hull_storage ))
CV_ERROR(CV_StsBadArg, "Destination must be valid memory storage or matrix");
mat = (CvMat*)hull_storage;
if( mat->cols != 1 && mat->rows != 1 || !CV_IS_MAT_CONT(mat->type))
CV_ERROR( CV_StsBadArg,
"The hull matrix should be continuous and have a single row or a single column" );
if( mat->cols + mat->rows - 1 < ptseq->total )
CV_ERROR( CV_StsBadSize, "The hull matrix size might be not enough to fit the hull" );
if( CV_MAT_TYPE(mat->type) != CV_SEQ_ELTYPE(ptseq) &&
CV_MAT_TYPE(mat->type) != CV_32SC1 )
CV_ERROR( CV_StsUnsupportedFormat,
"The hull matrix must have the same type as input or 32sC1 (integers)" );
CV_CALL( hullseq = cvMakeSeqHeaderForArray(
CV_SEQ_KIND_CURVE|CV_MAT_TYPE(mat->type)|CV_SEQ_FLAG_CLOSED,
sizeof(contour_header), CV_ELEM_SIZE(mat->type), mat->data.ptr,
mat->cols + mat->rows - 1, &hull_header.s, &hullblock ));
cvClearSeq( hullseq );
}
total = ptseq->total;
if( total == 0 )
{
if( mat )
CV_ERROR( CV_StsBadSize,
"Point sequence can not be empty if the output is matrix" );
EXIT;
}
cvStartAppendToSeq( hullseq, &writer );
is_float = CV_SEQ_ELTYPE(ptseq) == CV_32FC2;
hulltype = CV_SEQ_ELTYPE(hullseq);
sklansky = !is_float ? (sklansky_func)icvSklansky_32s :
(sklansky_func)icvSklansky_32f;
CV_CALL( pointer = (CvPoint**)cvAlloc( ptseq->total*sizeof(pointer[0]) ));
CV_CALL( stack = (int*)cvAlloc( (ptseq->total + 2)*sizeof(stack[0]) ));
pointerf = (CvPoint2D32f**)pointer;
cvStartReadSeq( ptseq, &reader );
for( i = 0; i < total; i++ )
{
pointer[i] = (CvPoint*)reader.ptr;
CV_NEXT_SEQ_ELEM( ptseq->elem_size, reader );
}
// sort the point set by x-coordinate, find min and max y
if( !is_float )
{
icvSortPointsByPointers_32s( pointer, total, 0 );
for( i = 1; i < total; i++ )
{
int y = pointer[i]->y;
if( pointer[miny_ind]->y > y )
miny_ind = i;
if( pointer[maxy_ind]->y < y )
maxy_ind = i;
}
}
else
{
icvSortPointsByPointers_32f( pointerf, total, 0 );
for( i = 1; i < total; i++ )
{
float y = pointerf[i]->y;
if( pointerf[miny_ind]->y > y )
miny_ind = i;
if( pointerf[maxy_ind]->y < y )
maxy_ind = i;
}
}
if( pointer[0]->x == pointer[total-1]->x &&
pointer[0]->y == pointer[total-1]->y )
{
if( hulltype == CV_SEQ_ELTYPE_PPOINT )
{
CV_WRITE_SEQ_ELEM( pointer[0], writer );
}
else if( hulltype == CV_SEQ_ELTYPE_INDEX )
{
int index = 0;
CV_WRITE_SEQ_ELEM( index, writer );
}
else
{
CvPoint pt = pointer[0][0];
CV_WRITE_SEQ_ELEM( pt, writer );
}
goto finish_hull;
}
/*upper half */
{
int *tl_stack = stack;
int tl_count = sklansky( pointer, 0, maxy_ind, tl_stack, -1, 1 );
int *tr_stack = tl_stack + tl_count;
int tr_count = sklansky( pointer, ptseq->total - 1, maxy_ind, tr_stack, -1, -1 );
/* gather upper part of convex hull to output */
if( orientation == CV_COUNTER_CLOCKWISE )
{
CV_SWAP( tl_stack, tr_stack, t_stack );
CV_SWAP( tl_count, tr_count, t_count );
}
if( hulltype == CV_SEQ_ELTYPE_PPOINT )
{
for( i = 0; i < tl_count - 1; i++ )
CV_WRITE_SEQ_ELEM( pointer[tl_stack[i]], writer );
for( i = tr_count - 1; i > 0; i-- )
CV_WRITE_SEQ_ELEM( pointer[tr_stack[i]], writer );
}
else if( hulltype == CV_SEQ_ELTYPE_INDEX )
{
CV_CALL( icvCalcAndWritePtIndices( pointer, tl_stack,
0, tl_count-1, ptseq, &writer ));
CV_CALL( icvCalcAndWritePtIndices( pointer, tr_stack,
tr_count-1, 0, ptseq, &writer ));
}
else
{
for( i = 0; i < tl_count - 1; i++ )
CV_WRITE_SEQ_ELEM( pointer[tl_stack[i]][0], writer );
for( i = tr_count - 1; i > 0; i-- )
CV_WRITE_SEQ_ELEM( pointer[tr_stack[i]][0], writer );
}
stop_idx = tr_count > 2 ? tr_stack[1] : tl_count > 2 ? tl_stack[tl_count - 2] : -1;
}
/* lower half */
{
int *bl_stack = stack;
int bl_count = sklansky( pointer, 0, miny_ind, bl_stack, 1, -1 );
int *br_stack = stack + bl_count;
int br_count = sklansky( pointer, ptseq->total - 1, miny_ind, br_stack, 1, 1 );
if( orientation != CV_COUNTER_CLOCKWISE )
{
CV_SWAP( bl_stack, br_stack, t_stack );
CV_SWAP( bl_count, br_count, t_count );
}
if( stop_idx >= 0 )
{
int check_idx = bl_count > 2 ? bl_stack[1] :
bl_count + br_count > 2 ? br_stack[2-bl_count] : -1;
if( check_idx == stop_idx || check_idx >= 0 &&
pointer[check_idx]->x == pointer[stop_idx]->x &&
pointer[check_idx]->y == pointer[stop_idx]->y )
{
/* if all the points lie on the same line, then
the bottom part of the convex hull is the mirrored top part
(except the exteme points).*/
bl_count = MIN( bl_count, 2 );
br_count = MIN( br_count, 2 );
}
}
if( hulltype == CV_SEQ_ELTYPE_PPOINT )
{
for( i = 0; i < bl_count - 1; i++ )
CV_WRITE_SEQ_ELEM( pointer[bl_stack[i]], writer );
for( i = br_count - 1; i > 0; i-- )
CV_WRITE_SEQ_ELEM( pointer[br_stack[i]], writer );
}
else if( hulltype == CV_SEQ_ELTYPE_INDEX )
{
CV_CALL( icvCalcAndWritePtIndices( pointer, bl_stack,
0, bl_count-1, ptseq, &writer ));
CV_CALL( icvCalcAndWritePtIndices( pointer, br_stack,
br_count-1, 0, ptseq, &writer ));
}
else
{
for( i = 0; i < bl_count - 1; i++ )
CV_WRITE_SEQ_ELEM( pointer[bl_stack[i]][0], writer );
for( i = br_count - 1; i > 0; i-- )
CV_WRITE_SEQ_ELEM( pointer[br_stack[i]][0], writer );
}
}
finish_hull:
CV_CALL( cvEndWriteSeq( &writer ));
if( mat )
{
if( mat->rows > mat->cols )
mat->rows = hullseq->total;
else
mat->cols = hullseq->total;
}
else
{
hull.s = hullseq;
hull.c->rect = cvBoundingRect( ptseq,
ptseq->header_size < (int)sizeof(CvContour) ||
&ptseq->flags == &contour_header.flags );
/*if( ptseq != (CvSeq*)&contour_header )
hullseq->v_prev = ptseq;*/
}
__END__;
cvFree( &pointer );
cvFree( &stack );
return hull.s;
}
/* contour must be a simple polygon */
/* it must have more than 3 points */
CV_IMPL CvSeq*
cvConvexityDefects( const CvArr* array,
const CvArr* hullarray,
CvMemStorage* storage )
{
CvSeq* defects = 0;
CV_FUNCNAME( "cvConvexityDefects" );
__BEGIN__;
int i, index;
CvPoint* hull_cur;
/* is orientation of hull different from contour one */
int rev_orientation;
CvContour contour_header;
union { CvContour c; CvSeq s; } hull_header;
CvSeqBlock block, hullblock;
CvSeq *ptseq = (CvSeq*)array, *hull = (CvSeq*)hullarray;
CvSeqReader hull_reader;
CvSeqReader ptseq_reader;
CvSeqWriter writer;
int is_index;
if( CV_IS_SEQ( ptseq ))
{
if( !CV_IS_SEQ_POINT_SET( ptseq ))
CV_ERROR( CV_StsUnsupportedFormat,
"Input sequence is not a sequence of points" );
if( !storage )
storage = ptseq->storage;
}
else
{
CV_CALL( ptseq = cvPointSeqFromMat(
CV_SEQ_KIND_GENERIC, array, &contour_header, &block ));
}
if( CV_SEQ_ELTYPE( ptseq ) != CV_32SC2 )
CV_ERROR( CV_StsUnsupportedFormat,
"Floating-point coordinates are not supported here" );
if( CV_IS_SEQ( hull ))
{
int hulltype = CV_SEQ_ELTYPE( hull );
if( hulltype != CV_SEQ_ELTYPE_PPOINT && hulltype != CV_SEQ_ELTYPE_INDEX )
CV_ERROR( CV_StsUnsupportedFormat,
"Convex hull must represented as a sequence "
"of indices or sequence of pointers" );
if( !storage )
storage = hull->storage;
}
else
{
CvMat* mat = (CvMat*)hull;
if( !CV_IS_MAT( hull ))
CV_ERROR(CV_StsBadArg, "Convex hull is neither sequence nor matrix");
if( mat->cols != 1 && mat->rows != 1 ||
!CV_IS_MAT_CONT(mat->type) || CV_MAT_TYPE(mat->type) != CV_32SC1 )
CV_ERROR( CV_StsBadArg,
"The matrix should be 1-dimensional and continuous array of int's" );
if( mat->cols + mat->rows - 1 > ptseq->total )
CV_ERROR( CV_StsBadSize, "Convex hull is larger than the point sequence" );
CV_CALL( hull = cvMakeSeqHeaderForArray(
CV_SEQ_KIND_CURVE|CV_MAT_TYPE(mat->type)|CV_SEQ_FLAG_CLOSED,
sizeof(CvContour), CV_ELEM_SIZE(mat->type), mat->data.ptr,
mat->cols + mat->rows - 1, &hull_header.s, &hullblock ));
}
is_index = CV_SEQ_ELTYPE(hull) == CV_SEQ_ELTYPE_INDEX;
if( !storage )
CV_ERROR( CV_StsNullPtr, "NULL storage pointer" );
CV_CALL( defects = cvCreateSeq( CV_SEQ_KIND_GENERIC, sizeof(CvSeq),
sizeof(CvConvexityDefect), storage ));
if( ptseq->total < 4 || hull->total < 3)
{
//CV_ERROR( CV_StsBadSize,
// "point seq size must be >= 4, convex hull size must be >= 3" );
EXIT;
}
/* recognize co-orientation of ptseq and its hull */
{
int sign = 0;
int index1, index2, index3;
if( !is_index )
{
CvPoint* pos = *CV_SEQ_ELEM( hull, CvPoint*, 0 );
CV_CALL( index1 = cvSeqElemIdx( ptseq, pos ));
pos = *CV_SEQ_ELEM( hull, CvPoint*, 1 );
CV_CALL( index2 = cvSeqElemIdx( ptseq, pos ));
pos = *CV_SEQ_ELEM( hull, CvPoint*, 2 );
CV_CALL( index3 = cvSeqElemIdx( ptseq, pos ));
}
else
{
index1 = *CV_SEQ_ELEM( hull, int, 0 );
index2 = *CV_SEQ_ELEM( hull, int, 1 );
index3 = *CV_SEQ_ELEM( hull, int, 2 );
}
sign += (index2 > index1) ? 1 : 0;
sign += (index3 > index2) ? 1 : 0;
sign += (index1 > index3) ? 1 : 0;
rev_orientation = (sign == 2) ? 0 : 1;
}
cvStartReadSeq( ptseq, &ptseq_reader, 0 );
cvStartReadSeq( hull, &hull_reader, rev_orientation );
if( !is_index )
{
hull_cur = *(CvPoint**)hull_reader.prev_elem;
index = cvSeqElemIdx( ptseq, (char*)hull_cur, 0 );
}
else
{
index = *(int*)hull_reader.prev_elem;
hull_cur = CV_GET_SEQ_ELEM( CvPoint, ptseq, index );
}
cvSetSeqReaderPos( &ptseq_reader, index );
cvStartAppendToSeq( defects, &writer );
/* cycle through ptseq and hull with computing defects */
for( i = 0; i < hull->total; i++ )
{
CvConvexityDefect defect;
int is_defect = 0;
double dx0, dy0;
double depth = 0, scale;
CvPoint* hull_next;
if( !is_index )
hull_next = *(CvPoint**)hull_reader.ptr;
else
{
int t = *(int*)hull_reader.ptr;
hull_next = CV_GET_SEQ_ELEM( CvPoint, ptseq, t );
}
dx0 = (double)hull_next->x - (double)hull_cur->x;
dy0 = (double)hull_next->y - (double)hull_cur->y;
assert( dx0 != 0 || dy0 != 0 );
scale = 1./sqrt(dx0*dx0 + dy0*dy0);
defect.start = hull_cur;
defect.end = hull_next;
for(;;)
{
/* go through ptseq to achieve next hull point */
CV_NEXT_SEQ_ELEM( sizeof(CvPoint), ptseq_reader );
if( ptseq_reader.ptr == (char*)hull_next )
break;
else
{
CvPoint* cur = (CvPoint*)ptseq_reader.ptr;
/* compute distance from current point to hull edge */
double dx = (double)cur->x - (double)hull_cur->x;
double dy = (double)cur->y - (double)hull_cur->y;
/* compute depth */
double dist = fabs(-dy0*dx + dx0*dy) * scale;
if( dist > depth )
{
depth = dist;
defect.depth_point = cur;
defect.depth = (float)depth;
is_defect = 1;
}
}
}
if( is_defect )
{
CV_WRITE_SEQ_ELEM( defect, writer );
}
hull_cur = hull_next;
if( rev_orientation )
{
CV_PREV_SEQ_ELEM( hull->elem_size, hull_reader );
}
else
{
CV_NEXT_SEQ_ELEM( hull->elem_size, hull_reader );
}
}
defects = cvEndWriteSeq( &writer );
__END__;
return defects;
}
CV_IMPL int
cvCheckContourConvexity( const CvArr* array )
{
int flag = -1;
CV_FUNCNAME( "cvCheckContourConvexity" );
__BEGIN__;
int i;
int orientation = 0;
CvSeqReader reader;
CvContour contour_header;
CvSeqBlock block;
CvSeq* contour = (CvSeq*)array;
if( CV_IS_SEQ(contour) )
{
if( !CV_IS_SEQ_POLYGON(contour))
CV_ERROR( CV_StsUnsupportedFormat,
"Input sequence must be polygon (closed 2d curve)" );
}
else
{
CV_CALL( contour = cvPointSeqFromMat(
CV_SEQ_KIND_CURVE|CV_SEQ_FLAG_CLOSED, array, &contour_header, &block ));
}
if( contour->total == 0 )
EXIT;
cvStartReadSeq( contour, &reader, 0 );
flag = 1;
if( CV_SEQ_ELTYPE( contour ) == CV_32SC2 )
{
CvPoint *prev_pt = (CvPoint*)reader.prev_elem;
CvPoint *cur_pt = (CvPoint*)reader.ptr;
int dx0 = cur_pt->x - prev_pt->x;
int dy0 = cur_pt->y - prev_pt->y;
for( i = 0; i < contour->total; i++ )
{
int dxdy0, dydx0;
int dx, dy;
/*int orient; */
CV_NEXT_SEQ_ELEM( sizeof(CvPoint), reader );
prev_pt = cur_pt;
cur_pt = (CvPoint *) reader.ptr;
dx = cur_pt->x - prev_pt->x;
dy = cur_pt->y - prev_pt->y;
dxdy0 = dx * dy0;
dydx0 = dy * dx0;
/* find orientation */
/*orient = -dy0 * dx + dx0 * dy;
orientation |= (orient > 0) ? 1 : 2;
*/
orientation |= (dydx0 > dxdy0) ? 1 : ((dydx0 < dxdy0) ? 2 : 3);
if( orientation == 3 )
{
flag = 0;
break;
}
dx0 = dx;
dy0 = dy;
}
}
else
{
assert( CV_SEQ_ELTYPE(contour) == CV_32FC2 );
CvPoint2D32f *prev_pt = (CvPoint2D32f*)reader.prev_elem;
CvPoint2D32f *cur_pt = (CvPoint2D32f*)reader.ptr;
float dx0 = cur_pt->x - prev_pt->x;
float dy0 = cur_pt->y - prev_pt->y;
for( i = 0; i < contour->total; i++ )
{
float dxdy0, dydx0;
float dx, dy;
/*int orient; */
CV_NEXT_SEQ_ELEM( sizeof(CvPoint2D32f), reader );
prev_pt = cur_pt;
cur_pt = (CvPoint2D32f*) reader.ptr;
dx = cur_pt->x - prev_pt->x;
dy = cur_pt->y - prev_pt->y;
dxdy0 = dx * dy0;
dydx0 = dy * dx0;
/* find orientation */
/*orient = -dy0 * dx + dx0 * dy;
orientation |= (orient > 0) ? 1 : 2;
*/
orientation |= (dydx0 > dxdy0) ? 1 : ((dydx0 < dxdy0) ? 2 : 3);
if( orientation == 3 )
{
flag = 0;
break;
}
dx0 = dx;
dy0 = dy;
}
}
__END__;
return flag;
}
/* End of file. */

View File

@@ -0,0 +1,44 @@
/*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*/
#include "_cv.h"
/* End of file. */

View File

@@ -0,0 +1,706 @@
/*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*/
#include "_cv.h"
#include <stdio.h>
static void
icvCalcMinEigenVal( const float* cov, int cov_step, float* dst,
int dst_step, CvSize size, CvMat* buffer )
{
int j;
float* buf = buffer->data.fl;
cov_step /= sizeof(cov[0]);
dst_step /= sizeof(dst[0]);
buffer->rows = 1;
for( ; size.height--; cov += cov_step, dst += dst_step )
{
for( j = 0; j < size.width; j++ )
{
double a = cov[j*3]*0.5;
double b = cov[j*3+1];
double c = cov[j*3+2]*0.5;
buf[j + size.width] = (float)(a + c);
buf[j] = (float)((a - c)*(a - c) + b*b);
}
cvPow( buffer, buffer, 0.5 );
for( j = 0; j < size.width ; j++ )
dst[j] = (float)(buf[j + size.width] - buf[j]);
}
}
static void
icvCalcHarris( const float* cov, int cov_step, float* dst,
int dst_step, CvSize size, CvMat* /*buffer*/, double k )
{
int j;
cov_step /= sizeof(cov[0]);
dst_step /= sizeof(dst[0]);
for( ; size.height--; cov += cov_step, dst += dst_step )
{
for( j = 0; j < size.width; j++ )
{
double a = cov[j*3];
double b = cov[j*3+1];
double c = cov[j*3+2];
dst[j] = (float)(a*c - b*b - k*(a + c)*(a + c));
}
}
}
static void
icvCalcEigenValsVecs( const float* cov, int cov_step, float* dst,
int dst_step, CvSize size, CvMat* buffer )
{
static int y0 = 0;
int j;
float* buf = buffer->data.fl;
cov_step /= sizeof(cov[0]);
dst_step /= sizeof(dst[0]);
for( ; size.height--; cov += cov_step, dst += dst_step )
{
for( j = 0; j < size.width; j++ )
{
double a = cov[j*3]*0.5;
double b = cov[j*3+1];
double c = cov[j*3+2]*0.5;
buf[j + size.width] = (float)(a + c);
buf[j] = (float)((a - c)*(a - c) + b*b);
}
buffer->rows = 1;
cvPow( buffer, buffer, 0.5 );
for( j = 0; j < size.width; j++ )
{
double a = cov[j*3];
double b = cov[j*3+1];
double c = cov[j*3+2];
double l1 = buf[j + size.width] + buf[j];
double l2 = buf[j + size.width] - buf[j];
double x = b;
double y = l1 - a;
double e = fabs(x);
if( e + fabs(y) < 1e-4 )
{
y = b;
x = l1 - c;
e = fabs(x);
if( e + fabs(y) < 1e-4 )
{
e = 1./(e + fabs(y) + FLT_EPSILON);
x *= e, y *= e;
}
}
buf[j] = (float)(x*x + y*y + DBL_EPSILON);
dst[6*j] = (float)l1;
dst[6*j + 2] = (float)x;
dst[6*j + 3] = (float)y;
x = b;
y = l2 - a;
e = fabs(x);
if( e + fabs(y) < 1e-4 )
{
y = b;
x = l2 - c;
e = fabs(x);
if( e + fabs(y) < 1e-4 )
{
e = 1./(e + fabs(y) + FLT_EPSILON);
x *= e, y *= e;
}
}
buf[j + size.width] = (float)(x*x + y*y + DBL_EPSILON);
dst[6*j + 1] = (float)l2;
dst[6*j + 4] = (float)x;
dst[6*j + 5] = (float)y;
}
buffer->rows = 2;
cvPow( buffer, buffer, -0.5 );
for( j = 0; j < size.width; j++ )
{
double t0 = buf[j]*dst[6*j + 2];
double t1 = buf[j]*dst[6*j + 3];
dst[6*j + 2] = (float)t0;
dst[6*j + 3] = (float)t1;
t0 = buf[j + size.width]*dst[6*j + 4];
t1 = buf[j + size.width]*dst[6*j + 5];
dst[6*j + 4] = (float)t0;
dst[6*j + 5] = (float)t1;
}
y0++;
}
}
#define ICV_MINEIGENVAL 0
#define ICV_HARRIS 1
#define ICV_EIGENVALSVECS 2
static void
icvCornerEigenValsVecs( const CvMat* src, CvMat* eigenv, int block_size,
int aperture_size, int op_type, double k=0. )
{
CvSepFilter dx_filter, dy_filter;
CvBoxFilter blur_filter;
CvMat *tempsrc = 0;
CvMat *Dx = 0, *Dy = 0, *cov = 0;
CvMat *sqrt_buf = 0;
int buf_size = 1 << 12;
CV_FUNCNAME( "icvCornerEigenValsVecs" );
__BEGIN__;
int i, j, y, dst_y = 0, max_dy, delta = 0;
int aperture_size0 = aperture_size;
int temp_step = 0, d_step;
uchar* shifted_ptr = 0;
int depth, d_depth;
int stage = CV_START;
CvSobelFixedIPPFunc ipp_sobel_vert = 0, ipp_sobel_horiz = 0;
CvFilterFixedIPPFunc ipp_scharr_vert = 0, ipp_scharr_horiz = 0;
CvSize el_size, size, stripe_size;
int aligned_width;
CvPoint el_anchor;
double factorx, factory;
bool use_ipp = false;
if( block_size < 3 || !(block_size & 1) )
CV_ERROR( CV_StsOutOfRange, "averaging window size must be an odd number >= 3" );
if( aperture_size < 3 && aperture_size != CV_SCHARR || !(aperture_size & 1) )
CV_ERROR( CV_StsOutOfRange,
"Derivative filter aperture size must be a positive odd number >=3 or CV_SCHARR" );
depth = CV_MAT_DEPTH(src->type);
d_depth = depth == CV_8U ? CV_16S : CV_32F;
size = cvGetMatSize(src);
aligned_width = cvAlign(size.width, 4);
aperture_size = aperture_size == CV_SCHARR ? 3 : aperture_size;
el_size = cvSize( aperture_size, aperture_size );
el_anchor = cvPoint( aperture_size/2, aperture_size/2 );
if( aperture_size <= 5 && icvFilterSobelVert_8u16s_C1R_p )
{
if( depth == CV_8U && aperture_size0 == CV_SCHARR )
{
ipp_scharr_vert = icvFilterScharrVert_8u16s_C1R_p;
ipp_scharr_horiz = icvFilterScharrHoriz_8u16s_C1R_p;
}
else if( depth == CV_32F && aperture_size0 == CV_SCHARR )
{
ipp_scharr_vert = icvFilterScharrVert_32f_C1R_p;
ipp_scharr_horiz = icvFilterScharrHoriz_32f_C1R_p;
}
else if( depth == CV_8U )
{
ipp_sobel_vert = icvFilterSobelVert_8u16s_C1R_p;
ipp_sobel_horiz = icvFilterSobelHoriz_8u16s_C1R_p;
}
else if( depth == CV_32F )
{
ipp_sobel_vert = icvFilterSobelVert_32f_C1R_p;
ipp_sobel_horiz = icvFilterSobelHoriz_32f_C1R_p;
}
}
if( ipp_sobel_vert && ipp_sobel_horiz ||
ipp_scharr_vert && ipp_scharr_horiz )
{
CV_CALL( tempsrc = icvIPPFilterInit( src, buf_size,
cvSize(el_size.width,el_size.height + block_size)));
shifted_ptr = tempsrc->data.ptr + el_anchor.y*tempsrc->step +
el_anchor.x*CV_ELEM_SIZE(depth);
temp_step = tempsrc->step ? tempsrc->step : CV_STUB_STEP;
max_dy = tempsrc->rows - aperture_size + 1;
use_ipp = true;
}
else
{
ipp_sobel_vert = ipp_sobel_horiz = 0;
ipp_scharr_vert = ipp_scharr_horiz = 0;
CV_CALL( dx_filter.init_deriv( size.width, depth, d_depth, 1, 0, aperture_size0 ));
CV_CALL( dy_filter.init_deriv( size.width, depth, d_depth, 0, 1, aperture_size0 ));
max_dy = buf_size / src->cols;
max_dy = MAX( max_dy, aperture_size + block_size );
}
CV_CALL( Dx = cvCreateMat( max_dy, aligned_width, d_depth ));
CV_CALL( Dy = cvCreateMat( max_dy, aligned_width, d_depth ));
CV_CALL( cov = cvCreateMat( max_dy + block_size + 1, size.width, CV_32FC3 ));
CV_CALL( sqrt_buf = cvCreateMat( 2, size.width, CV_32F ));
Dx->cols = Dy->cols = size.width;
if( !use_ipp )
max_dy -= aperture_size - 1;
d_step = Dx->step ? Dx->step : CV_STUB_STEP;
CV_CALL(blur_filter.init(size.width, CV_32FC3, CV_32FC3, 0, cvSize(block_size,block_size)));
stripe_size = size;
factorx = (double)(1 << (aperture_size - 1)) * block_size;
if( aperture_size0 == CV_SCHARR )
factorx *= 2;
if( depth == CV_8U )
factorx *= 255.;
factory = factorx = 1./factorx;
if( ipp_sobel_vert )
factory = -factory;
for( y = 0; y < size.height; y += delta )
{
if( !use_ipp )
{
delta = MIN( size.height - y, max_dy );
if( y + delta == size.height )
stage = stage & CV_START ? CV_START + CV_END : CV_END;
dx_filter.process( src, Dx, cvRect(0,y,-1,delta), cvPoint(0,0), stage );
stripe_size.height = dy_filter.process( src, Dy, cvRect(0,y,-1,delta),
cvPoint(0,0), stage );
}
else
{
delta = icvIPPFilterNextStripe( src, tempsrc, y, el_size, el_anchor );
stripe_size.height = delta;
if( ipp_sobel_vert )
{
IPPI_CALL( ipp_sobel_vert( shifted_ptr, temp_step,
Dx->data.ptr, d_step, stripe_size,
aperture_size*10 + aperture_size ));
IPPI_CALL( ipp_sobel_horiz( shifted_ptr, temp_step,
Dy->data.ptr, d_step, stripe_size,
aperture_size*10 + aperture_size ));
}
else /*if( ipp_scharr_vert )*/
{
IPPI_CALL( ipp_scharr_vert( shifted_ptr, temp_step,
Dx->data.ptr, d_step, stripe_size ));
IPPI_CALL( ipp_scharr_horiz( shifted_ptr, temp_step,
Dy->data.ptr, d_step, stripe_size ));
}
}
for( i = 0; i < stripe_size.height; i++ )
{
float* cov_data = (float*)(cov->data.ptr + i*cov->step);
if( d_depth == CV_16S )
{
const short* dxdata = (const short*)(Dx->data.ptr + i*Dx->step);
const short* dydata = (const short*)(Dy->data.ptr + i*Dy->step);
for( j = 0; j < size.width; j++ )
{
double dx = dxdata[j]*factorx;
double dy = dydata[j]*factory;
cov_data[j*3] = (float)(dx*dx);
cov_data[j*3+1] = (float)(dx*dy);
cov_data[j*3+2] = (float)(dy*dy);
}
}
else
{
const float* dxdata = (const float*)(Dx->data.ptr + i*Dx->step);
const float* dydata = (const float*)(Dy->data.ptr + i*Dy->step);
for( j = 0; j < size.width; j++ )
{
double dx = dxdata[j]*factorx;
double dy = dydata[j]*factory;
cov_data[j*3] = (float)(dx*dx);
cov_data[j*3+1] = (float)(dx*dy);
cov_data[j*3+2] = (float)(dy*dy);
}
}
}
if( y + stripe_size.height >= size.height )
stage = stage & CV_START ? CV_START + CV_END : CV_END;
stripe_size.height = blur_filter.process(cov,cov,
cvRect(0,0,-1,stripe_size.height),cvPoint(0,0),stage+CV_ISOLATED_ROI);
if( op_type == ICV_MINEIGENVAL )
icvCalcMinEigenVal( cov->data.fl, cov->step,
(float*)(eigenv->data.ptr + dst_y*eigenv->step), eigenv->step,
stripe_size, sqrt_buf );
else if( op_type == ICV_HARRIS )
icvCalcHarris( cov->data.fl, cov->step,
(float*)(eigenv->data.ptr + dst_y*eigenv->step), eigenv->step,
stripe_size, sqrt_buf, k );
else if( op_type == ICV_EIGENVALSVECS )
icvCalcEigenValsVecs( cov->data.fl, cov->step,
(float*)(eigenv->data.ptr + dst_y*eigenv->step), eigenv->step,
stripe_size, sqrt_buf );
dst_y += stripe_size.height;
stage = CV_MIDDLE;
}
__END__;
cvReleaseMat( &Dx );
cvReleaseMat( &Dy );
cvReleaseMat( &cov );
cvReleaseMat( &sqrt_buf );
cvReleaseMat( &tempsrc );
}
CV_IMPL void
cvCornerMinEigenVal( const void* srcarr, void* eigenvarr,
int block_size, int aperture_size )
{
CV_FUNCNAME( "cvCornerMinEigenVal" );
__BEGIN__;
CvMat stub, *src = (CvMat*)srcarr;
CvMat eigstub, *eigenv = (CvMat*)eigenvarr;
CV_CALL( src = cvGetMat( srcarr, &stub ));
CV_CALL( eigenv = cvGetMat( eigenv, &eigstub ));
if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
CV_MAT_TYPE(eigenv->type) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );
if( !CV_ARE_SIZES_EQ( src, eigenv ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
CV_CALL( icvCornerEigenValsVecs( src, eigenv, block_size, aperture_size, ICV_MINEIGENVAL ));
__END__;
}
CV_IMPL void
cvCornerHarris( const CvArr* srcarr, CvArr* harris_responce,
int block_size, int aperture_size, double k )
{
CV_FUNCNAME( "cvCornerHarris" );
__BEGIN__;
CvMat stub, *src = (CvMat*)srcarr;
CvMat eigstub, *eigenv = (CvMat*)harris_responce;
CV_CALL( src = cvGetMat( srcarr, &stub ));
CV_CALL( eigenv = cvGetMat( eigenv, &eigstub ));
if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
CV_MAT_TYPE(eigenv->type) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );
if( !CV_ARE_SIZES_EQ( src, eigenv ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
CV_CALL( icvCornerEigenValsVecs( src, eigenv, block_size, aperture_size, ICV_HARRIS, k ));
__END__;
}
CV_IMPL void
cvCornerEigenValsAndVecs( const void* srcarr, void* eigenvarr,
int block_size, int aperture_size )
{
CV_FUNCNAME( "cvCornerEigenValsAndVecs" );
__BEGIN__;
CvMat stub, *src = (CvMat*)srcarr;
CvMat eigstub, *eigenv = (CvMat*)eigenvarr;
CV_CALL( src = cvGetMat( srcarr, &stub ));
CV_CALL( eigenv = cvGetMat( eigenv, &eigstub ));
if( CV_MAT_CN(eigenv->type)*eigenv->cols != src->cols*6 ||
eigenv->rows != src->rows )
CV_ERROR( CV_StsUnmatchedSizes, "Output array should be 6 times "
"wider than the input array and they should have the same height");
if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
CV_MAT_TYPE(eigenv->type) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );
CV_CALL( icvCornerEigenValsVecs( src, eigenv, block_size, aperture_size, ICV_EIGENVALSVECS ));
__END__;
}
CV_IMPL void
cvPreCornerDetect( const void* srcarr, void* dstarr, int aperture_size )
{
CvSepFilter dx_filter, dy_filter, d2x_filter, d2y_filter, dxy_filter;
CvMat *Dx = 0, *Dy = 0, *D2x = 0, *D2y = 0, *Dxy = 0;
CvMat *tempsrc = 0;
int buf_size = 1 << 12;
CV_FUNCNAME( "cvPreCornerDetect" );
__BEGIN__;
int i, j, y, dst_y = 0, max_dy, delta = 0;
int temp_step = 0, d_step;
uchar* shifted_ptr = 0;
int depth, d_depth;
int stage = CV_START;
CvSobelFixedIPPFunc ipp_sobel_vert = 0, ipp_sobel_horiz = 0,
ipp_sobel_vert_second = 0, ipp_sobel_horiz_second = 0,
ipp_sobel_cross = 0;
CvSize el_size, size, stripe_size;
int aligned_width;
CvPoint el_anchor;
double factor;
CvMat stub, *src = (CvMat*)srcarr;
CvMat dststub, *dst = (CvMat*)dstarr;
bool use_ipp = false;
CV_CALL( src = cvGetMat( srcarr, &stub ));
CV_CALL( dst = cvGetMat( dst, &dststub ));
if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
CV_MAT_TYPE(dst->type) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );
if( !CV_ARE_SIZES_EQ( src, dst ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( aperture_size == CV_SCHARR )
CV_ERROR( CV_StsOutOfRange, "CV_SCHARR is not supported by this function" );
if( aperture_size < 3 || aperture_size > 7 || !(aperture_size & 1) )
CV_ERROR( CV_StsOutOfRange,
"Derivative filter aperture size must be 3, 5 or 7" );
depth = CV_MAT_DEPTH(src->type);
d_depth = depth == CV_8U ? CV_16S : CV_32F;
size = cvGetMatSize(src);
aligned_width = cvAlign(size.width, 4);
el_size = cvSize( aperture_size, aperture_size );
el_anchor = cvPoint( aperture_size/2, aperture_size/2 );
if( aperture_size <= 5 && icvFilterSobelVert_8u16s_C1R_p )
{
if( depth == CV_8U )
{
ipp_sobel_vert = icvFilterSobelVert_8u16s_C1R_p;
ipp_sobel_horiz = icvFilterSobelHoriz_8u16s_C1R_p;
ipp_sobel_vert_second = icvFilterSobelVertSecond_8u16s_C1R_p;
ipp_sobel_horiz_second = icvFilterSobelHorizSecond_8u16s_C1R_p;
ipp_sobel_cross = icvFilterSobelCross_8u16s_C1R_p;
}
else if( depth == CV_32F )
{
ipp_sobel_vert = icvFilterSobelVert_32f_C1R_p;
ipp_sobel_horiz = icvFilterSobelHoriz_32f_C1R_p;
ipp_sobel_vert_second = icvFilterSobelVertSecond_32f_C1R_p;
ipp_sobel_horiz_second = icvFilterSobelHorizSecond_32f_C1R_p;
ipp_sobel_cross = icvFilterSobelCross_32f_C1R_p;
}
}
if( ipp_sobel_vert && ipp_sobel_horiz && ipp_sobel_vert_second &&
ipp_sobel_horiz_second && ipp_sobel_cross )
{
CV_CALL( tempsrc = icvIPPFilterInit( src, buf_size, el_size ));
shifted_ptr = tempsrc->data.ptr + el_anchor.y*tempsrc->step +
el_anchor.x*CV_ELEM_SIZE(depth);
temp_step = tempsrc->step ? tempsrc->step : CV_STUB_STEP;
max_dy = tempsrc->rows - aperture_size + 1;
use_ipp = true;
}
else
{
ipp_sobel_vert = ipp_sobel_horiz = 0;
ipp_sobel_vert_second = ipp_sobel_horiz_second = ipp_sobel_cross = 0;
dx_filter.init_deriv( size.width, depth, d_depth, 1, 0, aperture_size );
dy_filter.init_deriv( size.width, depth, d_depth, 0, 1, aperture_size );
d2x_filter.init_deriv( size.width, depth, d_depth, 2, 0, aperture_size );
d2y_filter.init_deriv( size.width, depth, d_depth, 0, 2, aperture_size );
dxy_filter.init_deriv( size.width, depth, d_depth, 1, 1, aperture_size );
max_dy = buf_size / src->cols;
max_dy = MAX( max_dy, aperture_size );
}
CV_CALL( Dx = cvCreateMat( max_dy, aligned_width, d_depth ));
CV_CALL( Dy = cvCreateMat( max_dy, aligned_width, d_depth ));
CV_CALL( D2x = cvCreateMat( max_dy, aligned_width, d_depth ));
CV_CALL( D2y = cvCreateMat( max_dy, aligned_width, d_depth ));
CV_CALL( Dxy = cvCreateMat( max_dy, aligned_width, d_depth ));
Dx->cols = Dy->cols = D2x->cols = D2y->cols = Dxy->cols = size.width;
if( !use_ipp )
max_dy -= aperture_size - 1;
d_step = Dx->step ? Dx->step : CV_STUB_STEP;
stripe_size = size;
factor = 1 << (aperture_size - 1);
if( depth == CV_8U )
factor *= 255;
factor = 1./(factor * factor * factor);
aperture_size = aperture_size * 10 + aperture_size;
for( y = 0; y < size.height; y += delta )
{
if( !use_ipp )
{
delta = MIN( size.height - y, max_dy );
CvRect roi = cvRect(0,y,size.width,delta);
CvPoint origin=cvPoint(0,0);
if( y + delta == size.height )
stage = stage & CV_START ? CV_START + CV_END : CV_END;
dx_filter.process(src,Dx,roi,origin,stage);
dy_filter.process(src,Dy,roi,origin,stage);
d2x_filter.process(src,D2x,roi,origin,stage);
d2y_filter.process(src,D2y,roi,origin,stage);
stripe_size.height = dxy_filter.process(src,Dxy,roi,origin,stage);
}
else
{
delta = icvIPPFilterNextStripe( src, tempsrc, y, el_size, el_anchor );
stripe_size.height = delta;
IPPI_CALL( ipp_sobel_vert( shifted_ptr, temp_step,
Dx->data.ptr, d_step, stripe_size, aperture_size ));
IPPI_CALL( ipp_sobel_horiz( shifted_ptr, temp_step,
Dy->data.ptr, d_step, stripe_size, aperture_size ));
IPPI_CALL( ipp_sobel_vert_second( shifted_ptr, temp_step,
D2x->data.ptr, d_step, stripe_size, aperture_size ));
IPPI_CALL( ipp_sobel_horiz_second( shifted_ptr, temp_step,
D2y->data.ptr, d_step, stripe_size, aperture_size ));
IPPI_CALL( ipp_sobel_cross( shifted_ptr, temp_step,
Dxy->data.ptr, d_step, stripe_size, aperture_size ));
}
for( i = 0; i < stripe_size.height; i++, dst_y++ )
{
float* dstdata = (float*)(dst->data.ptr + dst_y*dst->step);
if( d_depth == CV_16S )
{
const short* dxdata = (const short*)(Dx->data.ptr + i*Dx->step);
const short* dydata = (const short*)(Dy->data.ptr + i*Dy->step);
const short* d2xdata = (const short*)(D2x->data.ptr + i*D2x->step);
const short* d2ydata = (const short*)(D2y->data.ptr + i*D2y->step);
const short* dxydata = (const short*)(Dxy->data.ptr + i*Dxy->step);
for( j = 0; j < stripe_size.width; j++ )
{
double dx = dxdata[j];
double dx2 = dx * dx;
double dy = dydata[j];
double dy2 = dy * dy;
dstdata[j] = (float)(factor*(dx2*d2ydata[j] + dy2*d2xdata[j] - 2*dx*dy*dxydata[j]));
}
}
else
{
const float* dxdata = (const float*)(Dx->data.ptr + i*Dx->step);
const float* dydata = (const float*)(Dy->data.ptr + i*Dy->step);
const float* d2xdata = (const float*)(D2x->data.ptr + i*D2x->step);
const float* d2ydata = (const float*)(D2y->data.ptr + i*D2y->step);
const float* dxydata = (const float*)(Dxy->data.ptr + i*Dxy->step);
for( j = 0; j < stripe_size.width; j++ )
{
double dx = dxdata[j];
double dy = dydata[j];
dstdata[j] = (float)(factor*(dx*dx*d2ydata[j] + dy*dy*d2xdata[j] - 2*dx*dy*dxydata[j]));
}
}
}
stage = CV_MIDDLE;
}
__END__;
cvReleaseMat( &Dx );
cvReleaseMat( &Dy );
cvReleaseMat( &D2x );
cvReleaseMat( &D2y );
cvReleaseMat( &Dxy );
cvReleaseMat( &tempsrc );
}
/* End of file */

View File

@@ -0,0 +1,268 @@
/*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*/
#include "_cv.h"
CV_IMPL void
cvFindCornerSubPix( const void* srcarr, CvPoint2D32f* corners,
int count, CvSize win, CvSize zeroZone,
CvTermCriteria criteria )
{
float* buffer = 0;
CV_FUNCNAME( "cvFindCornerSubPix" );
__BEGIN__;
const int MAX_ITERS = 100;
const float drv_x[] = { -1.f, 0.f, 1.f };
const float drv_y[] = { 0.f, 0.5f, 0.f };
float *maskX;
float *maskY;
float *mask;
float *src_buffer;
float *gx_buffer;
float *gy_buffer;
int win_w = win.width * 2 + 1, win_h = win.height * 2 + 1;
int win_rect_size = (win_w + 4) * (win_h + 4);
double coeff;
CvSize size, src_buf_size;
int i, j, k, pt_i;
int max_iters, buffer_size;
double eps;
CvMat stub, *src = (CvMat*)srcarr;
CV_CALL( src = cvGetMat( srcarr, &stub ));
if( CV_MAT_TYPE( src->type ) != CV_8UC1 )
CV_ERROR( CV_StsBadMask, "" );
if( !corners )
CV_ERROR( CV_StsNullPtr, "" );
if( count < 0 )
CV_ERROR( CV_StsBadSize, "" );
if( count == 0 )
EXIT;
if( win.width <= 0 || win.height <= 0 )
CV_ERROR( CV_StsBadSize, "" );
size = cvGetMatSize( src );
if( size.width < win_w + 4 || size.height < win_h + 4 )
CV_ERROR( CV_StsBadSize, "" );
/* initialize variables, controlling loop termination */
switch( criteria.type )
{
case CV_TERMCRIT_ITER:
eps = 0.f;
max_iters = criteria.max_iter;
break;
case CV_TERMCRIT_EPS:
eps = criteria.epsilon;
max_iters = MAX_ITERS;
break;
case CV_TERMCRIT_ITER | CV_TERMCRIT_EPS:
eps = criteria.epsilon;
max_iters = criteria.max_iter;
break;
default:
assert( 0 );
CV_ERROR( CV_StsBadFlag, "" );
}
eps = MAX( eps, 0 );
eps *= eps; /* use square of error in comparsion operations. */
max_iters = MAX( max_iters, 1 );
max_iters = MIN( max_iters, MAX_ITERS );
/* setup buffer */
buffer_size = (win_rect_size * 5 + win_w + win_h + 32) * sizeof(float);
buffer = (float*)cvAlloc( buffer_size );
/* assign pointers */
maskX = buffer;
maskY = maskX + win_w + 4;
mask = maskY + win_h + 4;
src_buffer = mask + win_w * win_h;
gx_buffer = src_buffer + win_rect_size;
gy_buffer = gx_buffer + win_rect_size;
coeff = 1. / (win.width * win.width);
/* calculate mask */
for( i = -win.width, k = 0; i <= win.width; i++, k++ )
{
maskX[k] = (float)exp( -i * i * coeff );
}
if( win.width == win.height )
{
maskY = maskX;
}
else
{
coeff = 1. / (win.height * win.height);
for( i = -win.height, k = 0; i <= win.height; i++, k++ )
{
maskY[k] = (float) exp( -i * i * coeff );
}
}
for( i = 0; i < win_h; i++ )
{
for( j = 0; j < win_w; j++ )
{
mask[i * win_w + j] = maskX[j] * maskY[i];
}
}
/* make zero_zone */
if( zeroZone.width >= 0 && zeroZone.height >= 0 &&
zeroZone.width * 2 + 1 < win_w && zeroZone.height * 2 + 1 < win_h )
{
for( i = win.height - zeroZone.height; i <= win.height + zeroZone.height; i++ )
{
for( j = win.width - zeroZone.width; j <= win.width + zeroZone.width; j++ )
{
mask[i * win_w + j] = 0;
}
}
}
/* set sizes of image rectangles, used in convolutions */
src_buf_size.width = win_w + 2;
src_buf_size.height = win_h + 2;
/* do optimization loop for all the points */
for( pt_i = 0; pt_i < count; pt_i++ )
{
CvPoint2D32f cT = corners[pt_i], cI = cT;
int iter = 0;
double err;
do
{
CvPoint2D32f cI2;
double a, b, c, bb1, bb2;
IPPI_CALL( icvGetRectSubPix_8u32f_C1R( (uchar*)src->data.ptr, src->step, size,
src_buffer, (win_w + 2) * sizeof( src_buffer[0] ),
cvSize( win_w + 2, win_h + 2 ), cI ));
/* calc derivatives */
icvSepConvSmall3_32f( src_buffer, src_buf_size.width * sizeof(src_buffer[0]),
gx_buffer, win_w * sizeof(gx_buffer[0]),
src_buf_size, drv_x, drv_y, buffer );
icvSepConvSmall3_32f( src_buffer, src_buf_size.width * sizeof(src_buffer[0]),
gy_buffer, win_w * sizeof(gy_buffer[0]),
src_buf_size, drv_y, drv_x, buffer );
a = b = c = bb1 = bb2 = 0;
/* process gradient */
for( i = 0, k = 0; i < win_h; i++ )
{
double py = i - win.height;
for( j = 0; j < win_w; j++, k++ )
{
double m = mask[k];
double tgx = gx_buffer[k];
double tgy = gy_buffer[k];
double gxx = tgx * tgx * m;
double gxy = tgx * tgy * m;
double gyy = tgy * tgy * m;
double px = j - win.width;
a += gxx;
b += gxy;
c += gyy;
bb1 += gxx * px + gxy * py;
bb2 += gxy * px + gyy * py;
}
}
{
double A[4];
double InvA[4];
CvMat matA, matInvA;
A[0] = a;
A[1] = A[2] = b;
A[3] = c;
cvInitMatHeader( &matA, 2, 2, CV_64F, A );
cvInitMatHeader( &matInvA, 2, 2, CV_64FC1, InvA );
cvInvert( &matA, &matInvA, CV_SVD );
cI2.x = (float)(cI.x + InvA[0]*bb1 + InvA[1]*bb2);
cI2.y = (float)(cI.y + InvA[2]*bb1 + InvA[3]*bb2);
}
err = (cI2.x - cI.x) * (cI2.x - cI.x) + (cI2.y - cI.y) * (cI2.y - cI.y);
cI = cI2;
}
while( ++iter < max_iters && err > eps );
/* if new point is too far from initial, it means poor convergence.
leave initial point as the result */
if( fabs( cI.x - cT.x ) > win.width || fabs( cI.y - cT.y ) > win.height )
{
cI = cT;
}
corners[pt_i] = cI; /* store result */
}
__CLEANUP__;
__END__;
cvFree( &buffer );
}
/* End of file. */

View File

@@ -0,0 +1,880 @@
/*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*/
#include "_cv.h"
/****************************************************************************************/
/* lightweight convolution with 3x3 kernel */
void icvSepConvSmall3_32f( float* src, int src_step, float* dst, int dst_step,
CvSize src_size, const float* kx, const float* ky, float* buffer )
{
int dst_width, buffer_step = 0;
int x, y;
assert( src && dst && src_size.width > 2 && src_size.height > 2 &&
(src_step & 3) == 0 && (dst_step & 3) == 0 &&
(kx || ky) && (buffer || !kx || !ky));
src_step /= sizeof(src[0]);
dst_step /= sizeof(dst[0]);
dst_width = src_size.width - 2;
if( !kx )
{
/* set vars, so that vertical convolution
will write results into destination ROI and
horizontal convolution won't run */
src_size.width = dst_width;
buffer_step = dst_step;
buffer = dst;
dst_width = 0;
}
assert( src_step >= src_size.width && dst_step >= dst_width );
src_size.height -= 3;
if( !ky )
{
/* set vars, so that vertical convolution won't run and
horizontal convolution will write results into destination ROI */
src_size.height += 3;
buffer_step = src_step;
buffer = src;
src_size.width = 0;
}
for( y = 0; y <= src_size.height; y++, src += src_step,
dst += dst_step,
buffer += buffer_step )
{
float* src2 = src + src_step;
float* src3 = src + src_step*2;
for( x = 0; x < src_size.width; x++ )
{
buffer[x] = (float)(ky[0]*src[x] + ky[1]*src2[x] + ky[2]*src3[x]);
}
for( x = 0; x < dst_width; x++ )
{
dst[x] = (float)(kx[0]*buffer[x] + kx[1]*buffer[x+1] + kx[2]*buffer[x+2]);
}
}
}
/****************************************************************************************\
Sobel & Scharr Derivative Filters
\****************************************************************************************/
/////////////////////////////// Old IPP derivative filters ///////////////////////////////
// still used in corner detectors (see cvcorner.cpp)
icvFilterSobelVert_8u16s_C1R_t icvFilterSobelVert_8u16s_C1R_p = 0;
icvFilterSobelHoriz_8u16s_C1R_t icvFilterSobelHoriz_8u16s_C1R_p = 0;
icvFilterSobelVertSecond_8u16s_C1R_t icvFilterSobelVertSecond_8u16s_C1R_p = 0;
icvFilterSobelHorizSecond_8u16s_C1R_t icvFilterSobelHorizSecond_8u16s_C1R_p = 0;
icvFilterSobelCross_8u16s_C1R_t icvFilterSobelCross_8u16s_C1R_p = 0;
icvFilterSobelVert_32f_C1R_t icvFilterSobelVert_32f_C1R_p = 0;
icvFilterSobelHoriz_32f_C1R_t icvFilterSobelHoriz_32f_C1R_p = 0;
icvFilterSobelVertSecond_32f_C1R_t icvFilterSobelVertSecond_32f_C1R_p = 0;
icvFilterSobelHorizSecond_32f_C1R_t icvFilterSobelHorizSecond_32f_C1R_p = 0;
icvFilterSobelCross_32f_C1R_t icvFilterSobelCross_32f_C1R_p = 0;
icvFilterScharrVert_8u16s_C1R_t icvFilterScharrVert_8u16s_C1R_p = 0;
icvFilterScharrHoriz_8u16s_C1R_t icvFilterScharrHoriz_8u16s_C1R_p = 0;
icvFilterScharrVert_32f_C1R_t icvFilterScharrVert_32f_C1R_p = 0;
icvFilterScharrHoriz_32f_C1R_t icvFilterScharrHoriz_32f_C1R_p = 0;
///////////////////////////////// New IPP derivative filters /////////////////////////////
#define IPCV_FILTER_PTRS( name ) \
icvFilter##name##GetBufSize_8u16s_C1R_t \
icvFilter##name##GetBufSize_8u16s_C1R_p = 0; \
icvFilter##name##Border_8u16s_C1R_t \
icvFilter##name##Border_8u16s_C1R_p = 0; \
icvFilter##name##GetBufSize_32f_C1R_t \
icvFilter##name##GetBufSize_32f_C1R_p = 0; \
icvFilter##name##Border_32f_C1R_t \
icvFilter##name##Border_32f_C1R_p = 0;
IPCV_FILTER_PTRS( ScharrHoriz )
IPCV_FILTER_PTRS( ScharrVert )
IPCV_FILTER_PTRS( SobelHoriz )
IPCV_FILTER_PTRS( SobelNegVert )
IPCV_FILTER_PTRS( SobelHorizSecond )
IPCV_FILTER_PTRS( SobelVertSecond )
IPCV_FILTER_PTRS( SobelCross )
IPCV_FILTER_PTRS( Laplacian )
typedef CvStatus (CV_STDCALL * CvDeriv3x3GetBufSizeIPPFunc)
( CvSize roi, int* bufsize );
typedef CvStatus (CV_STDCALL * CvDerivGetBufSizeIPPFunc)
( CvSize roi, int masksize, int* bufsize );
typedef CvStatus (CV_STDCALL * CvDeriv3x3IPPFunc_8u )
( const void* src, int srcstep, void* dst, int dststep,
CvSize size, int bordertype, uchar bordervalue, void* buffer );
typedef CvStatus (CV_STDCALL * CvDeriv3x3IPPFunc_32f )
( const void* src, int srcstep, void* dst, int dststep,
CvSize size, int bordertype, float bordervalue, void* buffer );
typedef CvStatus (CV_STDCALL * CvDerivIPPFunc_8u )
( const void* src, int srcstep, void* dst, int dststep,
CvSize size, int masksize, int bordertype,
uchar bordervalue, void* buffer );
typedef CvStatus (CV_STDCALL * CvDerivIPPFunc_32f )
( const void* src, int srcstep, void* dst, int dststep,
CvSize size, int masksize, int bordertype,
float bordervalue, void* buffer );
//////////////////////////////////////////////////////////////////////////////////////////
CV_IMPL void
cvSobel( const void* srcarr, void* dstarr, int dx, int dy, int aperture_size )
{
CvSepFilter filter;
void* buffer = 0;
int local_alloc = 0;
CV_FUNCNAME( "cvSobel" );
__BEGIN__;
int origin = 0;
int src_type, dst_type;
CvMat srcstub, *src = (CvMat*)srcarr;
CvMat dststub, *dst = (CvMat*)dstarr;
if( !CV_IS_MAT(src) )
CV_CALL( src = cvGetMat( src, &srcstub ));
if( !CV_IS_MAT(dst) )
CV_CALL( dst = cvGetMat( dst, &dststub ));
if( CV_IS_IMAGE_HDR( srcarr ))
origin = ((IplImage*)srcarr)->origin;
src_type = CV_MAT_TYPE( src->type );
dst_type = CV_MAT_TYPE( dst->type );
if( !CV_ARE_SIZES_EQ( src, dst ))
CV_ERROR( CV_StsBadArg, "src and dst have different sizes" );
if( ((aperture_size == CV_SCHARR || aperture_size == 3 || aperture_size == 5) &&
dx <= 2 && dy <= 2 && dx + dy <= 2 && icvFilterSobelNegVertBorder_8u16s_C1R_p) &&
(src_type == CV_8UC1 && dst_type == CV_16SC1 ||
src_type == CV_32FC1 && dst_type == CV_32FC1) )
{
CvDerivGetBufSizeIPPFunc ipp_sobel_getbufsize_func = 0;
CvDerivIPPFunc_8u ipp_sobel_func_8u = 0;
CvDerivIPPFunc_32f ipp_sobel_func_32f = 0;
CvDeriv3x3GetBufSizeIPPFunc ipp_scharr_getbufsize_func = 0;
CvDeriv3x3IPPFunc_8u ipp_scharr_func_8u = 0;
CvDeriv3x3IPPFunc_32f ipp_scharr_func_32f = 0;
if( aperture_size == CV_SCHARR )
{
if( dx == 1 && dy == 0 )
{
if( src_type == CV_8U )
ipp_scharr_func_8u = icvFilterScharrVertBorder_8u16s_C1R_p,
ipp_scharr_getbufsize_func = icvFilterScharrVertGetBufSize_8u16s_C1R_p;
else
ipp_scharr_func_32f = icvFilterScharrVertBorder_32f_C1R_p,
ipp_scharr_getbufsize_func = icvFilterScharrVertGetBufSize_32f_C1R_p;
}
else if( dx == 0 && dy == 1 )
{
if( src_type == CV_8U )
ipp_scharr_func_8u = icvFilterScharrHorizBorder_8u16s_C1R_p,
ipp_scharr_getbufsize_func = icvFilterScharrHorizGetBufSize_8u16s_C1R_p;
else
ipp_scharr_func_32f = icvFilterScharrHorizBorder_32f_C1R_p,
ipp_scharr_getbufsize_func = icvFilterScharrHorizGetBufSize_32f_C1R_p;
}
else
CV_ERROR( CV_StsBadArg, "Scharr filter can only be used to compute 1st image derivatives" );
}
else
{
if( dx == 1 && dy == 0 )
{
if( src_type == CV_8U )
ipp_sobel_func_8u = icvFilterSobelNegVertBorder_8u16s_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelNegVertGetBufSize_8u16s_C1R_p;
else
ipp_sobel_func_32f = icvFilterSobelNegVertBorder_32f_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelNegVertGetBufSize_32f_C1R_p;
}
else if( dx == 0 && dy == 1 )
{
if( src_type == CV_8U )
ipp_sobel_func_8u = icvFilterSobelHorizBorder_8u16s_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelHorizGetBufSize_8u16s_C1R_p;
else
ipp_sobel_func_32f = icvFilterSobelHorizBorder_32f_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelHorizGetBufSize_32f_C1R_p;
}
else if( dx == 2 && dy == 0 )
{
if( src_type == CV_8U )
ipp_sobel_func_8u = icvFilterSobelVertSecondBorder_8u16s_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelVertSecondGetBufSize_8u16s_C1R_p;
else
ipp_sobel_func_32f = icvFilterSobelVertSecondBorder_32f_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelVertSecondGetBufSize_32f_C1R_p;
}
else if( dx == 0 && dy == 2 )
{
if( src_type == CV_8U )
ipp_sobel_func_8u = icvFilterSobelHorizSecondBorder_8u16s_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelHorizSecondGetBufSize_8u16s_C1R_p;
else
ipp_sobel_func_32f = icvFilterSobelHorizSecondBorder_32f_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelHorizSecondGetBufSize_32f_C1R_p;
}
else if( dx == 1 && dy == 1 )
{
if( src_type == CV_8U )
ipp_sobel_func_8u = icvFilterSobelCrossBorder_8u16s_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelCrossGetBufSize_8u16s_C1R_p;
else
ipp_sobel_func_32f = icvFilterSobelCrossBorder_32f_C1R_p,
ipp_sobel_getbufsize_func = icvFilterSobelCrossGetBufSize_32f_C1R_p;
}
}
if( (ipp_sobel_func_8u || ipp_sobel_func_32f) && ipp_sobel_getbufsize_func ||
(ipp_scharr_func_8u || ipp_scharr_func_32f) && ipp_scharr_getbufsize_func )
{
int bufsize = 0, masksize = aperture_size == 3 ? 33 : 55;
CvSize size = cvGetMatSize( src );
uchar* src_ptr = src->data.ptr;
uchar* dst_ptr = dst->data.ptr;
int src_step = src->step ? src->step : CV_STUB_STEP;
int dst_step = dst->step ? dst->step : CV_STUB_STEP;
const int bordertype = 1; // replication border
CvStatus status;
status = ipp_sobel_getbufsize_func ?
ipp_sobel_getbufsize_func( size, masksize, &bufsize ) :
ipp_scharr_getbufsize_func( size, &bufsize );
if( status >= 0 )
{
if( bufsize <= CV_MAX_LOCAL_SIZE )
{
buffer = cvStackAlloc( bufsize );
local_alloc = 1;
}
else
CV_CALL( buffer = cvAlloc( bufsize ));
status =
ipp_sobel_func_8u ? ipp_sobel_func_8u( src_ptr, src_step, dst_ptr, dst_step,
size, masksize, bordertype, 0, buffer ) :
ipp_sobel_func_32f ? ipp_sobel_func_32f( src_ptr, src_step, dst_ptr, dst_step,
size, masksize, bordertype, 0, buffer ) :
ipp_scharr_func_8u ? ipp_scharr_func_8u( src_ptr, src_step, dst_ptr, dst_step,
size, bordertype, 0, buffer ) :
ipp_scharr_func_32f ? ipp_scharr_func_32f( src_ptr, src_step, dst_ptr, dst_step,
size, bordertype, 0, buffer ) :
CV_NOTDEFINED_ERR;
}
if( status >= 0 &&
(dx == 0 && dy == 1 && origin || dx == 1 && dy == 1 && !origin)) // negate the output
cvSubRS( dst, cvScalarAll(0), dst );
if( status >= 0 )
EXIT;
}
}
CV_CALL( filter.init_deriv( src->cols, src_type, dst_type, dx, dy,
aperture_size, origin ? CvSepFilter::FLIP_KERNEL : 0));
CV_CALL( filter.process( src, dst ));
__END__;
if( buffer && !local_alloc )
cvFree( &buffer );
}
/****************************************************************************************\
Laplacian Filter
\****************************************************************************************/
static void icvLaplaceRow_8u32s( const uchar* src, int* dst, void* params );
static void icvLaplaceRow_8u32f( const uchar* src, float* dst, void* params );
static void icvLaplaceRow_32f( const float* src, float* dst, void* params );
static void icvLaplaceCol_32s16s( const int** src, short* dst, int dst_step,
int count, void* params );
static void icvLaplaceCol_32f( const float** src, float* dst, int dst_step,
int count, void* params );
CvLaplaceFilter::CvLaplaceFilter()
{
normalized = basic_laplacian = false;
}
CvLaplaceFilter::CvLaplaceFilter( int _max_width, int _src_type, int _dst_type, bool _normalized,
int _ksize, int _border_mode, CvScalar _border_value )
{
normalized = basic_laplacian = false;
init( _max_width, _src_type, _dst_type, _normalized, _ksize, _border_mode, _border_value );
}
CvLaplaceFilter::~CvLaplaceFilter()
{
clear();
}
void CvLaplaceFilter::get_work_params()
{
int min_rows = max_ky*2 + 3, rows = MAX(min_rows,10), row_sz;
int width = max_width, trow_sz = 0;
int dst_depth = CV_MAT_DEPTH(dst_type);
int work_depth = dst_depth < CV_32F ? CV_32S : CV_32F;
work_type = CV_MAKETYPE( work_depth, CV_MAT_CN(dst_type)*2 );
trow_sz = cvAlign( (max_width + ksize.width - 1)*CV_ELEM_SIZE(src_type), ALIGN );
row_sz = cvAlign( width*CV_ELEM_SIZE(work_type), ALIGN );
buf_size = rows*row_sz;
buf_size = MIN( buf_size, 1 << 16 );
buf_size = MAX( buf_size, min_rows*row_sz );
max_rows = (buf_size/row_sz)*3 + max_ky*2 + 8;
buf_size += trow_sz;
}
void CvLaplaceFilter::init( int _max_width, int _src_type, int _dst_type, bool _normalized,
int _ksize0, int _border_mode, CvScalar _border_value )
{
CvMat *kx = 0, *ky = 0;
CV_FUNCNAME( "CvLaplaceFilter::init" );
__BEGIN__;
int src_depth = CV_MAT_DEPTH(_src_type), dst_depth = CV_MAT_DEPTH(_dst_type);
int _ksize = MAX( _ksize0, 3 );
normalized = _normalized;
basic_laplacian = _ksize0 == 1;
if( (src_depth != CV_8U || dst_depth != CV_16S && dst_depth != CV_32F) &&
(src_depth != CV_32F || dst_depth != CV_32F) ||
CV_MAT_CN(_src_type) != CV_MAT_CN(_dst_type) )
CV_ERROR( CV_StsUnmatchedFormats,
"Laplacian can either transform 8u->16s, or 8u->32f, or 32f->32f.\n"
"The channel number must be the same." );
if( _ksize < 1 || _ksize > CV_MAX_SOBEL_KSIZE || _ksize % 2 == 0 )
CV_ERROR( CV_StsOutOfRange, "kernel size must be within 1..7 and odd" );
CV_CALL( kx = cvCreateMat( 1, _ksize, CV_32F ));
CV_CALL( ky = cvCreateMat( 1, _ksize, CV_32F ));
CvSepFilter::init_sobel_kernel( kx, ky, 2, 0, 0 );
CvSepFilter::init( _max_width, _src_type, _dst_type, kx, ky,
cvPoint(-1,-1), _border_mode, _border_value );
x_func = 0;
y_func = 0;
if( src_depth == CV_8U )
{
if( dst_depth == CV_16S )
{
x_func = (CvRowFilterFunc)icvLaplaceRow_8u32s;
y_func = (CvColumnFilterFunc)icvLaplaceCol_32s16s;
}
else if( dst_depth == CV_32F )
{
x_func = (CvRowFilterFunc)icvLaplaceRow_8u32f;
y_func = (CvColumnFilterFunc)icvLaplaceCol_32f;
}
}
else if( src_depth == CV_32F )
{
if( dst_depth == CV_32F )
{
x_func = (CvRowFilterFunc)icvLaplaceRow_32f;
y_func = (CvColumnFilterFunc)icvLaplaceCol_32f;
}
}
if( !x_func || !y_func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
__END__;
cvReleaseMat( &kx );
cvReleaseMat( &ky );
}
void CvLaplaceFilter::init( int _max_width, int _src_type, int _dst_type,
bool _is_separable, CvSize _ksize,
CvPoint _anchor, int _border_mode,
CvScalar _border_value )
{
CvSepFilter::init( _max_width, _src_type, _dst_type, _is_separable,
_ksize, _anchor, _border_mode, _border_value );
}
void CvLaplaceFilter::init( int _max_width, int _src_type, int _dst_type,
const CvMat* _kx, const CvMat* _ky,
CvPoint _anchor, int _border_mode,
CvScalar _border_value )
{
CvSepFilter::init( _max_width, _src_type, _dst_type, _kx, _ky,
_anchor, _border_mode, _border_value );
}
#define ICV_LAPLACE_ROW( flavor, srctype, dsttype, load_macro ) \
static void \
icvLaplaceRow_##flavor( const srctype* src, dsttype* dst, void* params )\
{ \
const CvLaplaceFilter* state = (const CvLaplaceFilter*)params; \
const CvMat* _kx = state->get_x_kernel(); \
const CvMat* _ky = state->get_y_kernel(); \
const dsttype* kx = (dsttype*)_kx->data.ptr; \
const dsttype* ky = (dsttype*)_ky->data.ptr; \
int ksize = _kx->cols + _kx->rows - 1; \
int i = 0, j, k, width = state->get_width(); \
int cn = CV_MAT_CN(state->get_src_type()); \
int ksize2 = ksize/2, ksize2n = ksize2*cn; \
const srctype* s = src + ksize2n; \
bool basic_laplacian = state->is_basic_laplacian(); \
\
kx += ksize2; \
ky += ksize2; \
width *= cn; \
\
if( basic_laplacian ) \
for( i = 0; i < width; i++ ) \
{ \
dsttype s0 = load_macro(s[i]); \
dsttype s1 = (dsttype)(s[i-cn] - s0*2 + s[i+cn]); \
dst[i] = s0; dst[i+width] = s1; \
} \
else if( ksize == 3 ) \
for( i = 0; i < width; i++ ) \
{ \
dsttype s0 = (dsttype)(s[i-cn] + s[i]*2 + s[i+cn]); \
dsttype s1 = (dsttype)(s[i-cn] - s[i]*2 + s[i+cn]); \
dst[i] = s0; dst[i+width] = s1; \
} \
else if( ksize == 5 ) \
for( i = 0; i < width; i++ ) \
{ \
dsttype s0 = (dsttype)(s[i-2*cn]+(s[i-cn]+s[i+cn])*4+s[i]*6+s[i+2*cn]);\
dsttype s1 = (dsttype)(s[i-2*cn]-s[i]*2+s[i+2*cn]); \
dst[i] = s0; dst[i+width] = s1; \
} \
else \
for( i = 0; i < width; i++, s++ ) \
{ \
dsttype s0 = ky[0]*load_macro(s[0]), s1 = kx[0]*load_macro(s[0]);\
for( k = 1, j = cn; k <= ksize2; k++, j += cn ) \
{ \
dsttype t = load_macro(s[j] + s[-j]); \
s0 += ky[k]*t; s1 += kx[k]*t; \
} \
dst[i] = s0; dst[i+width] = s1; \
} \
}
ICV_LAPLACE_ROW( 8u32s, uchar, int, CV_NOP )
ICV_LAPLACE_ROW( 8u32f, uchar, float, CV_8TO32F )
ICV_LAPLACE_ROW( 32f, float, float, CV_NOP )
static void
icvLaplaceCol_32s16s( const int** src, short* dst,
int dst_step, int count, void* params )
{
const CvLaplaceFilter* state = (const CvLaplaceFilter*)params;
const CvMat* _kx = state->get_x_kernel();
const CvMat* _ky = state->get_y_kernel();
const int* kx = (const int*)_kx->data.ptr;
const int* ky = (const int*)_ky->data.ptr;
int ksize = _kx->cols + _kx->rows - 1, ksize2 = ksize/2;
int i = 0, k, width = state->get_width();
int cn = CV_MAT_CN(state->get_src_type());
bool basic_laplacian = state->is_basic_laplacian();
bool normalized = state->is_normalized();
int shift = ksize - 1, delta = (1 << shift) >> 1;
width *= cn;
src += ksize2;
kx += ksize2;
ky += ksize2;
dst_step /= sizeof(dst[0]);
if( basic_laplacian || !normalized )
{
normalized = false;
shift = delta = 0;
}
for( ; count--; dst += dst_step, src++ )
{
if( ksize == 3 )
{
const int *src0 = src[-1], *src1 = src[0], *src2 = src[1];
if( basic_laplacian )
{
for( i = 0; i <= width - 2; i += 2 )
{
int s0 = src0[i] - src1[i]*2 + src2[i] + src1[i+width];
int s1 = src0[i+1] - src1[i+1]*2 + src2[i+1] + src1[i+width+1];
dst[i] = (short)s0; dst[i+1] = (short)s1;
}
for( ; i < width; i++ )
dst[i] = (short)(src0[i] - src1[i]*2 + src2[i] + src1[i+width]);
}
else if( !normalized )
for( i = 0; i <= width - 2; i += 2 )
{
int s0 = src0[i] - src1[i]*2 + src2[i] +
src0[i+width] + src1[i+width]*2 + src2[i+width];
int s1 = src0[i+1] - src1[i+1]*2 + src2[i+1] +
src0[i+width+1] + src1[i+width+1]*2 + src2[i+width+1];
dst[i] = (short)s0; dst[i+1] = (short)s1;
}
else
for( i = 0; i <= width - 2; i += 2 )
{
int s0 = CV_DESCALE(src0[i] - src1[i]*2 + src2[i] +
src0[i+width] + src1[i+width]*2 + src2[i+width], 2);
int s1 = CV_DESCALE(src0[i+1] - src1[i+1]*2 + src2[i+1] +
src0[i+width+1] + src1[i+width+1]*2 + src2[i+width+1],2);
dst[i] = (short)s0; dst[i+1] = (short)s1;
}
}
else if( ksize == 5 )
{
const int *src0 = src[-2], *src1 = src[-1], *src2 = src[0], *src3 = src[1], *src4 = src[2];
if( !normalized )
for( i = 0; i <= width - 2; i += 2 )
{
int s0 = src0[i] - src2[i]*2 + src4[i] + src0[i+width] + src4[i+width] +
(src1[i+width] + src3[i+width])*4 + src2[i+width]*6;
int s1 = src0[i+1] - src2[i+1]*2 + src4[i+1] + src0[i+width+1] +
src4[i+width+1] + (src1[i+width+1] + src3[i+width+1])*4 +
src2[i+width+1]*6;
dst[i] = (short)s0; dst[i+1] = (short)s1;
}
else
for( i = 0; i <= width - 2; i += 2 )
{
int s0 = CV_DESCALE(src0[i] - src2[i]*2 + src4[i] +
src0[i+width] + src4[i+width] +
(src1[i+width] + src3[i+width])*4 + src2[i+width]*6, 4);
int s1 = CV_DESCALE(src0[i+1] - src2[i+1]*2 + src4[i+1] +
src0[i+width+1] + src4[i+width+1] +
(src1[i+width+1] + src3[i+width+1])*4 + src2[i+width+1]*6, 4);
dst[i] = (short)s0; dst[i+1] = (short)s1;
}
}
else
{
if( !normalized )
for( i = 0; i <= width - 2; i += 2 )
{
int s0 = kx[0]*src[0][i] + ky[0]*src[0][i+width];
int s1 = kx[0]*src[0][i+1] + ky[0]*src[0][i+width+1];
for( k = 1; k <= ksize2; k++ )
{
const int* src1 = src[k] + i, *src2 = src[-k] + i;
int fx = kx[k], fy = ky[k];
s0 += fx*(src1[0] + src2[0]) + fy*(src1[width] + src2[width]);
s1 += fx*(src1[1] + src2[1]) + fy*(src1[width+1] + src2[width+1]);
}
dst[i] = CV_CAST_16S(s0); dst[i+1] = CV_CAST_16S(s1);
}
else
for( i = 0; i <= width - 2; i += 2 )
{
int s0 = kx[0]*src[0][i] + ky[0]*src[0][i+width];
int s1 = kx[0]*src[0][i+1] + ky[0]*src[0][i+width+1];
for( k = 1; k <= ksize2; k++ )
{
const int* src1 = src[k] + i, *src2 = src[-k] + i;
int fx = kx[k], fy = ky[k];
s0 += fx*(src1[0] + src2[0]) + fy*(src1[width] + src2[width]);
s1 += fx*(src1[1] + src2[1]) + fy*(src1[width+1] + src2[width+1]);
}
s0 = CV_DESCALE( s0, shift ); s1 = CV_DESCALE( s1, shift );
dst[i] = (short)s0; dst[i+1] = (short)s1;
}
}
for( ; i < width; i++ )
{
int s0 = kx[0]*src[0][i] + ky[0]*src[0][i+width];
for( k = 1; k <= ksize2; k++ )
{
const int* src1 = src[k] + i, *src2 = src[-k] + i;
s0 += kx[k]*(src1[0] + src2[0]) + ky[k]*(src1[width] + src2[width]);
}
s0 = (s0 + delta) >> shift;
dst[i] = CV_CAST_16S(s0);
}
}
}
static void
icvLaplaceCol_32f( const float** src, float* dst,
int dst_step, int count, void* params )
{
const CvLaplaceFilter* state = (const CvLaplaceFilter*)params;
const CvMat* _kx = state->get_x_kernel();
const CvMat* _ky = state->get_y_kernel();
const float* kx = (const float*)_kx->data.ptr;
const float* ky = (const float*)_ky->data.ptr;
int ksize = _kx->cols + _kx->rows - 1, ksize2 = ksize/2;
int i = 0, k, width = state->get_width();
int cn = CV_MAT_CN(state->get_src_type());
bool basic_laplacian = state->is_basic_laplacian();
bool normalized = state->is_normalized();
float scale = 1.f/(1 << (ksize - 1));
width *= cn;
src += ksize2;
kx += ksize2;
ky += ksize2;
dst_step /= sizeof(dst[0]);
if( basic_laplacian || !normalized )
{
normalized = false;
scale = 1.f;
}
for( ; count--; dst += dst_step, src++ )
{
if( ksize == 3 )
{
const float *src0 = src[-1], *src1 = src[0], *src2 = src[1];
if( basic_laplacian )
{
for( i = 0; i <= width - 2; i += 2 )
{
float s0 = src0[i] - src1[i]*2 + src2[i] + src1[i+width];
float s1 = src0[i+1] - src1[i+1]*2 + src2[i+1] + src1[i+width+1];
dst[i] = s0; dst[i+1] = s1;
}
for( ; i < width; i++ )
dst[i] = src0[i] - src1[i]*2 + src2[i] + src1[i+width];
}
else if( !normalized )
for( i = 0; i <= width - 2; i += 2 )
{
float s0 = src0[i] - src1[i]*2 + src2[i] +
src0[i+width] + src1[i+width]*2 + src2[i+width];
float s1 = src0[i+1] - src1[i+1]*2 + src2[i+1] +
src0[i+width+1] + src1[i+width+1]*2 + src2[i+width+1];
dst[i] = s0; dst[i+1] = s1;
}
else
for( i = 0; i <= width - 2; i += 2 )
{
float s0 = (src0[i] - src1[i]*2 + src2[i] +
src0[i+width] + src1[i+width]*2 + src2[i+width])*scale;
float s1 = (src0[i+1] - src1[i+1]*2 + src2[i+1] +
src0[i+width+1] + src1[i+width+1]*2 + src2[i+width+1])*scale;
dst[i] = s0; dst[i+1] = s1;
}
}
else if( ksize == 5 )
{
const float *src0 = src[-2], *src1 = src[-1], *src2 = src[0], *src3 = src[1], *src4 = src[2];
for( i = 0; i <= width - 2; i += 2 )
{
float s0 = (src0[i] - src2[i]*2 + src4[i] +
src0[i+width] + src4[i+width] +
(src1[i+width] + src3[i+width])*4 + src2[i+width]*6)*scale;
float s1 = (src0[i+1] - src2[i+1]*2 + src4[i+1] +
src0[i+width+1] + src4[i+width+1] +
(src1[i+width+1] + src3[i+width+1])*4 + src2[i+width+1]*6)*scale;
dst[i] = s0; dst[i+1] = s1;
}
}
else
{
for( i = 0; i <= width - 2; i += 2 )
{
float s0 = kx[0]*src[0][i] + ky[0]*src[0][i+width];
float s1 = kx[0]*src[0][i+1] + ky[0]*src[0][i+width+1];
for( k = 1; k <= ksize2; k++ )
{
const float* src1 = src[k] + i, *src2 = src[-k] + i;
float fx = kx[k], fy = ky[k];
s0 += fx*(src1[0] + src2[0]) + fy*(src1[width] + src2[width]);
s1 += fx*(src1[1] + src2[1]) + fy*(src1[width+1] + src2[width+1]);
}
s0 *= scale; s1 *= scale;
dst[i] = s0; dst[i+1] = s1;
}
}
for( ; i < width; i++ )
{
float s0 = kx[0]*src[0][i] + ky[0]*src[0][i+width];
for( k = 1; k <= ksize2; k++ )
{
const float* src1 = src[k] + i, *src2 = src[-k] + i;
s0 += kx[k]*(src1[0] + src2[0]) + ky[k]*(src1[width] + src2[width]);
}
dst[i] = s0*scale;
}
}
}
CV_IMPL void
cvLaplace( const void* srcarr, void* dstarr, int aperture_size )
{
CvLaplaceFilter laplacian;
void* buffer = 0;
int local_alloc = 0;
CV_FUNCNAME( "cvLaplace" );
__BEGIN__;
CvMat srcstub, *src = (CvMat*)srcarr;
CvMat dststub, *dst = (CvMat*)dstarr;
int src_type, dst_type;
CV_CALL( src = cvGetMat( src, &srcstub ));
CV_CALL( dst = cvGetMat( dst, &dststub ));
src_type = CV_MAT_TYPE(src->type);
dst_type = CV_MAT_TYPE(dst->type);
if( aperture_size == 3 || aperture_size == 5 &&
(src_type == CV_8UC1 && dst_type == CV_16SC1 ||
src_type == CV_32FC1 && dst_type == CV_32FC1) &&
(aperture_size == 3 || src_type < CV_32FC1) )
{
CvDerivGetBufSizeIPPFunc ipp_laplace_getbufsize_func = 0;
CvDerivIPPFunc_8u ipp_laplace_func_8u = 0;
CvDerivIPPFunc_32f ipp_laplace_func_32f = 0;
if( src_type == CV_8U )
ipp_laplace_func_8u = icvFilterLaplacianBorder_8u16s_C1R_p,
ipp_laplace_getbufsize_func = icvFilterLaplacianGetBufSize_8u16s_C1R_p;
else
ipp_laplace_func_32f = icvFilterLaplacianBorder_32f_C1R_p,
ipp_laplace_getbufsize_func = icvFilterLaplacianGetBufSize_32f_C1R_p;
if( (ipp_laplace_func_8u || ipp_laplace_func_32f) && ipp_laplace_getbufsize_func )
{
int bufsize = 0, masksize = aperture_size == 3 ? 33 : 55;
CvSize size = cvGetMatSize( src );
uchar* src_ptr = src->data.ptr;
uchar* dst_ptr = dst->data.ptr;
int src_step = src->step ? src->step : CV_STUB_STEP;
int dst_step = dst->step ? dst->step : CV_STUB_STEP;
const int bordertype = 1; // replication border
CvStatus status;
status = ipp_laplace_getbufsize_func( size, masksize, &bufsize );
if( status >= 0 )
{
if( bufsize <= CV_MAX_LOCAL_SIZE )
{
buffer = cvStackAlloc( bufsize );
local_alloc = 1;
}
else
CV_CALL( buffer = cvAlloc( bufsize ));
status =
ipp_laplace_func_8u ? ipp_laplace_func_8u( src_ptr, src_step, dst_ptr, dst_step,
size, masksize, bordertype, 0, buffer ) :
ipp_laplace_func_32f ? ipp_laplace_func_32f( src_ptr, src_step, dst_ptr, dst_step,
size, masksize, bordertype, 0, buffer ) :
CV_NOTDEFINED_ERR;
}
if( status >= 0 )
EXIT;
}
}
CV_CALL( laplacian.init( src->cols, src_type, dst_type,
false, aperture_size ));
CV_CALL( laplacian.process( src, dst ));
__END__;
if( buffer && !local_alloc )
cvFree( &buffer );
}
/* End of file. */

View File

@@ -0,0 +1,734 @@
/*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*/
#include "_cv.h"
#define ICV_DIST_SHIFT 16
#define ICV_INIT_DIST0 (INT_MAX >> 2)
static CvStatus
icvInitTopBottom( int* temp, int tempstep, CvSize size, int border )
{
int i, j;
for( i = 0; i < border; i++ )
{
int* ttop = (int*)(temp + i*tempstep);
int* tbottom = (int*)(temp + (size.height + border*2 - i - 1)*tempstep);
for( j = 0; j < size.width + border*2; j++ )
{
ttop[j] = ICV_INIT_DIST0;
tbottom[j] = ICV_INIT_DIST0;
}
}
return CV_OK;
}
static CvStatus CV_STDCALL
icvDistanceTransform_3x3_C1R( const uchar* src, int srcstep, int* temp,
int step, float* dist, int dststep, CvSize size, const float* metrics )
{
const int BORDER = 1;
int i, j;
const int HV_DIST = CV_FLT_TO_FIX( metrics[0], ICV_DIST_SHIFT );
const int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], ICV_DIST_SHIFT );
const float scale = 1.f/(1 << ICV_DIST_SHIFT);
srcstep /= sizeof(src[0]);
step /= sizeof(temp[0]);
dststep /= sizeof(dist[0]);
icvInitTopBottom( temp, step, size, BORDER );
// forward pass
for( i = 0; i < size.height; i++ )
{
const uchar* s = src + i*srcstep;
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
for( j = 0; j < BORDER; j++ )
tmp[-j-1] = tmp[size.width + j] = ICV_INIT_DIST0;
for( j = 0; j < size.width; j++ )
{
if( !s[j] )
tmp[j] = 0;
else
{
int t0 = tmp[j-step-1] + DIAG_DIST;
int t = tmp[j-step] + HV_DIST;
if( t0 > t ) t0 = t;
t = tmp[j-step+1] + DIAG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j-1] + HV_DIST;
if( t0 > t ) t0 = t;
tmp[j] = t0;
}
}
}
// backward pass
for( i = size.height - 1; i >= 0; i-- )
{
float* d = (float*)(dist + i*dststep);
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
for( j = size.width - 1; j >= 0; j-- )
{
int t0 = tmp[j];
if( t0 > HV_DIST )
{
int t = tmp[j+step+1] + DIAG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+step] + HV_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+step-1] + DIAG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+1] + HV_DIST;
if( t0 > t ) t0 = t;
tmp[j] = t0;
}
d[j] = (float)(t0 * scale);
}
}
return CV_OK;
}
static CvStatus CV_STDCALL
icvDistanceTransform_5x5_C1R( const uchar* src, int srcstep, int* temp,
int step, float* dist, int dststep, CvSize size, const float* metrics )
{
const int BORDER = 2;
int i, j;
const int HV_DIST = CV_FLT_TO_FIX( metrics[0], ICV_DIST_SHIFT );
const int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], ICV_DIST_SHIFT );
const int LONG_DIST = CV_FLT_TO_FIX( metrics[2], ICV_DIST_SHIFT );
const float scale = 1.f/(1 << ICV_DIST_SHIFT);
srcstep /= sizeof(src[0]);
step /= sizeof(temp[0]);
dststep /= sizeof(dist[0]);
icvInitTopBottom( temp, step, size, BORDER );
// forward pass
for( i = 0; i < size.height; i++ )
{
const uchar* s = src + i*srcstep;
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
for( j = 0; j < BORDER; j++ )
tmp[-j-1] = tmp[size.width + j] = ICV_INIT_DIST0;
for( j = 0; j < size.width; j++ )
{
if( !s[j] )
tmp[j] = 0;
else
{
int t0 = tmp[j-step*2-1] + LONG_DIST;
int t = tmp[j-step*2+1] + LONG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j-step-2] + LONG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j-step-1] + DIAG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j-step] + HV_DIST;
if( t0 > t ) t0 = t;
t = tmp[j-step+1] + DIAG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j-step+2] + LONG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j-1] + HV_DIST;
if( t0 > t ) t0 = t;
tmp[j] = t0;
}
}
}
// backward pass
for( i = size.height - 1; i >= 0; i-- )
{
float* d = (float*)(dist + i*dststep);
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
for( j = size.width - 1; j >= 0; j-- )
{
int t0 = tmp[j];
if( t0 > HV_DIST )
{
int t = tmp[j+step*2+1] + LONG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+step*2-1] + LONG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+step+2] + LONG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+step+1] + DIAG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+step] + HV_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+step-1] + DIAG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+step-2] + LONG_DIST;
if( t0 > t ) t0 = t;
t = tmp[j+1] + HV_DIST;
if( t0 > t ) t0 = t;
tmp[j] = t0;
}
d[j] = (float)(t0 * scale);
}
}
return CV_OK;
}
static CvStatus CV_STDCALL
icvDistanceTransformEx_5x5_C1R( const uchar* src, int srcstep, int* temp,
int step, float* dist, int dststep, int* labels, int lstep,
CvSize size, const float* metrics )
{
const int BORDER = 2;
int i, j;
const int HV_DIST = CV_FLT_TO_FIX( metrics[0], ICV_DIST_SHIFT );
const int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], ICV_DIST_SHIFT );
const int LONG_DIST = CV_FLT_TO_FIX( metrics[2], ICV_DIST_SHIFT );
const float scale = 1.f/(1 << ICV_DIST_SHIFT);
srcstep /= sizeof(src[0]);
step /= sizeof(temp[0]);
dststep /= sizeof(dist[0]);
lstep /= sizeof(labels[0]);
icvInitTopBottom( temp, step, size, BORDER );
// forward pass
for( i = 0; i < size.height; i++ )
{
const uchar* s = src + i*srcstep;
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
int* lls = (int*)(labels + i*lstep);
for( j = 0; j < BORDER; j++ )
tmp[-j-1] = tmp[size.width + j] = ICV_INIT_DIST0;
for( j = 0; j < size.width; j++ )
{
if( !s[j] )
{
tmp[j] = 0;
//assert( lls[j] != 0 );
}
else
{
int t0 = ICV_INIT_DIST0, t;
int l0 = 0;
t = tmp[j-step*2-1] + LONG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j-lstep*2-1];
}
t = tmp[j-step*2+1] + LONG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j-lstep*2+1];
}
t = tmp[j-step-2] + LONG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j-lstep-2];
}
t = tmp[j-step-1] + DIAG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j-lstep-1];
}
t = tmp[j-step] + HV_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j-lstep];
}
t = tmp[j-step+1] + DIAG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j-lstep+1];
}
t = tmp[j-step+2] + LONG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j-lstep+2];
}
t = tmp[j-1] + HV_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j-1];
}
tmp[j] = t0;
lls[j] = l0;
}
}
}
// backward pass
for( i = size.height - 1; i >= 0; i-- )
{
float* d = (float*)(dist + i*dststep);
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
int* lls = (int*)(labels + i*lstep);
for( j = size.width - 1; j >= 0; j-- )
{
int t0 = tmp[j];
int l0 = lls[j];
if( t0 > HV_DIST )
{
int t = tmp[j+step*2+1] + LONG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j+lstep*2+1];
}
t = tmp[j+step*2-1] + LONG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j+lstep*2-1];
}
t = tmp[j+step+2] + LONG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j+lstep+2];
}
t = tmp[j+step+1] + DIAG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j+lstep+1];
}
t = tmp[j+step] + HV_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j+lstep];
}
t = tmp[j+step-1] + DIAG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j+lstep-1];
}
t = tmp[j+step-2] + LONG_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j+lstep-2];
}
t = tmp[j+1] + HV_DIST;
if( t0 > t )
{
t0 = t;
l0 = lls[j+1];
}
tmp[j] = t0;
lls[j] = l0;
}
d[j] = (float)(t0 * scale);
}
}
return CV_OK;
}
static CvStatus
icvGetDistanceTransformMask( int maskType, float *metrics )
{
if( !metrics )
return CV_NULLPTR_ERR;
switch (maskType)
{
case 30:
metrics[0] = 1.0f;
metrics[1] = 1.0f;
break;
case 31:
metrics[0] = 1.0f;
metrics[1] = 2.0f;
break;
case 32:
metrics[0] = 0.955f;
metrics[1] = 1.3693f;
break;
case 50:
metrics[0] = 1.0f;
metrics[1] = 1.0f;
metrics[2] = 2.0f;
break;
case 51:
metrics[0] = 1.0f;
metrics[1] = 2.0f;
metrics[2] = 3.0f;
break;
case 52:
metrics[0] = 1.0f;
metrics[1] = 1.4f;
metrics[2] = 2.1969f;
break;
default:
return CV_BADRANGE_ERR;
}
return CV_OK;
}
static void
icvTrueDistTrans( const CvMat* src, CvMat* dst )
{
CvMat* buffer = 0;
CV_FUNCNAME( "cvDistTransform2" );
__BEGIN__;
int i, m, n;
int sstep, dstep;
const float inf = 1e6f;
int thread_count = cvGetNumThreads();
int pass1_sz, pass2_sz;
if( !CV_ARE_SIZES_EQ( src, dst ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( CV_MAT_TYPE(src->type) != CV_8UC1 ||
CV_MAT_TYPE(dst->type) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat,
"The input image must have 8uC1 type and the output one must have 32fC1 type" );
m = src->rows;
n = src->cols;
// (see stage 1 below):
// sqr_tab: 2*m, sat_tab: 3*m + 1, d: m*thread_count,
pass1_sz = src->rows*(5 + thread_count) + 1;
// (see stage 2):
// sqr_tab & inv_tab: n each; f & v: n*thread_count each; z: (n+1)*thread_count
pass2_sz = src->cols*(2 + thread_count*3) + thread_count;
CV_CALL( buffer = cvCreateMat( 1, MAX(pass1_sz, pass2_sz), CV_32FC1 ));
sstep = src->step;
dstep = dst->step / sizeof(float);
// stage 1: compute 1d distance transform of each column
{
float* sqr_tab = buffer->data.fl;
int* sat_tab = (int*)(sqr_tab + m*2);
const int shift = m*2;
for( i = 0; i < m; i++ )
sqr_tab[i] = (float)(i*i);
for( i = m; i < m*2; i++ )
sqr_tab[i] = inf;
for( i = 0; i < shift; i++ )
sat_tab[i] = 0;
for( ; i <= m*3; i++ )
sat_tab[i] = i - shift;
#ifdef _OPENMP
#pragma omp parallel for num_threads(thread_count)
#endif
for( i = 0; i < n; i++ )
{
const uchar* sptr = src->data.ptr + i + (m-1)*sstep;
float* dptr = dst->data.fl + i;
int* d = (int*)(sat_tab + m*3+1+m*cvGetThreadNum());
int j, dist = m-1;
for( j = m-1; j >= 0; j--, sptr -= sstep )
{
dist = (dist + 1) & (sptr[0] == 0 ? 0 : -1);
d[j] = dist;
}
dist = m-1;
for( j = 0; j < m; j++, dptr += dstep )
{
dist = dist + 1 - sat_tab[dist + 1 - d[j] + shift];
d[j] = dist;
dptr[0] = sqr_tab[dist];
}
}
}
// stage 2: compute modified distance transform for each row
{
float* inv_tab = buffer->data.fl;
float* sqr_tab = inv_tab + n;
inv_tab[0] = sqr_tab[0] = 0.f;
for( i = 1; i < n; i++ )
{
inv_tab[i] = (float)(0.5/i);
sqr_tab[i] = (float)(i*i);
}
#ifdef _OPENMP
#pragma omp parallel for num_threads(thread_count), schedule(dynamic)
#endif
for( i = 0; i < m; i++ )
{
float* d = (float*)(dst->data.ptr + i*dst->step);
float* f = sqr_tab + n + (n*3+1)*cvGetThreadNum();
float* z = f + n;
int* v = (int*)(z + n + 1);
int p, q, k;
v[0] = 0;
z[0] = -inf;
z[1] = inf;
f[0] = d[0];
for( q = 1, k = 0; q < n; q++ )
{
float fq = d[q];
f[q] = fq;
for(;;k--)
{
p = v[k];
float s = (fq + sqr_tab[q] - d[p] - sqr_tab[p])*inv_tab[q - p];
if( s > z[k] )
{
k++;
v[k] = q;
z[k] = s;
z[k+1] = inf;
break;
}
}
}
for( q = 0, k = 0; q < n; q++ )
{
while( z[k+1] < q )
k++;
p = v[k];
d[q] = sqr_tab[abs(q - p)] + f[p];
}
}
}
cvPow( dst, dst, 0.5 );
__END__;
cvReleaseMat( &buffer );
}
/*********************************** IPP functions *********************************/
icvDistanceTransform_3x3_8u32f_C1R_t icvDistanceTransform_3x3_8u32f_C1R_p = 0;
icvDistanceTransform_5x5_8u32f_C1R_t icvDistanceTransform_5x5_8u32f_C1R_p = 0;
typedef CvStatus (CV_STDCALL * CvIPPDistTransFunc)( const uchar* src, int srcstep,
float* dst, int dststep,
CvSize size, const float* metrics );
/***********************************************************************************/
typedef CvStatus (CV_STDCALL * CvDistTransFunc)( const uchar* src, int srcstep,
int* temp, int tempstep,
float* dst, int dststep,
CvSize size, const float* metrics );
/* Wrapper function for distance transform group */
CV_IMPL void
cvDistTransform( const void* srcarr, void* dstarr,
int distType, int maskSize,
const float *mask,
void* labelsarr )
{
CvMat* temp = 0;
CvMat* src_copy = 0;
CvMemStorage* st = 0;
CV_FUNCNAME( "cvDistTransform" );
__BEGIN__;
float _mask[5];
CvMat srcstub, *src = (CvMat*)srcarr;
CvMat dststub, *dst = (CvMat*)dstarr;
CvMat lstub, *labels = (CvMat*)labelsarr;
CvSize size;
CvIPPDistTransFunc ipp_func = 0;
CV_CALL( src = cvGetMat( src, &srcstub ));
CV_CALL( dst = cvGetMat( dst, &dststub ));
if( !CV_IS_MASK_ARR( src ) || CV_MAT_TYPE( dst->type ) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "source image must be 8uC1 and the distance map must be 32fC1" );
if( !CV_ARE_SIZES_EQ( src, dst ))
CV_ERROR( CV_StsUnmatchedSizes, "the source and the destination images must be of the same size" );
if( maskSize != CV_DIST_MASK_3 && maskSize != CV_DIST_MASK_5 && maskSize != CV_DIST_MASK_PRECISE )
CV_ERROR( CV_StsBadSize, "Mask size should be 3 or 5 or 0 (presize)" );
if( distType == CV_DIST_C || distType == CV_DIST_L1 )
maskSize = !labels ? CV_DIST_MASK_3 : CV_DIST_MASK_5;
else if( distType == CV_DIST_L2 && labels )
maskSize = CV_DIST_MASK_5;
if( maskSize == CV_DIST_MASK_PRECISE )
{
CV_CALL( icvTrueDistTrans( src, dst ));
EXIT;
}
if( labels )
{
CV_CALL( labels = cvGetMat( labels, &lstub ));
if( CV_MAT_TYPE( labels->type ) != CV_32SC1 )
CV_ERROR( CV_StsUnsupportedFormat, "the output array of labels must be 32sC1" );
if( !CV_ARE_SIZES_EQ( labels, dst ))
CV_ERROR( CV_StsUnmatchedSizes, "the array of labels has a different size" );
if( maskSize == CV_DIST_MASK_3 )
CV_ERROR( CV_StsNotImplemented,
"3x3 mask can not be used for \"labeled\" distance transform. Use 5x5 mask" );
}
if( distType == CV_DIST_C || distType == CV_DIST_L1 || distType == CV_DIST_L2 )
{
icvGetDistanceTransformMask( (distType == CV_DIST_C ? 0 :
distType == CV_DIST_L1 ? 1 : 2) + maskSize*10, _mask );
}
else if( distType == CV_DIST_USER )
{
if( !mask )
CV_ERROR( CV_StsNullPtr, "" );
memcpy( _mask, mask, (maskSize/2 + 1)*sizeof(float));
}
if( !labels )
ipp_func = maskSize == CV_DIST_MASK_3 ? icvDistanceTransform_3x3_8u32f_C1R_p :
icvDistanceTransform_5x5_8u32f_C1R_p;
size = cvGetMatSize(src);
if( ipp_func && src->cols >= 4 && src->rows >= 2 )
{
IPPI_CALL( ipp_func( src->data.ptr, src->step,
dst->data.fl, dst->step, size, _mask ));
}
else
{
int border = maskSize == CV_DIST_MASK_3 ? 1 : 2;
CV_CALL( temp = cvCreateMat( size.height + border*2, size.width + border*2, CV_32SC1 ));
if( !labels )
{
CvDistTransFunc func = maskSize == CV_DIST_MASK_3 ?
icvDistanceTransform_3x3_C1R :
icvDistanceTransform_5x5_C1R;
func( src->data.ptr, src->step, temp->data.i, temp->step,
dst->data.fl, dst->step, size, _mask );
}
else
{
CvSeq *contours = 0;
CvPoint top_left = {0,0}, bottom_right = {size.width-1,size.height-1};
int label;
CV_CALL( st = cvCreateMemStorage() );
CV_CALL( src_copy = cvCreateMat( size.height, size.width, src->type ));
cvCmpS( src, 0, src_copy, CV_CMP_EQ );
cvFindContours( src_copy, st, &contours, sizeof(CvContour),
CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE );
cvZero( labels );
for( label = 1; contours != 0; contours = contours->h_next, label++ )
{
CvScalar area_color = cvScalarAll(label);
cvDrawContours( labels, contours, area_color, area_color, -255, -1, 8 );
}
cvCopy( src, src_copy );
cvRectangle( src_copy, top_left, bottom_right, cvScalarAll(255), 1, 8 );
icvDistanceTransformEx_5x5_C1R( src_copy->data.ptr, src_copy->step, temp->data.i, temp->step,
dst->data.fl, dst->step, labels->data.i, labels->step, size, _mask );
}
}
__END__;
cvReleaseMat( &temp );
cvReleaseMat( &src_copy );
cvReleaseMemStorage( &st );
}
/* End of file. */

View File

@@ -0,0 +1,407 @@
/*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*/
#include "_cv.h"
typedef struct _PointInfo
{
CvPoint pt;
int left_neigh;
int right_neigh;
}
icvPointInfo;
static CvStatus
icvFindDominantPointsIPAN( CvSeq * contour,
CvMemStorage * storage,
CvSeq ** corners, int dmin2, int dmax2, int dneigh2, float amax )
{
CvStatus status = CV_OK;
/* variables */
int n = contour->total;
float *sharpness;
float *distance;
icvPointInfo *ptInf;
int i, j, k;
CvSeqWriter writer;
float mincos = (float) cos( 3.14159265359 * amax / 180 );
/* check bad arguments */
if( contour == NULL )
return CV_NULLPTR_ERR;
if( storage == NULL )
return CV_NULLPTR_ERR;
if( corners == NULL )
return CV_NULLPTR_ERR;
if( dmin2 < 0 )
return CV_BADSIZE_ERR;
if( dmax2 < dmin2 )
return CV_BADSIZE_ERR;
if( (dneigh2 > dmax2) || (dneigh2 < 0) )
return CV_BADSIZE_ERR;
if( (amax < 0) || (amax > 180) )
return CV_BADSIZE_ERR;
sharpness = (float *) cvAlloc( n * sizeof( float ));
distance = (float *) cvAlloc( n * sizeof( float ));
ptInf = (icvPointInfo *) cvAlloc( n * sizeof( icvPointInfo ));
/*****************************************************************************************/
/* First pass */
/*****************************************************************************************/
if( CV_IS_SEQ_CHAIN_CONTOUR( contour ))
{
CvChainPtReader reader;
cvStartReadChainPoints( (CvChain *) contour, &reader );
for( i = 0; i < n; i++ )
{
CV_READ_CHAIN_POINT( ptInf[i].pt, reader );
}
}
else if( CV_IS_SEQ_POLYGON( contour ))
{
CvSeqReader reader;
cvStartReadSeq( contour, &reader, 0 );
for( i = 0; i < n; i++ )
{
CV_READ_SEQ_ELEM( ptInf[i].pt, reader );
}
}
else
{
return CV_BADFLAG_ERR;
}
for( i = 0; i < n; i++ )
{
/* find nearest suitable points
which satisfy distance constraint >dmin */
int left_near = 0;
int right_near = 0;
int left_far, right_far;
float dist_l = 0;
float dist_r = 0;
int i_plus = 0;
int i_minus = 0;
float max_cos_alpha;
/* find right minimum */
while( dist_r < dmin2 )
{
float dx, dy;
int ind;
if( i_plus >= n )
goto error;
right_near = i_plus;
if( dist_r < dneigh2 )
ptInf[i].right_neigh = i_plus;
i_plus++;
ind = (i + i_plus) % n;
dx = (float) (ptInf[i].pt.x - ptInf[ind].pt.x);
dy = (float) (ptInf[i].pt.y - ptInf[ind].pt.y);
dist_r = dx * dx + dy * dy;
}
/* find right maximum */
while( dist_r <= dmax2 )
{
float dx, dy;
int ind;
if( i_plus >= n )
goto error;
distance[(i + i_plus) % n] = cvSqrt( dist_r );
if( dist_r < dneigh2 )
ptInf[i].right_neigh = i_plus;
i_plus++;
right_far = i_plus;
ind = (i + i_plus) % n;
dx = (float) (ptInf[i].pt.x - ptInf[ind].pt.x);
dy = (float) (ptInf[i].pt.y - ptInf[ind].pt.y);
dist_r = dx * dx + dy * dy;
}
right_far = i_plus;
/* left minimum */
while( dist_l < dmin2 )
{
float dx, dy;
int ind;
if( i_minus <= -n )
goto error;
left_near = i_minus;
if( dist_l < dneigh2 )
ptInf[i].left_neigh = i_minus;
i_minus--;
ind = i + i_minus;
ind = (ind < 0) ? (n + ind) : ind;
dx = (float) (ptInf[i].pt.x - ptInf[ind].pt.x);
dy = (float) (ptInf[i].pt.y - ptInf[ind].pt.y);
dist_l = dx * dx + dy * dy;
}
/* find left maximum */
while( dist_l <= dmax2 )
{
float dx, dy;
int ind;
if( i_minus <= -n )
goto error;
ind = i + i_minus;
ind = (ind < 0) ? (n + ind) : ind;
distance[ind] = cvSqrt( dist_l );
if( dist_l < dneigh2 )
ptInf[i].left_neigh = i_minus;
i_minus--;
left_far = i_minus;
ind = i + i_minus;
ind = (ind < 0) ? (n + ind) : ind;
dx = (float) (ptInf[i].pt.x - ptInf[ind].pt.x);
dy = (float) (ptInf[i].pt.y - ptInf[ind].pt.y);
dist_l = dx * dx + dy * dy;
}
left_far = i_minus;
if( (i_plus - i_minus) > n + 2 )
goto error;
max_cos_alpha = -1;
for( j = left_far + 1; j < left_near; j++ )
{
float dx, dy;
float a, a2;
int leftind = i + j;
leftind = (leftind < 0) ? (n + leftind) : leftind;
a = distance[leftind];
a2 = a * a;
for( k = right_near + 1; k < right_far; k++ )
{
int ind = (i + k) % n;
float c2, cosalpha;
float b = distance[ind];
float b2 = b * b;
/* compute cosinus */
dx = (float) (ptInf[leftind].pt.x - ptInf[ind].pt.x);
dy = (float) (ptInf[leftind].pt.y - ptInf[ind].pt.y);
c2 = dx * dx + dy * dy;
cosalpha = (a2 + b2 - c2) / (2 * a * b);
max_cos_alpha = MAX( max_cos_alpha, cosalpha );
if( max_cos_alpha < mincos )
max_cos_alpha = -1;
sharpness[i] = max_cos_alpha;
}
}
}
/*****************************************************************************************/
/* Second pass */
/*****************************************************************************************/
cvStartWriteSeq( (contour->flags & ~CV_SEQ_ELTYPE_MASK) | CV_SEQ_ELTYPE_INDEX,
sizeof( CvSeq ), sizeof( int ), storage, &writer );
/* second pass - nonmaxima suppression */
/* neighborhood of point < dneigh2 */
for( i = 0; i < n; i++ )
{
int suppressed = 0;
if( sharpness[i] == -1 )
continue;
for( j = 1; (j <= ptInf[i].right_neigh) && (suppressed == 0); j++ )
{
if( sharpness[i] < sharpness[(i + j) % n] )
suppressed = 1;
}
for( j = -1; (j >= ptInf[i].left_neigh) && (suppressed == 0); j-- )
{
int ind = i + j;
ind = (ind < 0) ? (n + ind) : ind;
if( sharpness[i] < sharpness[ind] )
suppressed = 1;
}
if( !suppressed )
CV_WRITE_SEQ_ELEM( i, writer );
}
*corners = cvEndWriteSeq( &writer );
cvFree( &sharpness );
cvFree( &distance );
cvFree( &ptInf );
return status;
error:
/* dmax is so big (more than contour diameter)
that algorithm could become infinite cycle */
cvFree( &sharpness );
cvFree( &distance );
cvFree( &ptInf );
return CV_BADRANGE_ERR;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvFindDominantPoints
// Purpose:
// Applies some algorithm to find dominant points ( corners ) of contour
//
// Context:
// Parameters:
// contours - pointer to input contour object.
// out_numbers - array of dominant points indices
// count - length of out_numbers array on input
// and numbers of founded dominant points on output
//
// method - only CV_DOMINANT_IPAN now
// parameters - array of parameters
// for IPAN algorithm
// [0] - minimal distance
// [1] - maximal distance
// [2] - neighborhood distance (must be not greater than dmaximal distance)
// [3] - maximal possible angle of curvature
// Returns:
// CV_OK or error code
// Notes:
// User must allocate out_numbers array. If it is small - function fills array
// with part of points and returns error
//F*/
CV_IMPL CvSeq*
cvFindDominantPoints( CvSeq * contour, CvMemStorage * storage, int method,
double parameter1, double parameter2, double parameter3, double parameter4 )
{
CvSeq* corners = 0;
CV_FUNCNAME( "cvFindDominantPoints" );
__BEGIN__;
if( !contour )
CV_ERROR( CV_StsNullPtr, "" );
if( !storage )
storage = contour->storage;
if( !storage )
CV_ERROR( CV_StsNullPtr, "" );
switch (method)
{
case CV_DOMINANT_IPAN:
{
int dmin = cvRound(parameter1);
int dmax = cvRound(parameter2);
int dneigh = cvRound(parameter3);
int amax = cvRound(parameter4);
if( amax == 0 )
amax = 150;
if( dmin == 0 )
dmin = 7;
if( dmax == 0 )
dmax = dmin + 2;
if( dneigh == 0 )
dneigh = dmin;
IPPI_CALL( icvFindDominantPointsIPAN( contour, storage, &corners,
dmin*dmin, dmax*dmax, dneigh*dneigh, (float)amax ));
}
break;
default:
CV_ERROR_FROM_STATUS( CV_BADFLAG_ERR );
}
__END__;
return corners;
}
/* End of file. */

View File

@@ -0,0 +1,234 @@
/*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*/
#include "_cv.h"
#define cmp_features( f1, f2 ) (*(f1) > *(f2))
static CV_IMPLEMENT_QSORT( icvSortFeatures, int *, cmp_features )
CV_IMPL void
cvGoodFeaturesToTrack( const void* image, void* eigImage, void* tempImage,
CvPoint2D32f* corners, int *corner_count,
double quality_level, double min_distance,
const void* maskImage, int block_size,
int use_harris, double harris_k )
{
CvMat* _eigImg = 0;
CvMat* _tmpImg = 0;
CV_FUNCNAME( "cvGoodFeaturesToTrack" );
__BEGIN__;
double max_val = 0;
int max_count = 0;
int count = 0;
int x, y, i, k = 0;
int min_dist;
int eig_step, tmp_step;
/* when selecting points, use integer coordinates */
CvPoint *ptr = (CvPoint *) corners;
/* process floating-point images using integer arithmetics */
int *eig_data = 0;
int *tmp_data = 0;
int **ptr_data = 0;
uchar *mask_data = 0;
int mask_step = 0;
CvSize size;
int coi1 = 0, coi2 = 0, coi3 = 0;
CvMat stub, *img = (CvMat*)image;
CvMat eig_stub, *eig = (CvMat*)eigImage;
CvMat tmp_stub, *tmp = (CvMat*)tempImage;
CvMat mask_stub, *mask = (CvMat*)maskImage;
if( corner_count )
{
max_count = *corner_count;
*corner_count = 0;
}
CV_CALL( img = cvGetMat( img, &stub, &coi1 ));
if( eig )
{
CV_CALL( eig = cvGetMat( eig, &eig_stub, &coi2 ));
}
else
{
CV_CALL( _eigImg = cvCreateMat( img->rows, img->cols, CV_32FC1 ));
eig = _eigImg;
}
if( tmp )
{
CV_CALL( tmp = cvGetMat( tmp, &tmp_stub, &coi3 ));
}
else
{
CV_CALL( _tmpImg = cvCreateMat( img->rows, img->cols, CV_32FC1 ));
tmp = _tmpImg;
}
if( mask )
{
CV_CALL( mask = cvGetMat( mask, &mask_stub ));
if( !CV_IS_MASK_ARR( mask ))
{
CV_ERROR( CV_StsBadMask, "" );
}
}
if( coi1 != 0 || coi2 != 0 || coi3 != 0 )
CV_ERROR( CV_BadCOI, "" );
if( CV_MAT_CN(img->type) != 1 ||
CV_MAT_CN(eig->type) != 1 ||
CV_MAT_CN(tmp->type) != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
if( CV_MAT_DEPTH(tmp->type) != CV_32F ||
CV_MAT_DEPTH(eig->type) != CV_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
if( !corners || !corner_count )
CV_ERROR( CV_StsNullPtr, "" );
if( max_count <= 0 )
CV_ERROR( CV_StsBadArg, "maximal corners number is non positive" );
if( quality_level <= 0 || min_distance < 0 )
CV_ERROR( CV_StsBadArg, "quality level or min distance are non positive" );
if( use_harris )
{
CV_CALL( cvCornerHarris( img, eig, block_size, 3, harris_k ));
}
else
{
CV_CALL( cvCornerMinEigenVal( img, eig, block_size, 3 ));
}
CV_CALL( cvMinMaxLoc( eig, 0, &max_val, 0, 0, mask ));
CV_CALL( cvThreshold( eig, eig, max_val * quality_level,
0, CV_THRESH_TOZERO ));
CV_CALL( cvDilate( eig, tmp ));
min_dist = cvRound( min_distance * min_distance );
size = cvGetMatSize( img );
ptr_data = (int**)(tmp->data.ptr);
eig_data = (int*)(eig->data.ptr);
tmp_data = (int*)(tmp->data.ptr);
if( mask )
{
mask_data = (uchar*)(mask->data.ptr);
mask_step = mask->step;
}
eig_step = eig->step / sizeof(eig_data[0]);
tmp_step = tmp->step / sizeof(tmp_data[0]);
/* collect list of pointers to features - put them into temporary image */
for( y = 1, k = 0; y < size.height - 1; y++ )
{
eig_data += eig_step;
tmp_data += tmp_step;
mask_data += mask_step;
for( x = 1; x < size.width - 1; x++ )
{
int val = eig_data[x];
if( val != 0 && val == tmp_data[x] && (!mask || mask_data[x]) )
ptr_data[k++] = eig_data + x;
}
}
icvSortFeatures( ptr_data, k, 0 );
/* select the strongest features */
for( i = 0; i < k; i++ )
{
int j = count, ofs = (int)((uchar*)(ptr_data[i]) - eig->data.ptr);
y = ofs / eig->step;
x = (ofs - y * eig->step)/sizeof(float);
if( min_dist != 0 )
{
for( j = 0; j < count; j++ )
{
int dx = x - ptr[j].x;
int dy = y - ptr[j].y;
int dist = dx * dx + dy * dy;
if( dist < min_dist )
break;
}
}
if( j == count )
{
ptr[count].x = x;
ptr[count].y = y;
if( ++count >= max_count )
break;
}
}
/* convert points to floating-point format */
for( i = 0; i < count; i++ )
{
assert( (unsigned)ptr[i].x < (unsigned)size.width &&
(unsigned)ptr[i].y < (unsigned)size.height );
corners[i].x = (float)ptr[i].x;
corners[i].y = (float)ptr[i].y;
}
*corner_count = count;
__END__;
cvReleaseMat( &_eigImg );
cvReleaseMat( &_tmpImg );
}
/* End of file. */

View File

@@ -0,0 +1,355 @@
/*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*/
#include "_cv.h"
CV_IMPL CvRect
cvMaxRect( const CvRect* rect1, const CvRect* rect2 )
{
if( rect1 && rect2 )
{
CvRect max_rect;
int a, b;
max_rect.x = a = rect1->x;
b = rect2->x;
if( max_rect.x > b )
max_rect.x = b;
max_rect.width = a += rect1->width;
b += rect2->width;
if( max_rect.width < b )
max_rect.width = b;
max_rect.width -= max_rect.x;
max_rect.y = a = rect1->y;
b = rect2->y;
if( max_rect.y > b )
max_rect.y = b;
max_rect.height = a += rect1->height;
b += rect2->height;
if( max_rect.height < b )
max_rect.height = b;
max_rect.height -= max_rect.y;
return max_rect;
}
else if( rect1 )
return *rect1;
else if( rect2 )
return *rect2;
else
return cvRect(0,0,0,0);
}
CV_IMPL void
cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] )
{
CV_FUNCNAME( "cvBoxPoints" );
__BEGIN__;
double angle = box.angle*CV_PI/180.;
float a = (float)cos(angle)*0.5f;
float b = (float)sin(angle)*0.5f;
if( !pt )
CV_ERROR( CV_StsNullPtr, "NULL vertex array pointer" );
pt[0].x = box.center.x - a*box.size.height - b*box.size.width;
pt[0].y = box.center.y + b*box.size.height - a*box.size.width;
pt[1].x = box.center.x + a*box.size.height - b*box.size.width;
pt[1].y = box.center.y - b*box.size.height - a*box.size.width;
pt[2].x = 2*box.center.x - pt[0].x;
pt[2].y = 2*box.center.y - pt[0].y;
pt[3].x = 2*box.center.x - pt[1].x;
pt[3].y = 2*box.center.y - pt[1].y;
__END__;
}
int
icvIntersectLines( double x1, double dx1, double y1, double dy1,
double x2, double dx2, double y2, double dy2, double *t2 )
{
double d = dx1 * dy2 - dx2 * dy1;
int result = -1;
if( d != 0 )
{
*t2 = ((x2 - x1) * dy1 - (y2 - y1) * dx1) / d;
result = 0;
}
return result;
}
void
icvCreateCenterNormalLine( CvSubdiv2DEdge edge, double *_a, double *_b, double *_c )
{
CvPoint2D32f org = cvSubdiv2DEdgeOrg( edge )->pt;
CvPoint2D32f dst = cvSubdiv2DEdgeDst( edge )->pt;
double a = dst.x - org.x;
double b = dst.y - org.y;
double c = -(a * (dst.x + org.x) + b * (dst.y + org.y));
*_a = a + a;
*_b = b + b;
*_c = c;
}
void
icvIntersectLines3( double *a0, double *b0, double *c0,
double *a1, double *b1, double *c1, CvPoint2D32f * point )
{
double det = a0[0] * b1[0] - a1[0] * b0[0];
if( det != 0 )
{
det = 1. / det;
point->x = (float) ((b0[0] * c1[0] - b1[0] * c0[0]) * det);
point->y = (float) ((a1[0] * c0[0] - a0[0] * c1[0]) * det);
}
else
{
point->x = point->y = FLT_MAX;
}
}
CV_IMPL double
cvPointPolygonTest( const CvArr* _contour, CvPoint2D32f pt, int measure_dist )
{
double result = 0;
CV_FUNCNAME( "cvCheckPointPolygon" );
__BEGIN__;
CvSeqBlock block;
CvContour header;
CvSeq* contour = (CvSeq*)_contour;
CvSeqReader reader;
int i, total, counter = 0;
int is_float;
double min_dist_num = FLT_MAX, min_dist_denom = 1;
CvPoint ip = {0,0};
if( !CV_IS_SEQ(contour) )
{
CV_CALL( contour = cvPointSeqFromMat( CV_SEQ_KIND_CURVE + CV_SEQ_FLAG_CLOSED,
_contour, &header, &block ));
}
else if( CV_IS_SEQ_POLYGON(contour) )
{
if( contour->header_size == sizeof(CvContour) && !measure_dist )
{
CvRect r = ((CvContour*)contour)->rect;
if( pt.x < r.x || pt.y < r.y ||
pt.x >= r.x + r.width || pt.y >= r.y + r.height )
return -100;
}
}
else if( CV_IS_SEQ_CHAIN(contour) )
{
CV_ERROR( CV_StsBadArg,
"Chains are not supported. Convert them to polygonal representation using cvApproxChains()" );
}
else
CV_ERROR( CV_StsBadArg, "Input contour is neither a valid sequence nor a matrix" );
total = contour->total;
is_float = CV_SEQ_ELTYPE(contour) == CV_32FC2;
cvStartReadSeq( contour, &reader, -1 );
if( !is_float && !measure_dist && (ip.x = cvRound(pt.x)) == pt.x && (ip.y = cvRound(pt.y)) == pt.y )
{
// the fastest "pure integer" branch
CvPoint v0, v;
CV_READ_SEQ_ELEM( v, reader );
for( i = 0; i < total; i++ )
{
int dist;
v0 = v;
CV_READ_SEQ_ELEM( v, reader );
if( v0.y <= ip.y && v.y <= ip.y ||
v0.y > ip.y && v.y > ip.y ||
v0.x < ip.x && v.x < ip.x )
{
if( ip.y == v.y && (ip.x == v.x || ip.y == v0.y &&
(v0.x <= ip.x && ip.x <= v.x || v.x <= ip.x && ip.x <= v0.x)) )
EXIT;
continue;
}
dist = (ip.y - v0.y)*(v.x - v0.x) - (ip.x - v0.x)*(v.y - v0.y);
if( dist == 0 )
EXIT;
if( v.y < v0.y )
dist = -dist;
counter += dist > 0;
}
result = counter % 2 == 0 ? -100 : 100;
}
else
{
CvPoint2D32f v0, v;
CvPoint iv;
if( is_float )
{
CV_READ_SEQ_ELEM( v, reader );
}
else
{
CV_READ_SEQ_ELEM( iv, reader );
v = cvPointTo32f( iv );
}
if( !measure_dist )
{
for( i = 0; i < total; i++ )
{
double dist;
v0 = v;
if( is_float )
{
CV_READ_SEQ_ELEM( v, reader );
}
else
{
CV_READ_SEQ_ELEM( iv, reader );
v = cvPointTo32f( iv );
}
if( v0.y <= pt.y && v.y <= pt.y ||
v0.y > pt.y && v.y > pt.y ||
v0.x < pt.x && v.x < pt.x )
{
if( pt.y == v.y && (pt.x == v.x || pt.y == v0.y &&
(v0.x <= pt.x && pt.x <= v.x || v.x <= pt.x && pt.x <= v0.x)) )
EXIT;
continue;
}
dist = (double)(pt.y - v0.y)*(v.x - v0.x) - (double)(pt.x - v0.x)*(v.y - v0.y);
if( dist == 0 )
EXIT;
if( v.y < v0.y )
dist = -dist;
counter += dist > 0;
}
result = counter % 2 == 0 ? -100 : 100;
}
else
{
for( i = 0; i < total; i++ )
{
double dx, dy, dx1, dy1, dx2, dy2, dist_num, dist_denom = 1;
v0 = v;
if( is_float )
{
CV_READ_SEQ_ELEM( v, reader );
}
else
{
CV_READ_SEQ_ELEM( iv, reader );
v = cvPointTo32f( iv );
}
dx = v.x - v0.x; dy = v.y - v0.y;
dx1 = pt.x - v0.x; dy1 = pt.y - v0.y;
dx2 = pt.x - v.x; dy2 = pt.y - v.y;
if( dx1*dx + dy1*dy <= 0 )
dist_num = dx1*dx1 + dy1*dy1;
else if( dx2*dx + dy2*dy >= 0 )
dist_num = dx2*dx2 + dy2*dy2;
else
{
dist_num = (dy1*dx - dx1*dy);
dist_num *= dist_num;
dist_denom = dx*dx + dy*dy;
}
if( dist_num*min_dist_denom < min_dist_num*dist_denom )
{
min_dist_num = dist_num;
min_dist_denom = dist_denom;
if( min_dist_num == 0 )
break;
}
if( v0.y <= pt.y && v.y <= pt.y ||
v0.y > pt.y && v.y > pt.y ||
v0.x < pt.x && v.x < pt.x )
continue;
dist_num = dy1*dx - dx1*dy;
if( dy < 0 )
dist_num = -dist_num;
counter += dist_num > 0;
}
result = sqrt(min_dist_num/min_dist_denom);
if( counter % 2 == 0 )
result = -result;
}
}
__END__;
return result;
}
/* End of file. */

View File

@@ -0,0 +1,821 @@
/*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 icvers.
//
// 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*/
/* ////////////////////////////////////////////////////////////////////
//
// Geometrical transforms on images and matrices: rotation, zoom etc.
//
// */
#include "_cv.h"
#undef CV_MAT_ELEM_PTR_FAST
#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \
((mat).data.ptr + (size_t)(mat).step*(row) + (pix_size)*(col))
inline float
min4( float a, float b, float c, float d )
{
a = MIN(a,b);
c = MIN(c,d);
return MIN(a,c);
}
#define CV_MAT_3COLOR_ELEM(img,type,y,x,c) CV_MAT_ELEM(img,type,y,(x)*3+(c))
#define KNOWN 0 //known outside narrow band
#define BAND 1 //narrow band (known)
#define INSIDE 2 //unknown
#define CHANGE 3 //servise
typedef struct CvHeapElem
{
float T;
int i,j;
struct CvHeapElem* prev;
struct CvHeapElem* next;
}
CvHeapElem;
class CvPriorityQueueFloat
{
protected:
CvHeapElem *mem,*empty,*head,*tail;
int num,in;
public:
bool Init( const CvMat* f )
{
int i,j;
for( i = num = 0; i < f->rows; i++ )
{
for( j = 0; j < f->cols; j++ )
num += CV_MAT_ELEM(*f,uchar,i,j)!=0;
}
if (num<=0) return false;
mem = (CvHeapElem*)cvAlloc((num+2)*sizeof(CvHeapElem));
if (mem==NULL) return false;
head = mem;
head->i = head->j = -1;
head->prev = NULL;
head->next = mem+1;
head->T = -FLT_MAX;
empty = mem+1;
for (i=1; i<=num; i++) {
mem[i].prev = mem+i-1;
mem[i].next = mem+i+1;
mem[i].i = mem[i].i = -1;
mem[i].T = FLT_MAX;
}
tail = mem+i;
tail->i = tail->j = -1;
tail->prev = mem+i-1;
tail->next = NULL;
tail->T = FLT_MAX;
return true;
}
bool Add(const CvMat* f) {
int i,j;
for (i=0; i<f->rows; i++) {
for (j=0; j<f->cols; j++) {
if (CV_MAT_ELEM(*f,uchar,i,j)!=0) {
if (!Push(i,j,0)) return false;
}
}
}
return true;
}
bool Push(int i, int j, float T) {
CvHeapElem *tmp=empty,*add=empty;
if (empty==tail) return false;
while (tmp->prev->T>T) tmp = tmp->prev;
if (tmp!=empty) {
add->prev->next = add->next;
add->next->prev = add->prev;
empty = add->next;
add->prev = tmp->prev;
add->next = tmp;
add->prev->next = add;
add->next->prev = add;
} else {
empty = empty->next;
}
add->i = i;
add->j = j;
add->T = T;
in++;
// printf("push i %3d j %3d T %12.4e in %4d\n",i,j,T,in);
return true;
}
bool Pop(int *i, int *j) {
CvHeapElem *tmp=head->next;
if (empty==tmp) return false;
*i = tmp->i;
*j = tmp->j;
tmp->prev->next = tmp->next;
tmp->next->prev = tmp->prev;
tmp->prev = empty->prev;
tmp->next = empty;
tmp->prev->next = tmp;
tmp->next->prev = tmp;
empty = tmp;
in--;
// printf("pop i %3d j %3d T %12.4e in %4d\n",tmp->i,tmp->j,tmp->T,in);
return true;
}
bool Pop(int *i, int *j, float *T) {
CvHeapElem *tmp=head->next;
if (empty==tmp) return false;
*i = tmp->i;
*j = tmp->j;
*T = tmp->T;
tmp->prev->next = tmp->next;
tmp->next->prev = tmp->prev;
tmp->prev = empty->prev;
tmp->next = empty;
tmp->prev->next = tmp;
tmp->next->prev = tmp;
empty = tmp;
in--;
// printf("pop i %3d j %3d T %12.4e in %4d\n",tmp->i,tmp->j,tmp->T,in);
return true;
}
CvPriorityQueueFloat(void) {
num=in=0;
mem=empty=head=tail=NULL;
}
~CvPriorityQueueFloat(void)
{
cvFree( &mem );
}
};
inline float VectorScalMult(CvPoint2D32f v1,CvPoint2D32f v2) {
return v1.x*v2.x+v1.y*v2.y;
}
inline float VectorLength(CvPoint2D32f v1) {
return v1.x*v1.x+v1.y*v1.y;
}
///////////////////////////////////////////////////////////////////////////////////////////
//HEAP::iterator Heap_Iterator;
//HEAP Heap;
float FastMarching_solve(int i1,int j1,int i2,int j2, const CvMat* f, const CvMat* t)
{
double sol, a11, a22, m12;
a11=CV_MAT_ELEM(*t,float,i1,j1);
a22=CV_MAT_ELEM(*t,float,i2,j2);
m12=MIN(a11,a22);
if( CV_MAT_ELEM(*f,uchar,i1,j1) != INSIDE )
if( CV_MAT_ELEM(*f,uchar,i2,j2) != INSIDE )
if( fabs(a11-a22) >= 1.0 )
sol = 1+m12;
else
sol = (a11+a22+sqrt((double)(2-(a11-a22)*(a11-a22))))*0.5;
else
sol = 1+a11;
else if( CV_MAT_ELEM(*f,uchar,i2,j2) != INSIDE )
sol = 1+a22;
else
sol = 1+m12;
return (float)sol;
}
/////////////////////////////////////////////////////////////////////////////////////
static void
icvCalcFMM(const CvMat *f, CvMat *t, CvPriorityQueueFloat *Heap, bool negate) {
int i, j, ii = 0, jj = 0, q;
float dist;
while (Heap->Pop(&ii,&jj)) {
unsigned known=(negate)?CHANGE:KNOWN;
CV_MAT_ELEM(*f,uchar,ii,jj) = (uchar)known;
for (q=0; q<4; q++) {
i=0; j=0;
if (q==0) {i=ii-1; j=jj;}
else if(q==1) {i=ii; j=jj-1;}
else if(q==2) {i=ii+1; j=jj;}
else {i=ii; j=jj+1;}
if ((i<=0)||(j<=0)||(i>f->rows)||(j>f->cols)) continue;
if (CV_MAT_ELEM(*f,uchar,i,j)==INSIDE) {
dist = min4(FastMarching_solve(i-1,j,i,j-1,f,t),
FastMarching_solve(i+1,j,i,j-1,f,t),
FastMarching_solve(i-1,j,i,j+1,f,t),
FastMarching_solve(i+1,j,i,j+1,f,t));
CV_MAT_ELEM(*t,float,i,j) = dist;
CV_MAT_ELEM(*f,uchar,i,j) = BAND;
Heap->Push(i,j,dist);
}
}
}
if (negate) {
for (i=0; i<f->rows; i++) {
for(j=0; j<f->cols; j++) {
if (CV_MAT_ELEM(*f,uchar,i,j) == CHANGE) {
CV_MAT_ELEM(*f,uchar,i,j) = KNOWN;
CV_MAT_ELEM(*t,float,i,j) = -CV_MAT_ELEM(*t,float,i,j);
}
}
}
}
}
static void
icvTeleaInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueueFloat *Heap ) {
int i = 0, j = 0, ii = 0, jj = 0, k, l, q, color = 0;
float dist;
if (CV_MAT_CN(out->type)==3) {
while (Heap->Pop(&ii,&jj)) {
CV_MAT_ELEM(*f,uchar,ii,jj) = KNOWN;
for(q=0; q<4; q++) {
if (q==0) {i=ii-1; j=jj;}
else if(q==1) {i=ii; j=jj-1;}
else if(q==2) {i=ii+1; j=jj;}
else if(q==3) {i=ii; j=jj+1;}
if ((i<=1)||(j<=1)||(i>t->rows-1)||(j>t->cols-1)) continue;
if (CV_MAT_ELEM(*f,uchar,i,j)==INSIDE) {
dist = min4(FastMarching_solve(i-1,j,i,j-1,f,t),
FastMarching_solve(i+1,j,i,j-1,f,t),
FastMarching_solve(i-1,j,i,j+1,f,t),
FastMarching_solve(i+1,j,i,j+1,f,t));
CV_MAT_ELEM(*t,float,i,j) = dist;
for (color=0; color<=2; color++) {
CvPoint2D32f gradI,gradT,r;
float Ia=0,Jx=0,Jy=0,s=1.0e-20f,w,dst,lev,dir,sat;
if (CV_MAT_ELEM(*f,uchar,i,j+1)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,i,j-1)!=INSIDE) {
gradT.x=(float)((CV_MAT_ELEM(*t,float,i,j+1)-CV_MAT_ELEM(*t,float,i,j-1)))*0.5f;
} else {
gradT.x=(float)((CV_MAT_ELEM(*t,float,i,j+1)-CV_MAT_ELEM(*t,float,i,j)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,i,j-1)!=INSIDE) {
gradT.x=(float)((CV_MAT_ELEM(*t,float,i,j)-CV_MAT_ELEM(*t,float,i,j-1)));
} else {
gradT.x=0;
}
}
if (CV_MAT_ELEM(*f,uchar,i+1,j)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,i-1,j)!=INSIDE) {
gradT.y=(float)((CV_MAT_ELEM(*t,float,i+1,j)-CV_MAT_ELEM(*t,float,i-1,j)))*0.5f;
} else {
gradT.y=(float)((CV_MAT_ELEM(*t,float,i+1,j)-CV_MAT_ELEM(*t,float,i,j)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,i-1,j)!=INSIDE) {
gradT.y=(float)((CV_MAT_ELEM(*t,float,i,j)-CV_MAT_ELEM(*t,float,i-1,j)));
} else {
gradT.y=0;
}
}
for (k=i-range; k<=i+range; k++) {
int km=k-1+(k==1),kp=k-1-(k==t->rows-2);
for (l=j-range; l<=j+range; l++) {
int lm=l-1+(l==1),lp=l-1-(l==t->cols-2);
if (k>0&&l>0&&k<t->rows-1&&l<t->cols-1) {
if ((CV_MAT_ELEM(*f,uchar,k,l)!=INSIDE)&&
((l-j)*(l-j)+(k-i)*(k-i)<=range*range)) {
r.y = (float)(i-k);
r.x = (float)(j-l);
dst = (float)(1./(VectorLength(r)*sqrt((double)VectorLength(r))));
lev = (float)(1./(1+fabs(CV_MAT_ELEM(*t,float,k,l)-CV_MAT_ELEM(*t,float,i,j))));
dir=VectorScalMult(r,gradT);
if (fabs(dir)<=0.01) dir=0.000001f;
w = (float)fabs(dst*lev*dir);
if (CV_MAT_ELEM(*f,uchar,k,l+1)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
gradI.x=(float)((CV_MAT_3COLOR_ELEM(*out,uchar,km,lp+1,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm-1,color)))*2.0f;
} else {
gradI.x=(float)((CV_MAT_3COLOR_ELEM(*out,uchar,km,lp+1,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
gradI.x=(float)((CV_MAT_3COLOR_ELEM(*out,uchar,km,lp,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm-1,color)));
} else {
gradI.x=0;
}
}
if (CV_MAT_ELEM(*f,uchar,k+1,l)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
gradI.y=(float)((CV_MAT_3COLOR_ELEM(*out,uchar,kp+1,lm,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km-1,lm,color)))*2.0f;
} else {
gradI.y=(float)((CV_MAT_3COLOR_ELEM(*out,uchar,kp+1,lm,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
gradI.y=(float)((CV_MAT_3COLOR_ELEM(*out,uchar,kp,lm,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km-1,lm,color)));
} else {
gradI.y=0;
}
}
Ia += (float)w * (float)(CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color));
Jx -= (float)w * (float)(gradI.x*r.x);
Jy -= (float)w * (float)(gradI.y*r.y);
s += w;
}
}
}
}
sat = (float)((Ia/s+(Jx+Jy)/(sqrt(Jx*Jx+Jy*Jy)+1.0e-20f)+0.5f));
{
int isat = cvRound(sat);
CV_MAT_3COLOR_ELEM(*out,uchar,i-1,j-1,color) = CV_CAST_8U(isat);
}
}
CV_MAT_ELEM(*f,uchar,i,j) = BAND;
Heap->Push(i,j,dist);
}
}
}
} else if (CV_MAT_CN(out->type)==1) {
while (Heap->Pop(&ii,&jj)) {
CV_MAT_ELEM(*f,uchar,ii,jj) = KNOWN;
for(q=0; q<4; q++) {
if (q==0) {i=ii-1; j=jj;}
else if(q==1) {i=ii; j=jj-1;}
else if(q==2) {i=ii+1; j=jj;}
else if(q==3) {i=ii; j=jj+1;}
if ((i<=1)||(j<=1)||(i>t->rows-1)||(j>t->cols-1)) continue;
if (CV_MAT_ELEM(*f,uchar,i,j)==INSIDE) {
dist = min4(FastMarching_solve(i-1,j,i,j-1,f,t),
FastMarching_solve(i+1,j,i,j-1,f,t),
FastMarching_solve(i-1,j,i,j+1,f,t),
FastMarching_solve(i+1,j,i,j+1,f,t));
CV_MAT_ELEM(*t,float,i,j) = dist;
for (color=0; color<=0; color++) {
CvPoint2D32f gradI,gradT,r;
float Ia=0,Jx=0,Jy=0,s=1.0e-20f,w,dst,lev,dir,sat;
if (CV_MAT_ELEM(*f,uchar,i,j+1)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,i,j-1)!=INSIDE) {
gradT.x=(float)((CV_MAT_ELEM(*t,float,i,j+1)-CV_MAT_ELEM(*t,float,i,j-1)))*0.5f;
} else {
gradT.x=(float)((CV_MAT_ELEM(*t,float,i,j+1)-CV_MAT_ELEM(*t,float,i,j)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,i,j-1)!=INSIDE) {
gradT.x=(float)((CV_MAT_ELEM(*t,float,i,j)-CV_MAT_ELEM(*t,float,i,j-1)));
} else {
gradT.x=0;
}
}
if (CV_MAT_ELEM(*f,uchar,i+1,j)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,i-1,j)!=INSIDE) {
gradT.y=(float)((CV_MAT_ELEM(*t,float,i+1,j)-CV_MAT_ELEM(*t,float,i-1,j)))*0.5f;
} else {
gradT.y=(float)((CV_MAT_ELEM(*t,float,i+1,j)-CV_MAT_ELEM(*t,float,i,j)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,i-1,j)!=INSIDE) {
gradT.y=(float)((CV_MAT_ELEM(*t,float,i,j)-CV_MAT_ELEM(*t,float,i-1,j)));
} else {
gradT.y=0;
}
}
for (k=i-range; k<=i+range; k++) {
int km=k-1+(k==1),kp=k-1-(k==t->rows-2);
for (l=j-range; l<=j+range; l++) {
int lm=l-1+(l==1),lp=l-1-(l==t->cols-2);
if (k>0&&l>0&&k<t->rows-1&&l<t->cols-1) {
if ((CV_MAT_ELEM(*f,uchar,k,l)!=INSIDE)&&
((l-j)*(l-j)+(k-i)*(k-i)<=range*range)) {
r.y = (float)(i-k);
r.x = (float)(j-l);
dst = (float)(1./(VectorLength(r)*sqrt(VectorLength(r))));
lev = (float)(1./(1+fabs(CV_MAT_ELEM(*t,float,k,l)-CV_MAT_ELEM(*t,float,i,j))));
dir=VectorScalMult(r,gradT);
if (fabs(dir)<=0.01) dir=0.000001f;
w = (float)fabs(dst*lev*dir);
if (CV_MAT_ELEM(*f,uchar,k,l+1)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
gradI.x=(float)((CV_MAT_ELEM(*out,uchar,km,lp+1)-CV_MAT_ELEM(*out,uchar,km,lm-1)))*2.0f;
} else {
gradI.x=(float)((CV_MAT_ELEM(*out,uchar,km,lp+1)-CV_MAT_ELEM(*out,uchar,km,lm)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
gradI.x=(float)((CV_MAT_ELEM(*out,uchar,km,lp)-CV_MAT_ELEM(*out,uchar,km,lm-1)));
} else {
gradI.x=0;
}
}
if (CV_MAT_ELEM(*f,uchar,k+1,l)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
gradI.y=(float)((CV_MAT_ELEM(*out,uchar,kp+1,lm)-CV_MAT_ELEM(*out,uchar,km-1,lm)))*2.0f;
} else {
gradI.y=(float)((CV_MAT_ELEM(*out,uchar,kp+1,lm)-CV_MAT_ELEM(*out,uchar,km,lm)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
gradI.y=(float)((CV_MAT_ELEM(*out,uchar,kp,lm)-CV_MAT_ELEM(*out,uchar,km-1,lm)));
} else {
gradI.y=0;
}
}
Ia += (float)w * (float)(CV_MAT_ELEM(*out,uchar,km,lm));
Jx -= (float)w * (float)(gradI.x*r.x);
Jy -= (float)w * (float)(gradI.y*r.y);
s += w;
}
}
}
}
sat = (float)((Ia/s+(Jx+Jy)/(sqrt(Jx*Jx+Jy*Jy)+1.0e-20f)+0.5f));
{
int isat = cvRound(sat);
CV_MAT_ELEM(*out,uchar,i-1,j-1) = CV_CAST_8U(isat);
}
}
CV_MAT_ELEM(*f,uchar,i,j) = BAND;
Heap->Push(i,j,dist);
}
}
}
}
}
static void
icvNSInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueueFloat *Heap) {
int i = 0, j = 0, ii = 0, jj = 0, k, l, q, color = 0;
float dist;
if (CV_MAT_CN(out->type)==3) {
while (Heap->Pop(&ii,&jj)) {
CV_MAT_ELEM(*f,uchar,ii,jj) = KNOWN;
for(q=0; q<4; q++) {
if (q==0) {i=ii-1; j=jj;}
else if(q==1) {i=ii; j=jj-1;}
else if(q==2) {i=ii+1; j=jj;}
else if(q==3) {i=ii; j=jj+1;}
if ((i<=1)||(j<=1)||(i>t->rows-1)||(j>t->cols-1)) continue;
if (CV_MAT_ELEM(*f,uchar,i,j)==INSIDE) {
dist = min4(FastMarching_solve(i-1,j,i,j-1,f,t),
FastMarching_solve(i+1,j,i,j-1,f,t),
FastMarching_solve(i-1,j,i,j+1,f,t),
FastMarching_solve(i+1,j,i,j+1,f,t));
CV_MAT_ELEM(*t,float,i,j) = dist;
for (color=0; color<=2; color++) {
CvPoint2D32f gradI,r;
float Ia=0,s=1.0e-20f,w,dst,dir;
for (k=i-range; k<=i+range; k++) {
int km=k-1+(k==1),kp=k-1-(k==f->rows-2);
for (l=j-range; l<=j+range; l++) {
int lm=l-1+(l==1),lp=l-1-(l==f->cols-2);
if (k>0&&l>0&&k<f->rows-1&&l<f->cols-1) {
if ((CV_MAT_ELEM(*f,uchar,k,l)!=INSIDE)&&
((l-j)*(l-j)+(k-i)*(k-i)<=range*range)) {
r.y=(float)(k-i);
r.x=(float)(l-j);
dst = 1/(VectorLength(r)*VectorLength(r)+1);
if (CV_MAT_ELEM(*f,uchar,k+1,l)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
gradI.x=(float)(abs(CV_MAT_3COLOR_ELEM(*out,uchar,kp+1,lm,color)-CV_MAT_3COLOR_ELEM(*out,uchar,kp,lm,color))+
abs(CV_MAT_3COLOR_ELEM(*out,uchar,kp,lm,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km-1,lm,color)));
} else {
gradI.x=(float)(abs(CV_MAT_3COLOR_ELEM(*out,uchar,kp+1,lm,color)-CV_MAT_3COLOR_ELEM(*out,uchar,kp,lm,color)))*2.0f;
}
} else {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
gradI.x=(float)(abs(CV_MAT_3COLOR_ELEM(*out,uchar,kp,lm,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km-1,lm,color)))*2.0f;
} else {
gradI.x=0;
}
}
if (CV_MAT_ELEM(*f,uchar,k,l+1)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
gradI.y=(float)(abs(CV_MAT_3COLOR_ELEM(*out,uchar,km,lp+1,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color))+
abs(CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm-1,color)));
} else {
gradI.y=(float)(abs(CV_MAT_3COLOR_ELEM(*out,uchar,km,lp+1,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color)))*2.0f;
}
} else {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
gradI.y=(float)(abs(CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color)-CV_MAT_3COLOR_ELEM(*out,uchar,km,lm-1,color)))*2.0f;
} else {
gradI.y=0;
}
}
gradI.x=-gradI.x;
dir=VectorScalMult(r,gradI);
if (fabs(dir)<=0.01) {
dir=0.000001f;
} else {
dir = (float)fabs(VectorScalMult(r,gradI)/sqrt(VectorLength(r)*VectorLength(gradI)));
}
w = dst*dir;
Ia += (float)w * (float)(CV_MAT_3COLOR_ELEM(*out,uchar,km,lm,color));
s += w;
}
}
}
}
{
int out_val = cvRound((double)Ia/s);
CV_MAT_3COLOR_ELEM(*out,uchar,i-1,j-1,color) = CV_CAST_8U(out_val);
}
}
CV_MAT_ELEM(*f,uchar,i,j) = BAND;
Heap->Push(i,j,dist);
}
}
}
} else if (CV_MAT_CN(out->type)==1) {
while (Heap->Pop(&ii,&jj)) {
CV_MAT_ELEM(*f,uchar,ii,jj) = KNOWN;
for(q=0; q<4; q++) {
if (q==0) {i=ii-1; j=jj;}
else if(q==1) {i=ii; j=jj-1;}
else if(q==2) {i=ii+1; j=jj;}
else if(q==3) {i=ii; j=jj+1;}
if ((i<=1)||(j<=1)||(i>t->rows-1)||(j>t->cols-1)) continue;
if (CV_MAT_ELEM(*f,uchar,i,j)==INSIDE) {
dist = min4(FastMarching_solve(i-1,j,i,j-1,f,t),
FastMarching_solve(i+1,j,i,j-1,f,t),
FastMarching_solve(i-1,j,i,j+1,f,t),
FastMarching_solve(i+1,j,i,j+1,f,t));
CV_MAT_ELEM(*t,float,i,j) = dist;
{
CvPoint2D32f gradI,r;
float Ia=0,s=1.0e-20f,w,dst,dir;
for (k=i-range; k<=i+range; k++) {
int km=k-1+(k==1),kp=k-1-(k==t->rows-2);
for (l=j-range; l<=j+range; l++) {
int lm=l-1+(l==1),lp=l-1-(l==t->cols-2);
if (k>0&&l>0&&k<t->rows-1&&l<t->cols-1) {
if ((CV_MAT_ELEM(*f,uchar,k,l)!=INSIDE)&&
((l-j)*(l-j)+(k-i)*(k-i)<=range*range)) {
r.y=(float)(i-k);
r.x=(float)(j-l);
dst = 1/(VectorLength(r)*VectorLength(r)+1);
if (CV_MAT_ELEM(*f,uchar,k+1,l)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
gradI.x=(float)(abs(CV_MAT_ELEM(*out,uchar,kp+1,lm)-CV_MAT_ELEM(*out,uchar,kp,lm))+
abs(CV_MAT_ELEM(*out,uchar,kp,lm)-CV_MAT_ELEM(*out,uchar,km-1,lm)));
} else {
gradI.x=(float)(abs(CV_MAT_ELEM(*out,uchar,kp+1,lm)-CV_MAT_ELEM(*out,uchar,kp,lm)))*2.0f;
}
} else {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
gradI.x=(float)(abs(CV_MAT_ELEM(*out,uchar,kp,lm)-CV_MAT_ELEM(*out,uchar,km-1,lm)))*2.0f;
} else {
gradI.x=0;
}
}
if (CV_MAT_ELEM(*f,uchar,k,l+1)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
gradI.y=(float)(abs(CV_MAT_ELEM(*out,uchar,km,lp+1)-CV_MAT_ELEM(*out,uchar,km,lm))+
abs(CV_MAT_ELEM(*out,uchar,km,lm)-CV_MAT_ELEM(*out,uchar,km,lm-1)));
} else {
gradI.y=(float)(abs(CV_MAT_ELEM(*out,uchar,km,lp+1)-CV_MAT_ELEM(*out,uchar,km,lm)))*2.0f;
}
} else {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
gradI.y=(float)(abs(CV_MAT_ELEM(*out,uchar,km,lm)-CV_MAT_ELEM(*out,uchar,km,lm-1)))*2.0f;
} else {
gradI.y=0;
}
}
gradI.x=-gradI.x;
dir=VectorScalMult(r,gradI);
if (fabs(dir)<=0.01) {
dir=0.000001f;
} else {
dir = (float)fabs(VectorScalMult(r,gradI)/sqrt(VectorLength(r)*VectorLength(gradI)));
}
w = dst*dir;
Ia += (float)w * (float)(CV_MAT_ELEM(*out,uchar,km,lm));
s += w;
}
}
}
}
{
int out_val = cvRound((double)Ia/s);
CV_MAT_ELEM(*out,uchar,i-1,j-1) = CV_CAST_8U(out_val);
}
}
CV_MAT_ELEM(*f,uchar,i,j) = BAND;
Heap->Push(i,j,dist);
}
}
}
}
}
#define SET_BORDER1_C1(image,type,value) {\
int i,j;\
for(j=0; j<image->cols; j++) {\
CV_MAT_ELEM(*image,type,0,j) = value;\
}\
for (i=1; i<image->rows-1; i++) {\
CV_MAT_ELEM(*image,type,i,0) = CV_MAT_ELEM(*image,type,i,image->cols-1) = value;\
}\
for(j=0; j<image->cols; j++) {\
CV_MAT_ELEM(*image,type,erows-1,j) = value;\
}\
}
#define COPY_MASK_BORDER1_C1(src,dst,type) {\
int i,j;\
for (i=0; i<src->rows; i++) {\
for(j=0; j<src->cols; j++) {\
if (CV_MAT_ELEM(*src,type,i,j)!=0)\
CV_MAT_ELEM(*dst,type,i+1,j+1) = INSIDE;\
}\
}\
}
CV_IMPL void
cvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_img,
double inpaintRange, int flags )
{
CvMat *mask = 0, *band = 0, *f = 0, *t = 0, *out = 0;
CvPriorityQueueFloat *Heap = 0, *Out = 0;
IplConvKernel *el_cross = 0, *el_range = 0;
CV_FUNCNAME( "cvInpaint" );
__BEGIN__;
CvMat input_hdr, mask_hdr, output_hdr;
CvMat* input_img, *inpaint_mask, *output_img;
int range=cvRound(inpaintRange);
int erows, ecols;
CV_CALL( input_img = cvGetMat( _input_img, &input_hdr ));
CV_CALL( inpaint_mask = cvGetMat( _inpaint_mask, &mask_hdr ));
CV_CALL( output_img = cvGetMat( _output_img, &output_hdr ));
if( !CV_ARE_SIZES_EQ(input_img,output_img) || !CV_ARE_SIZES_EQ(input_img,inpaint_mask))
CV_ERROR( CV_StsUnmatchedSizes, "All the input and output images must have the same size" );
if( CV_MAT_TYPE(input_img->type) != CV_8UC1 &&
CV_MAT_TYPE(input_img->type) != CV_8UC3 ||
!CV_ARE_TYPES_EQ(input_img,output_img) )
CV_ERROR( CV_StsUnsupportedFormat,
"Only 8-bit 1-channel and 3-channel input/output images are supported" );
if( CV_MAT_TYPE(inpaint_mask->type) != CV_8UC1 )
CV_ERROR( CV_StsUnsupportedFormat, "The mask must be 8-bit 1-channel image" );
range = MAX(range,1);
range = MIN(range,100);
ecols = input_img->cols + 2;
erows = input_img->rows + 2;
CV_CALL( f = cvCreateMat(erows, ecols, CV_8UC1));
CV_CALL( t = cvCreateMat(erows, ecols, CV_32FC1));
CV_CALL( band = cvCreateMat(erows, ecols, CV_8UC1));
CV_CALL( mask = cvCreateMat(erows, ecols, CV_8UC1));
CV_CALL( el_cross = cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_CROSS,NULL));
cvCopy( input_img, output_img );
cvSet(mask,cvScalar(KNOWN,0,0,0));
COPY_MASK_BORDER1_C1(inpaint_mask,mask,uchar);
SET_BORDER1_C1(mask,uchar,0);
cvSet(f,cvScalar(KNOWN,0,0,0));
cvSet(t,cvScalar(1.0e6f,0,0,0));
cvDilate(mask,band,el_cross,1); // image with narrow band
Heap=new CvPriorityQueueFloat;
if (!Heap->Init(band))
EXIT;
cvSub(band,mask,band,NULL);
SET_BORDER1_C1(band,uchar,0);
if (!Heap->Add(band))
EXIT;
cvSet(f,cvScalar(BAND,0,0,0),band);
cvSet(f,cvScalar(INSIDE,0,0,0),mask);
cvSet(t,cvScalar(0,0,0,0),band);
if( flags == CV_INPAINT_TELEA )
{
CV_CALL( out = cvCreateMat(erows, ecols, CV_8UC1));
CV_CALL( el_range = cvCreateStructuringElementEx(2*range+1,2*range+1,
range,range,CV_SHAPE_RECT,NULL));
cvDilate(mask,out,el_range,1);
cvSub(out,mask,out,NULL);
Out=new CvPriorityQueueFloat;
if (!Out->Init(out))
EXIT;
if (!Out->Add(band))
EXIT;
cvSub(out,band,out,NULL);
SET_BORDER1_C1(out,uchar,0);
icvCalcFMM(out,t,Out,true);
icvTeleaInpaintFMM(mask,t,output_img,range,Heap);
}
else
icvNSInpaintFMM(mask,t,output_img,range,Heap);
__END__;
delete Out;
delete Heap;
cvReleaseStructuringElement(&el_cross);
cvReleaseStructuringElement(&el_range);
cvReleaseMat(&out);
cvReleaseMat(&mask);
cvReleaseMat(&band);
cvReleaseMat(&t);
cvReleaseMat(&f);
}

View File

@@ -0,0 +1,241 @@
/*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*/
#include "_cv.h"
CV_IMPL CvKalman*
cvCreateKalman( int DP, int MP, int CP )
{
CvKalman *kalman = 0;
CV_FUNCNAME( "cvCreateKalman" );
__BEGIN__;
if( DP <= 0 || MP <= 0 )
CV_ERROR( CV_StsOutOfRange,
"state and measurement vectors must have positive number of dimensions" );
if( CP < 0 )
CP = DP;
/* allocating memory for the structure */
CV_CALL( kalman = (CvKalman *)cvAlloc( sizeof( CvKalman )));
memset( kalman, 0, sizeof(*kalman));
kalman->DP = DP;
kalman->MP = MP;
kalman->CP = CP;
CV_CALL( kalman->state_pre = cvCreateMat( DP, 1, CV_32FC1 ));
cvZero( kalman->state_pre );
CV_CALL( kalman->state_post = cvCreateMat( DP, 1, CV_32FC1 ));
cvZero( kalman->state_post );
CV_CALL( kalman->transition_matrix = cvCreateMat( DP, DP, CV_32FC1 ));
cvSetIdentity( kalman->transition_matrix );
CV_CALL( kalman->process_noise_cov = cvCreateMat( DP, DP, CV_32FC1 ));
cvSetIdentity( kalman->process_noise_cov );
CV_CALL( kalman->measurement_matrix = cvCreateMat( MP, DP, CV_32FC1 ));
cvZero( kalman->measurement_matrix );
CV_CALL( kalman->measurement_noise_cov = cvCreateMat( MP, MP, CV_32FC1 ));
cvSetIdentity( kalman->measurement_noise_cov );
CV_CALL( kalman->error_cov_pre = cvCreateMat( DP, DP, CV_32FC1 ));
CV_CALL( kalman->error_cov_post = cvCreateMat( DP, DP, CV_32FC1 ));
cvZero( kalman->error_cov_post );
CV_CALL( kalman->gain = cvCreateMat( DP, MP, CV_32FC1 ));
if( CP > 0 )
{
CV_CALL( kalman->control_matrix = cvCreateMat( DP, CP, CV_32FC1 ));
cvZero( kalman->control_matrix );
}
CV_CALL( kalman->temp1 = cvCreateMat( DP, DP, CV_32FC1 ));
CV_CALL( kalman->temp2 = cvCreateMat( MP, DP, CV_32FC1 ));
CV_CALL( kalman->temp3 = cvCreateMat( MP, MP, CV_32FC1 ));
CV_CALL( kalman->temp4 = cvCreateMat( MP, DP, CV_32FC1 ));
CV_CALL( kalman->temp5 = cvCreateMat( MP, 1, CV_32FC1 ));
#if 1
kalman->PosterState = kalman->state_pre->data.fl;
kalman->PriorState = kalman->state_post->data.fl;
kalman->DynamMatr = kalman->transition_matrix->data.fl;
kalman->MeasurementMatr = kalman->measurement_matrix->data.fl;
kalman->MNCovariance = kalman->measurement_noise_cov->data.fl;
kalman->PNCovariance = kalman->process_noise_cov->data.fl;
kalman->KalmGainMatr = kalman->gain->data.fl;
kalman->PriorErrorCovariance = kalman->error_cov_pre->data.fl;
kalman->PosterErrorCovariance = kalman->error_cov_post->data.fl;
#endif
__END__;
if( cvGetErrStatus() < 0 )
cvReleaseKalman( &kalman );
return kalman;
}
CV_IMPL void
cvReleaseKalman( CvKalman** _kalman )
{
CvKalman *kalman;
CV_FUNCNAME( "cvReleaseKalman" );
__BEGIN__;
if( !_kalman )
CV_ERROR( CV_StsNullPtr, "" );
kalman = *_kalman;
/* freeing the memory */
cvReleaseMat( &kalman->state_pre );
cvReleaseMat( &kalman->state_post );
cvReleaseMat( &kalman->transition_matrix );
cvReleaseMat( &kalman->control_matrix );
cvReleaseMat( &kalman->measurement_matrix );
cvReleaseMat( &kalman->process_noise_cov );
cvReleaseMat( &kalman->measurement_noise_cov );
cvReleaseMat( &kalman->error_cov_pre );
cvReleaseMat( &kalman->gain );
cvReleaseMat( &kalman->error_cov_post );
cvReleaseMat( &kalman->temp1 );
cvReleaseMat( &kalman->temp2 );
cvReleaseMat( &kalman->temp3 );
cvReleaseMat( &kalman->temp4 );
cvReleaseMat( &kalman->temp5 );
memset( kalman, 0, sizeof(*kalman));
/* deallocating the structure */
cvFree( _kalman );
__END__;
}
CV_IMPL const CvMat*
cvKalmanPredict( CvKalman* kalman, const CvMat* control )
{
CvMat* result = 0;
CV_FUNCNAME( "cvKalmanPredict" );
__BEGIN__;
if( !kalman )
CV_ERROR( CV_StsNullPtr, "" );
/* update the state */
/* x'(k) = A*x(k) */
CV_CALL( cvMatMulAdd( kalman->transition_matrix, kalman->state_post, 0, kalman->state_pre ));
if( control && kalman->CP > 0 )
/* x'(k) = x'(k) + B*u(k) */
CV_CALL( cvMatMulAdd( kalman->control_matrix, control, kalman->state_pre, kalman->state_pre ));
/* update error covariance matrices */
/* temp1 = A*P(k) */
CV_CALL( cvMatMulAdd( kalman->transition_matrix, kalman->error_cov_post, 0, kalman->temp1 ));
/* P'(k) = temp1*At + Q */
CV_CALL( cvGEMM( kalman->temp1, kalman->transition_matrix, 1, kalman->process_noise_cov, 1,
kalman->error_cov_pre, CV_GEMM_B_T ));
result = kalman->state_pre;
__END__;
return result;
}
CV_IMPL const CvMat*
cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement )
{
CvMat* result = 0;
CV_FUNCNAME( "cvKalmanCorrect" );
__BEGIN__;
if( !kalman || !measurement )
CV_ERROR( CV_StsNullPtr, "" );
/* temp2 = H*P'(k) */
CV_CALL( cvMatMulAdd( kalman->measurement_matrix,
kalman->error_cov_pre, 0, kalman->temp2 ));
/* temp3 = temp2*Ht + R */
CV_CALL( cvGEMM( kalman->temp2, kalman->measurement_matrix, 1,
kalman->measurement_noise_cov, 1, kalman->temp3, CV_GEMM_B_T ));
/* temp4 = inv(temp3)*temp2 = Kt(k) */
CV_CALL( cvSolve( kalman->temp3, kalman->temp2, kalman->temp4, CV_SVD ));
/* K(k) */
CV_CALL( cvTranspose( kalman->temp4, kalman->gain ));
/* temp5 = z(k) - H*x'(k) */
CV_CALL( cvGEMM( kalman->measurement_matrix, kalman->state_pre, -1, measurement, 1, kalman->temp5 ));
/* x(k) = x'(k) + K(k)*temp5 */
CV_CALL( cvMatMulAdd( kalman->gain, kalman->temp5, kalman->state_pre, kalman->state_post ));
/* P(k) = P'(k) - K(k)*temp2 */
CV_CALL( cvGEMM( kalman->gain, kalman->temp2, -1, kalman->error_cov_pre, 1,
kalman->error_cov_post, 0 ));
result = kalman->state_post;
__END__;
return result;
}

View File

@@ -0,0 +1,693 @@
/*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*/
#include "_cv.h"
static const double eps = 1e-6;
static CvStatus
icvFitLine2D_wods( CvPoint2D32f * points, int _count, float *weights, float *line )
{
double x = 0, y = 0, x2 = 0, y2 = 0, xy = 0, w = 0;
double dx2, dy2, dxy;
int i;
int count = _count;
float t;
/* Calculating the average of x and y... */
if( weights == 0 )
{
for( i = 0; i < count; i += 1 )
{
x += points[i].x;
y += points[i].y;
x2 += points[i].x * points[i].x;
y2 += points[i].y * points[i].y;
xy += points[i].x * points[i].y;
}
w = (float) count;
}
else
{
for( i = 0; i < count; i += 1 )
{
x += weights[i] * points[i].x;
y += weights[i] * points[i].y;
x2 += weights[i] * points[i].x * points[i].x;
y2 += weights[i] * points[i].y * points[i].y;
xy += weights[i] * points[i].x * points[i].y;
w += weights[i];
}
}
x /= w;
y /= w;
x2 /= w;
y2 /= w;
xy /= w;
dx2 = x2 - x * x;
dy2 = y2 - y * y;
dxy = xy - x * y;
t = (float) atan2( 2 * dxy, dx2 - dy2 ) / 2;
line[0] = (float) cos( t );
line[1] = (float) sin( t );
line[2] = (float) x;
line[3] = (float) y;
return CV_NO_ERR;
}
static CvStatus
icvFitLine3D_wods( CvPoint3D32f * points, int count, float *weights, float *line )
{
int i;
float w0 = 0;
float x0 = 0, y0 = 0, z0 = 0;
float x2 = 0, y2 = 0, z2 = 0, xy = 0, yz = 0, xz = 0;
float dx2, dy2, dz2, dxy, dxz, dyz;
float *v;
float n;
float det[9], evc[9], evl[3];
memset( evl, 0, 3*sizeof(evl[0]));
memset( evc, 0, 9*sizeof(evl[0]));
if( weights )
{
for( i = 0; i < count; i++ )
{
float x = points[i].x;
float y = points[i].y;
float z = points[i].z;
float w = weights[i];
x2 += x * x * w;
xy += x * y * w;
xz += x * z * w;
y2 += y * y * w;
yz += y * z * w;
z2 += z * z * w;
x0 += x * w;
y0 += y * w;
z0 += z * w;
w0 += w;
}
}
else
{
for( i = 0; i < count; i++ )
{
float x = points[i].x;
float y = points[i].y;
float z = points[i].z;
x2 += x * x;
xy += x * y;
xz += x * z;
y2 += y * y;
yz += y * z;
z2 += z * z;
x0 += x;
y0 += y;
z0 += z;
}
w0 = (float) count;
}
x2 /= w0;
xy /= w0;
xz /= w0;
y2 /= w0;
yz /= w0;
z2 /= w0;
x0 /= w0;
y0 /= w0;
z0 /= w0;
dx2 = x2 - x0 * x0;
dxy = xy - x0 * y0;
dxz = xz - x0 * z0;
dy2 = y2 - y0 * y0;
dyz = yz - y0 * z0;
dz2 = z2 - z0 * z0;
det[0] = dz2 + dy2;
det[1] = -dxy;
det[2] = -dxz;
det[3] = det[1];
det[4] = dx2 + dz2;
det[5] = -dyz;
det[6] = det[2];
det[7] = det[5];
det[8] = dy2 + dx2;
/* Searching for a eigenvector of det corresponding to the minimal eigenvalue */
#if 1
{
CvMat _det = cvMat( 3, 3, CV_32F, det );
CvMat _evc = cvMat( 3, 3, CV_32F, evc );
CvMat _evl = cvMat( 3, 1, CV_32F, evl );
cvEigenVV( &_det, &_evc, &_evl, 0 );
i = evl[0] < evl[1] ? (evl[0] < evl[2] ? 0 : 2) : (evl[1] < evl[2] ? 1 : 2);
}
#else
{
CvMat _det = cvMat( 3, 3, CV_32F, det );
CvMat _evc = cvMat( 3, 3, CV_32F, evc );
CvMat _evl = cvMat( 1, 3, CV_32F, evl );
cvSVD( &_det, &_evl, &_evc, 0, CV_SVD_MODIFY_A+CV_SVD_U_T );
}
i = 2;
#endif
v = &evc[i * 3];
n = (float) sqrt( (double)v[0] * v[0] + (double)v[1] * v[1] + (double)v[2] * v[2] );
n = (float)MAX(n, eps);
line[0] = v[0] / n;
line[1] = v[1] / n;
line[2] = v[2] / n;
line[3] = x0;
line[4] = y0;
line[5] = z0;
return CV_NO_ERR;
}
static double
icvCalcDist2D( CvPoint2D32f * points, int count, float *_line, float *dist )
{
int j;
float px = _line[2], py = _line[3];
float nx = _line[1], ny = -_line[0];
double sum_dist = 0.;
for( j = 0; j < count; j++ )
{
float x, y;
x = points[j].x - px;
y = points[j].y - py;
dist[j] = (float) fabs( nx * x + ny * y );
sum_dist += dist[j];
}
return sum_dist;
}
static double
icvCalcDist3D( CvPoint3D32f * points, int count, float *_line, float *dist )
{
int j;
float px = _line[3], py = _line[4], pz = _line[5];
float vx = _line[0], vy = _line[1], vz = _line[2];
double sum_dist = 0.;
for( j = 0; j < count; j++ )
{
float x, y, z;
double p1, p2, p3;
x = points[j].x - px;
y = points[j].y - py;
z = points[j].z - pz;
p1 = vy * z - vz * y;
p2 = vz * x - vx * z;
p3 = vx * y - vy * x;
dist[j] = (float) sqrt( p1*p1 + p2*p2 + p3*p3 );
sum_dist += dist[j];
}
return sum_dist;
}
static void
icvWeightL1( float *d, int count, float *w )
{
int i;
for( i = 0; i < count; i++ )
{
double t = fabs( (double) d[i] );
w[i] = (float)(1. / MAX(t, eps));
}
}
static void
icvWeightL12( float *d, int count, float *w )
{
int i;
for( i = 0; i < count; i++ )
{
w[i] = 1.0f / (float) sqrt( 1 + (double) (d[i] * d[i] * 0.5) );
}
}
static void
icvWeightHuber( float *d, int count, float *w, float _c )
{
int i;
const float c = _c <= 0 ? 1.345f : _c;
for( i = 0; i < count; i++ )
{
if( d[i] < c )
w[i] = 1.0f;
else
w[i] = c/d[i];
}
}
static void
icvWeightFair( float *d, int count, float *w, float _c )
{
int i;
const float c = _c == 0 ? 1 / 1.3998f : 1 / _c;
for( i = 0; i < count; i++ )
{
w[i] = 1 / (1 + d[i] * c);
}
}
static void
icvWeightWelsch( float *d, int count, float *w, float _c )
{
int i;
const float c = _c == 0 ? 1 / 2.9846f : 1 / _c;
for( i = 0; i < count; i++ )
{
w[i] = (float) exp( -d[i] * d[i] * c * c );
}
}
/* Takes an array of 2D points, type of distance (including user-defined
distance specified by callbacks, fills the array of four floats with line
parameters A, B, C, D, where (A, B) is the normalized direction vector,
(C, D) is the point that belongs to the line. */
static CvStatus icvFitLine2D( CvPoint2D32f * points, int count, int dist,
float _param, float reps, float aeps, float *line )
{
void (*calc_weights) (float *, int, float *) = 0;
void (*calc_weights_param) (float *, int, float *, float) = 0;
float *w; /* weights */
float *r; /* square distances */
int i, j;
float _line[6], _lineprev[6];
int first = 1;
float rdelta = reps != 0 ? reps : 1.0f;
float adelta = aeps != 0 ? aeps : 0.01f;
memset( line, 0, 4*sizeof(line[0]) );
switch (dist)
{
case CV_DIST_L2:
return icvFitLine2D_wods( points, count, 0, line );
case CV_DIST_L1:
calc_weights = icvWeightL1;
break;
case CV_DIST_L12:
calc_weights = icvWeightL12;
break;
case CV_DIST_FAIR:
calc_weights_param = icvWeightFair;
break;
case CV_DIST_WELSCH:
calc_weights_param = icvWeightWelsch;
break;
case CV_DIST_HUBER:
calc_weights_param = icvWeightHuber;
break;
/*case CV_DIST_USER:
calc_weights = (void ( * )(float *, int, float *)) _PFP.fp;
break;*/
default:
return CV_BADFACTOR_ERR;
}
w = (float *) cvAlloc( count * sizeof( float ));
r = (float *) cvAlloc( count * sizeof( float ));
for( i = 0; i < count; i++ )
w[i] = 1.0f;
icvFitLine2D_wods( points, count, 0, _line );
for( i = 0; i < 100; i++ )
{
double sum_w = 0;
if( first )
{
first = 0;
}
else
{
double t = _line[0] * _lineprev[0] + _line[1] * _lineprev[1];
t = MAX(t,-1.);
t = MIN(t,1.);
if( fabs(acos(t)) < adelta )
{
float x, y, d;
x = (float) fabs( _line[2] - _lineprev[2] );
y = (float) fabs( _line[3] - _lineprev[3] );
d = x > y ? x : y;
if( d < rdelta )
goto _exit_;
}
}
/* calculate distances */
if( icvCalcDist2D( points, count, _line, r ) < FLT_EPSILON*count )
break;
/* calculate weights */
if( calc_weights )
{
calc_weights( r, count, w );
}
else if( calc_weights_param )
{
calc_weights_param( r, count, w, _param );
}
else
goto _exit_;
for( j = 0; j < count; j++ )
sum_w += w[j];
if( fabs(sum_w) > FLT_EPSILON )
{
sum_w = 1./sum_w;
for( j = 0; j < count; j++ )
w[j] = (float)(w[j]*sum_w);
}
else
{
for( j = 0; j < count; j++ )
w[j] = 1.f;
}
/* save the line parameters */
memcpy( _lineprev, _line, 4 * sizeof( float ));
/* Run again... */
icvFitLine2D_wods( points, count, w, _line );
}
_exit_:
memcpy( line, _line, 4 * sizeof(line[0]));
cvFree( &w );
cvFree( &r );
return CV_OK;
}
/* Takes an array of 3D points, type of distance (including user-defined
distance specified by callbacks, fills the array of four floats with line
parameters A, B, C, D, E, F, where (A, B, C) is the normalized direction vector,
(D, E, F) is the point that belongs to the line. */
static CvStatus
icvFitLine3D( CvPoint3D32f * points, int count, int dist,
float _param, float reps, float aeps, float *line )
{
void (*calc_weights) (float *, int, float *) = 0;
void (*calc_weights_param) (float *, int, float *, float) = 0;
float *w; /* weights */
float *r; /* square distances */
int i, j;
float _line[6], _lineprev[6];
int first = 1;
float rdelta = reps != 0 ? reps : 1.0f;
float adelta = aeps != 0 ? aeps : 0.01f;
memset( line, 0, 6*sizeof(line[0]) );
switch (dist)
{
case CV_DIST_L2:
return icvFitLine3D_wods( points, count, 0, line );
case CV_DIST_L1:
calc_weights = icvWeightL1;
break;
case CV_DIST_L12:
calc_weights = icvWeightL12;
break;
case CV_DIST_FAIR:
calc_weights_param = icvWeightFair;
break;
case CV_DIST_WELSCH:
calc_weights_param = icvWeightWelsch;
break;
case CV_DIST_HUBER:
calc_weights_param = icvWeightHuber;
break;
/*case CV_DIST_USER:
_PFP.p = param;
calc_weights = (void ( * )(float *, int, float *)) _PFP.fp;
break;*/
default:
return CV_BADFACTOR_ERR;
}
w = (float *) cvAlloc( count * sizeof( float ));
r = (float *) cvAlloc( count * sizeof( float ));
for( i = 0; i < count; i++ )
w[i] = 1.0f;
icvFitLine3D_wods( points, count, 0, _line );
for( i = 0; i < 100; i++ )
{
double sum_w = 0;
if( first )
{
first = 0;
}
else
{
double t = _line[0] * _lineprev[0] + _line[1] * _lineprev[1] + _line[2] * _lineprev[2];
t = MAX(t,-1.);
t = MIN(t,1.);
if( fabs(acos(t)) < adelta )
{
float x, y, z, ax, ay, az, dx, dy, dz, d;
x = _line[3] - _lineprev[3];
y = _line[4] - _lineprev[4];
z = _line[5] - _lineprev[5];
ax = _line[0] - _lineprev[0];
ay = _line[1] - _lineprev[1];
az = _line[2] - _lineprev[2];
dx = (float) fabs( y * az - z * ay );
dy = (float) fabs( z * ax - x * az );
dz = (float) fabs( x * ay - y * ax );
d = dx > dy ? (dx > dz ? dx : dz) : (dy > dz ? dy : dz);
if( d < rdelta )
goto _exit_;
}
}
/* calculate distances */
if( icvCalcDist3D( points, count, _line, r ) < FLT_EPSILON*count )
break;
/* calculate weights */
if( calc_weights )
{
calc_weights( r, count, w );
}
else if( calc_weights_param )
{
calc_weights_param( r, count, w, _param );
}
else
goto _exit_;
for( j = 0; j < count; j++ )
sum_w += w[j];
if( fabs(sum_w) > FLT_EPSILON )
{
sum_w = 1./sum_w;
for( j = 0; j < count; j++ )
w[j] = (float)(w[j]*sum_w);
}
else
{
for( j = 0; j < count; j++ )
w[j] = 1.f;
}
/* save the line parameters */
memcpy( _lineprev, _line, 6 * sizeof( float ));
/* Run again... */
icvFitLine3D_wods( points, count, w, _line );
}
_exit_:
// Return...
memcpy( line, _line, 6 * sizeof(line[0]));
cvFree( &w );
cvFree( &r );
return CV_OK;
}
CV_IMPL void
cvFitLine( const CvArr* array, int dist, double param,
double reps, double aeps, float *line )
{
char* buffer = 0;
CV_FUNCNAME( "cvFitLine" );
__BEGIN__;
char* points = 0;
union { CvContour contour; CvSeq seq; } header;
CvSeqBlock block;
CvSeq* ptseq = (CvSeq*)array;
int type;
if( !line )
CV_ERROR( CV_StsNullPtr, "NULL pointer to line parameters" );
if( CV_IS_SEQ(ptseq) )
{
type = CV_SEQ_ELTYPE(ptseq);
if( ptseq->total == 0 )
CV_ERROR( CV_StsBadSize, "The sequence has no points" );
if( (type!=CV_32FC2 && type!=CV_32FC3 && type!=CV_32SC2 && type!=CV_32SC3) ||
CV_ELEM_SIZE(type) != ptseq->elem_size )
CV_ERROR( CV_StsUnsupportedFormat,
"Input sequence must consist of 2d points or 3d points" );
}
else
{
CvMat* mat = (CvMat*)array;
type = CV_MAT_TYPE(mat->type);
if( !CV_IS_MAT(mat))
CV_ERROR( CV_StsBadArg, "Input array is not a sequence nor matrix" );
if( !CV_IS_MAT_CONT(mat->type) ||
(type!=CV_32FC2 && type!=CV_32FC3 && type!=CV_32SC2 && type!=CV_32SC3) ||
(mat->width != 1 && mat->height != 1))
CV_ERROR( CV_StsBadArg,
"Input array must be 1d continuous array of 2d or 3d points" );
CV_CALL( ptseq = cvMakeSeqHeaderForArray(
CV_SEQ_KIND_GENERIC|type, sizeof(CvContour), CV_ELEM_SIZE(type), mat->data.ptr,
mat->width + mat->height - 1, &header.seq, &block ));
}
if( reps < 0 || aeps < 0 )
CV_ERROR( CV_StsOutOfRange, "Both reps and aeps must be non-negative" );
if( CV_MAT_DEPTH(type) == CV_32F && ptseq->first->next == ptseq->first )
{
/* no need to copy data in this case */
points = ptseq->first->data;
}
else
{
CV_CALL( buffer = points = (char*)cvAlloc( ptseq->total*CV_ELEM_SIZE(type) ));
CV_CALL( cvCvtSeqToArray( ptseq, points, CV_WHOLE_SEQ ));
if( CV_MAT_DEPTH(type) != CV_32F )
{
int i, total = ptseq->total*CV_MAT_CN(type);
assert( CV_MAT_DEPTH(type) == CV_32S );
for( i = 0; i < total; i++ )
((float*)points)[i] = (float)((int*)points)[i];
}
}
if( dist == CV_DIST_USER )
CV_ERROR( CV_StsBadArg, "User-defined distance is not allowed" );
if( CV_MAT_CN(type) == 2 )
{
IPPI_CALL( icvFitLine2D( (CvPoint2D32f*)points, ptseq->total,
dist, (float)param, (float)reps, (float)aeps, line ));
}
else
{
IPPI_CALL( icvFitLine3D( (CvPoint3D32f*)points, ptseq->total,
dist, (float)param, (float)reps, (float)aeps, line ));
}
__END__;
cvFree( &buffer );
}
/* End of file. */

View File

@@ -0,0 +1,398 @@
/*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*/
#include "_cv.h"
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvMatchContours
// Purpose:
// Calculates matching of the two contours
// Context:
// Parameters:
// contour_1 - pointer to the first input contour object.
// contour_2 - pointer to the second input contour object.
// method - method for the matching calculation
// (now CV_IPPI_CONTOURS_MATCH_I1, CV_CONTOURS_MATCH_I2 or
// CV_CONTOURS_MATCH_I3 only )
// rezult - output calculated measure
//
//F*/
CV_IMPL double
cvMatchShapes( const void* contour1, const void* contour2,
int method, double /*parameter*/ )
{
CvMoments moments;
CvHuMoments huMoments;
double ma[7], mb[7];
int i, sma, smb;
double eps = 1.e-5;
double mmm;
double result = 0;
CV_FUNCNAME( "cvMatchShapes" );
__BEGIN__;
if( !contour1 || !contour2 )
CV_ERROR( CV_StsNullPtr, "" );
/* first moments calculation */
CV_CALL( cvMoments( contour1, &moments ));
/* Hu moments calculation */
CV_CALL( cvGetHuMoments( &moments, &huMoments ));
ma[0] = huMoments.hu1;
ma[1] = huMoments.hu2;
ma[2] = huMoments.hu3;
ma[3] = huMoments.hu4;
ma[4] = huMoments.hu5;
ma[5] = huMoments.hu6;
ma[6] = huMoments.hu7;
/* second moments calculation */
CV_CALL( cvMoments( contour2, &moments ));
/* Hu moments calculation */
CV_CALL( cvGetHuMoments( &moments, &huMoments ));
mb[0] = huMoments.hu1;
mb[1] = huMoments.hu2;
mb[2] = huMoments.hu3;
mb[3] = huMoments.hu4;
mb[4] = huMoments.hu5;
mb[5] = huMoments.hu6;
mb[6] = huMoments.hu7;
switch (method)
{
case 1:
{
for( i = 0; i < 7; i++ )
{
double ama = fabs( ma[i] );
double amb = fabs( mb[i] );
if( ma[i] > 0 )
sma = 1;
else if( ma[i] < 0 )
sma = -1;
else
sma = 0;
if( mb[i] > 0 )
smb = 1;
else if( mb[i] < 0 )
smb = -1;
else
smb = 0;
if( ama > eps && amb > eps )
{
ama = 1. / (sma * log10( ama ));
amb = 1. / (smb * log10( amb ));
result += fabs( -ama + amb );
}
}
break;
}
case 2:
{
for( i = 0; i < 7; i++ )
{
double ama = fabs( ma[i] );
double amb = fabs( mb[i] );
if( ma[i] > 0 )
sma = 1;
else if( ma[i] < 0 )
sma = -1;
else
sma = 0;
if( mb[i] > 0 )
smb = 1;
else if( mb[i] < 0 )
smb = -1;
else
smb = 0;
if( ama > eps && amb > eps )
{
ama = sma * log10( ama );
amb = smb * log10( amb );
result += fabs( -ama + amb );
}
}
break;
}
case 3:
{
for( i = 0; i < 7; i++ )
{
double ama = fabs( ma[i] );
double amb = fabs( mb[i] );
if( ma[i] > 0 )
sma = 1;
else if( ma[i] < 0 )
sma = -1;
else
sma = 0;
if( mb[i] > 0 )
smb = 1;
else if( mb[i] < 0 )
smb = -1;
else
smb = 0;
if( ama > eps && amb > eps )
{
ama = sma * log10( ama );
amb = smb * log10( amb );
mmm = fabs( (ama - amb) / ama );
if( result < mmm )
result = mmm;
}
}
break;
}
default:
CV_ERROR_FROM_STATUS( CV_BADCOEF_ERR );
}
__END__;
return result;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvMatchContourTrees
// Purpose:
// Calculates matching of the two contour trees
// Context:
// Parameters:
// tree1 - pointer to the first input contour tree object.
// tree2 - pointer to the second input contour tree object.
// method - method for the matching calculation
// (now CV_CONTOUR_TREES_MATCH_I1 only )
// threshold - threshold for the contour trees matching
// result - output calculated measure
//F*/
CV_IMPL double
cvMatchContourTrees( const CvContourTree* tree1, const CvContourTree* tree2,
int method, double threshold )
{
_CvTrianAttr **ptr_p1 = 0, **ptr_p2 = 0; /*pointers to the pointer's buffer */
_CvTrianAttr **ptr_n1 = 0, **ptr_n2 = 0; /*pointers to the pointer's buffer */
_CvTrianAttr **ptr11, **ptr12, **ptr21, **ptr22;
int lpt1, lpt2, lpt, flag, flag_n, i, j, ibuf, ibuf1;
double match_v, d12, area1, area2, r11, r12, r21, r22, w1, w2;
double eps = 1.e-5;
char s1, s2;
_CvTrianAttr tree_1, tree_2; /*current vertex 1 and 2 tree */
CvSeqReader reader1, reader2;
double result = 0;
CV_FUNCNAME("cvMatchContourTrees");
__BEGIN__;
if( !tree1 || !tree2 )
CV_ERROR( CV_StsNullPtr, "" );
if( method != CV_CONTOUR_TREES_MATCH_I1 )
CV_ERROR( CV_StsBadArg, "Unknown/unsupported comparison method" );
if( !CV_IS_SEQ_POLYGON_TREE( tree1 ))
CV_ERROR( CV_StsBadArg, "The first argument is not a valid contour tree" );
if( !CV_IS_SEQ_POLYGON_TREE( tree2 ))
CV_ERROR( CV_StsBadArg, "The second argument is not a valid contour tree" );
lpt1 = tree1->total;
lpt2 = tree2->total;
lpt = lpt1 > lpt2 ? lpt1 : lpt2;
ptr_p1 = ptr_n1 = ptr_p2 = ptr_n2 = NULL;
CV_CALL( ptr_p1 = (_CvTrianAttr **) cvAlloc( lpt * sizeof( _CvTrianAttr * )));
CV_CALL( ptr_p2 = (_CvTrianAttr **) cvAlloc( lpt * sizeof( _CvTrianAttr * )));
CV_CALL( ptr_n1 = (_CvTrianAttr **) cvAlloc( lpt * sizeof( _CvTrianAttr * )));
CV_CALL( ptr_n2 = (_CvTrianAttr **) cvAlloc( lpt * sizeof( _CvTrianAttr * )));
cvStartReadSeq( (CvSeq *) tree1, &reader1, 0 );
cvStartReadSeq( (CvSeq *) tree2, &reader2, 0 );
/*read the root of the first and second tree*/
CV_READ_SEQ_ELEM( tree_1, reader1 );
CV_READ_SEQ_ELEM( tree_2, reader2 );
/*write to buffer pointers to root's childs vertexs*/
ptr_p1[0] = tree_1.next_v1;
ptr_p1[1] = tree_1.next_v2;
ptr_p2[0] = tree_2.next_v1;
ptr_p2[1] = tree_2.next_v2;
i = 2;
match_v = 0.;
area1 = tree_1.area;
area2 = tree_2.area;
if( area1 < eps || area2 < eps || lpt < 4 )
CV_ERROR( CV_StsBadSize, "" );
r11 = r12 = r21 = r22 = w1 = w2 = d12 = 0;
flag = 0;
s1 = s2 = 0;
do
{
if( flag == 0 )
{
ptr11 = ptr_p1;
ptr12 = ptr_n1;
ptr21 = ptr_p2;
ptr22 = ptr_n2;
flag = 1;
}
else
{
ptr11 = ptr_n1;
ptr12 = ptr_p1;
ptr21 = ptr_n2;
ptr22 = ptr_p2;
flag = 0;
}
ibuf = 0;
for( j = 0; j < i; j++ )
{
flag_n = 0;
if( ptr11[j] != NULL )
{
r11 = ptr11[j]->r1;
r12 = ptr11[j]->r2;
flag_n = 1;
w1 = ptr11[j]->area / area1;
s1 = ptr11[j]->sign;
}
else
{
r11 = r21 = 0;
}
if( ptr21[j] != NULL )
{
r21 = ptr21[j]->r1;
r22 = ptr21[j]->r2;
flag_n = 1;
w2 = ptr21[j]->area / area2;
s2 = ptr21[j]->sign;
}
else
{
r21 = r22 = 0;
}
if( flag_n != 0 )
/* calculate node distance */
{
switch (method)
{
case 1:
{
double t0, t1;
if( s1 != s2 )
{
t0 = fabs( r11 * w1 + r21 * w2 );
t1 = fabs( r12 * w1 + r22 * w2 );
}
else
{
t0 = fabs( r11 * w1 - r21 * w2 );
t1 = fabs( r12 * w1 - r22 * w2 );
}
d12 = t0 + t1;
break;
}
}
match_v += d12;
ibuf1 = ibuf + 1;
/*write to buffer the pointer to child vertexes*/
if( ptr11[j] != NULL )
{
ptr12[ibuf] = ptr11[j]->next_v1;
ptr12[ibuf1] = ptr11[j]->next_v2;
}
else
{
ptr12[ibuf] = NULL;
ptr12[ibuf1] = NULL;
}
if( ptr21[j] != NULL )
{
ptr22[ibuf] = ptr21[j]->next_v1;
ptr22[ibuf1] = ptr21[j]->next_v2;
}
else
{
ptr22[ibuf] = NULL;
ptr22[ibuf1] = NULL;
}
ibuf += 2;
}
}
i = ibuf;
}
while( i > 0 && match_v < threshold );
result = match_v;
__END__;
cvFree( &ptr_n2 );
cvFree( &ptr_n1 );
cvFree( &ptr_p2 );
cvFree( &ptr_p1 );
return result;
}
/* End of file. */

View File

@@ -0,0 +1,687 @@
/*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*/
#include "_cv.h"
/* The function calculates center of gravity and central second order moments */
static void
icvCompleteMomentState( CvMoments* moments )
{
double cx = 0, cy = 0;
double mu20, mu11, mu02;
assert( moments != 0 );
moments->inv_sqrt_m00 = 0;
if( fabs(moments->m00) > DBL_EPSILON )
{
double inv_m00 = 1. / moments->m00;
cx = moments->m10 * inv_m00;
cy = moments->m01 * inv_m00;
moments->inv_sqrt_m00 = sqrt( fabs(inv_m00) );
}
/* mu20 = m20 - m10*cx */
mu20 = moments->m20 - moments->m10 * cx;
/* mu11 = m11 - m10*cy */
mu11 = moments->m11 - moments->m10 * cy;
/* mu02 = m02 - m01*cy */
mu02 = moments->m02 - moments->m01 * cy;
moments->mu20 = mu20;
moments->mu11 = mu11;
moments->mu02 = mu02;
/* mu30 = m30 - cx*(3*mu20 + cx*m10) */
moments->mu30 = moments->m30 - cx * (3 * mu20 + cx * moments->m10);
mu11 += mu11;
/* mu21 = m21 - cx*(2*mu11 + cx*m01) - cy*mu20 */
moments->mu21 = moments->m21 - cx * (mu11 + cx * moments->m01) - cy * mu20;
/* mu12 = m12 - cy*(2*mu11 + cy*m10) - cx*mu02 */
moments->mu12 = moments->m12 - cy * (mu11 + cy * moments->m10) - cx * mu02;
/* mu03 = m03 - cy*(3*mu02 + cy*m01) */
moments->mu03 = moments->m03 - cy * (3 * mu02 + cy * moments->m01);
}
static void
icvContourMoments( CvSeq* contour, CvMoments* moments )
{
int is_float = CV_SEQ_ELTYPE(contour) == CV_32FC2;
if( contour->total )
{
CvSeqReader reader;
double a00, a10, a01, a20, a11, a02, a30, a21, a12, a03;
double xi, yi, xi2, yi2, xi_1, yi_1, xi_12, yi_12, dxy, xii_1, yii_1;
int lpt = contour->total;
a00 = a10 = a01 = a20 = a11 = a02 = a30 = a21 = a12 = a03 = 0;
cvStartReadSeq( contour, &reader, 0 );
if( !is_float )
{
xi_1 = ((CvPoint*)(reader.ptr))->x;
yi_1 = ((CvPoint*)(reader.ptr))->y;
}
else
{
xi_1 = ((CvPoint2D32f*)(reader.ptr))->x;
yi_1 = ((CvPoint2D32f*)(reader.ptr))->y;
}
CV_NEXT_SEQ_ELEM( contour->elem_size, reader );
xi_12 = xi_1 * xi_1;
yi_12 = yi_1 * yi_1;
while( lpt-- > 0 )
{
if( !is_float )
{
xi = ((CvPoint*)(reader.ptr))->x;
yi = ((CvPoint*)(reader.ptr))->y;
}
else
{
xi = ((CvPoint2D32f*)(reader.ptr))->x;
yi = ((CvPoint2D32f*)(reader.ptr))->y;
}
CV_NEXT_SEQ_ELEM( contour->elem_size, reader );
xi2 = xi * xi;
yi2 = yi * yi;
dxy = xi_1 * yi - xi * yi_1;
xii_1 = xi_1 + xi;
yii_1 = yi_1 + yi;
a00 += dxy;
a10 += dxy * xii_1;
a01 += dxy * yii_1;
a20 += dxy * (xi_1 * xii_1 + xi2);
a11 += dxy * (xi_1 * (yii_1 + yi_1) + xi * (yii_1 + yi));
a02 += dxy * (yi_1 * yii_1 + yi2);
a30 += dxy * xii_1 * (xi_12 + xi2);
a03 += dxy * yii_1 * (yi_12 + yi2);
a21 +=
dxy * (xi_12 * (3 * yi_1 + yi) + 2 * xi * xi_1 * yii_1 +
xi2 * (yi_1 + 3 * yi));
a12 +=
dxy * (yi_12 * (3 * xi_1 + xi) + 2 * yi * yi_1 * xii_1 +
yi2 * (xi_1 + 3 * xi));
xi_1 = xi;
yi_1 = yi;
xi_12 = xi2;
yi_12 = yi2;
}
double db1_2, db1_6, db1_12, db1_24, db1_20, db1_60;
if( fabs(a00) > FLT_EPSILON )
{
if( a00 > 0 )
{
db1_2 = 0.5;
db1_6 = 0.16666666666666666666666666666667;
db1_12 = 0.083333333333333333333333333333333;
db1_24 = 0.041666666666666666666666666666667;
db1_20 = 0.05;
db1_60 = 0.016666666666666666666666666666667;
}
else
{
db1_2 = -0.5;
db1_6 = -0.16666666666666666666666666666667;
db1_12 = -0.083333333333333333333333333333333;
db1_24 = -0.041666666666666666666666666666667;
db1_20 = -0.05;
db1_60 = -0.016666666666666666666666666666667;
}
/* spatial moments */
moments->m00 = a00 * db1_2;
moments->m10 = a10 * db1_6;
moments->m01 = a01 * db1_6;
moments->m20 = a20 * db1_12;
moments->m11 = a11 * db1_24;
moments->m02 = a02 * db1_12;
moments->m30 = a30 * db1_20;
moments->m21 = a21 * db1_60;
moments->m12 = a12 * db1_60;
moments->m03 = a03 * db1_20;
icvCompleteMomentState( moments );
}
}
}
/* summarizes moment values for all tiles */
static void
icvAccumulateMoments( double *tiles, CvSize size, CvSize tile_size, CvMoments * moments )
{
int x, y;
for( y = 0; y < size.height; y += tile_size.height )
{
for( x = 0; x < size.width; x += tile_size.width, tiles += 10 )
{
double dx = x, dy = y;
double dxm = dx * tiles[0], dym = dy * tiles[0];
/* + m00 ( = m00' ) */
moments->m00 += tiles[0];
/* + m10 ( = m10' + dx*m00' ) */
moments->m10 += tiles[1] + dxm;
/* + m01 ( = m01' + dy*m00' ) */
moments->m01 += tiles[2] + dym;
/* + m20 ( = m20' + 2*dx*m10' + dx*dx*m00' ) */
moments->m20 += tiles[3] + dx * (tiles[1] * 2 + dxm);
/* + m11 ( = m11' + dx*m01' + dy*m10' + dx*dy*m00' ) */
moments->m11 += tiles[4] + dx * (tiles[2] + dym) + dy * tiles[1];
/* + m02 ( = m02' + 2*dy*m01' + dy*dy*m00' ) */
moments->m02 += tiles[5] + dy * (tiles[2] * 2 + dym);
/* + m30 ( = m30' + 3*dx*m20' + 3*dx*dx*m10' + dx*dx*dx*m00' ) */
moments->m30 += tiles[6] + dx * (3. * tiles[3] + dx * (3. * tiles[1] + dxm));
/* + m21 (= m21' + dx*(2*m11' + 2*dy*m10' + dx*m01' + dx*dy*m00') + dy*m20') */
moments->m21 += tiles[7] + dx * (2 * (tiles[4] + dy * tiles[1]) +
dx * (tiles[2] + dym)) + dy * tiles[3];
/* + m12 (= m12' + dy*(2*m11' + 2*dx*m01' + dy*m10' + dx*dy*m00') + dx*m02') */
moments->m12 += tiles[8] + dy * (2 * (tiles[4] + dx * tiles[2]) +
dy * (tiles[1] + dxm)) + dx * tiles[5];
/* + m03 ( = m03' + 3*dy*m02' + 3*dy*dy*m01' + dy*dy*dy*m00' ) */
moments->m03 += tiles[9] + dy * (3. * tiles[5] + dy * (3. * tiles[2] + dym));
}
}
icvCompleteMomentState( moments );
}
/****************************************************************************************\
* Spatial Moments *
\****************************************************************************************/
#define ICV_DEF_CALC_MOMENTS_IN_TILE( __op__, name, flavor, srctype, temptype, momtype ) \
static CvStatus CV_STDCALL icv##name##_##flavor##_CnCR \
( const srctype* img, int step, CvSize size, int cn, int coi, double *moments ) \
{ \
int x, y, sx_init = (size.width & -4) * (size.width & -4), sy = 0; \
momtype mom[10]; \
\
assert( img && size.width && (size.width | size.height) >= 0 ); \
memset( mom, 0, 10 * sizeof( mom[0] )); \
\
if( coi ) \
img += coi - 1; \
step /= sizeof(img[0]); \
\
for( y = 0; y < size.height; sy += 2 * y + 1, y++, img += step ) \
{ \
temptype x0 = 0; \
temptype x1 = 0; \
temptype x2 = 0; \
momtype x3 = 0; \
int sx = sx_init; \
const srctype* ptr = img; \
\
for( x = 0; x < size.width - 3; x += 4, ptr += cn*4 ) \
{ \
temptype p0 = __op__(ptr[0]), p1 = __op__(ptr[cn]), \
p2 = __op__(ptr[2*cn]), p3 = __op__(ptr[3*cn]); \
temptype t = p1; \
temptype a, b, c; \
\
p0 += p1 + p2 + p3; /* p0 + p1 + p2 + p3 */ \
p1 += 2 * p2 + 3 * p3; /* p1 + p2*2 + p3*3 */ \
p2 = p1 + 2 * p2 + 6 * p3; /* p1 + p2*4 + p3*9 */ \
p3 = 2 * p2 - t + 9 * p3; /* p1 + p2*8 + p3*27 */ \
\
a = x * p0 + p1; /* x*p0 + (x+1)*p1 + (x+2)*p2 + (x+3)*p3 */ \
b = x * p1 + p2; /* (x+1)*p1 + 2*(x+2)*p2 + 3*(x+3)*p3 */ \
c = x * p2 + p3; /* (x+1)*p1 + 4*(x+2)*p2 + 9*(x+3)*p3 */ \
\
x0 += p0; \
x1 += a; \
a = a * x + b; /*(x^2)*p0+((x+1)^2)*p1+((x+2)^2)*p2+((x+3)^2)*p3 */ \
x2 += a; \
x3 += ((momtype)(a + b)) * x + c; /*x3 += (x^3)*p0+((x+1)^3)*p1 + */ \
/* ((x+2)^3)*p2+((x+3)^3)*p3 */ \
} \
\
/* process the rest */ \
for( ; x < size.width; sx += 2 * x + 1, x++, ptr += cn ) \
{ \
temptype p = __op__(ptr[0]); \
temptype xp = x * p; \
\
x0 += p; \
x1 += xp; \
x2 += sx * p; \
x3 += ((momtype)sx) * xp; \
} \
\
{ \
temptype py = y * x0; \
\
mom[9] += ((momtype)py) * sy; /* m03 */ \
mom[8] += ((momtype)x1) * sy; /* m12 */ \
mom[7] += ((momtype)x2) * y; /* m21 */ \
mom[6] += x3; /* m30 */ \
mom[5] += x0 * sy; /* m02 */ \
mom[4] += x1 * y; /* m11 */ \
mom[3] += x2; /* m20 */ \
mom[2] += py; /* m01 */ \
mom[1] += x1; /* m10 */ \
mom[0] += x0; /* m00 */ \
} \
} \
\
for( x = 0; x < 10; x++ ) \
moments[x] = (double)mom[x]; \
\
return CV_OK; \
}
ICV_DEF_CALC_MOMENTS_IN_TILE( CV_NOP, MomentsInTile, 8u, uchar, int, int )
ICV_DEF_CALC_MOMENTS_IN_TILE( CV_NOP, MomentsInTile, 16u, ushort, int, int64 )
ICV_DEF_CALC_MOMENTS_IN_TILE( CV_NOP, MomentsInTile, 16s, short, int, int64 )
ICV_DEF_CALC_MOMENTS_IN_TILE( CV_NOP, MomentsInTile, 32f, float, double, double )
ICV_DEF_CALC_MOMENTS_IN_TILE( CV_NOP, MomentsInTile, 64f, double, double, double )
ICV_DEF_CALC_MOMENTS_IN_TILE( CV_NONZERO, MomentsInTileBin, 8u, uchar, int, int )
ICV_DEF_CALC_MOMENTS_IN_TILE( CV_NONZERO, MomentsInTileBin, 16s, ushort, int, int )
ICV_DEF_CALC_MOMENTS_IN_TILE( CV_NONZERO_FLT, MomentsInTileBin, 32f, int, int, int )
ICV_DEF_CALC_MOMENTS_IN_TILE( CV_NONZERO_FLT, MomentsInTileBin, 64f, int64, double, double )
#define icvMomentsInTile_8s_CnCR 0
#define icvMomentsInTile_32s_CnCR 0
#define icvMomentsInTileBin_8s_CnCR icvMomentsInTileBin_8u_CnCR
#define icvMomentsInTileBin_16u_CnCR icvMomentsInTileBin_16s_CnCR
#define icvMomentsInTileBin_32s_CnCR 0
CV_DEF_INIT_FUNC_TAB_2D( MomentsInTile, CnCR )
CV_DEF_INIT_FUNC_TAB_2D( MomentsInTileBin, CnCR )
////////////////////////////////// IPP moment functions //////////////////////////////////
icvMoments_8u_C1R_t icvMoments_8u_C1R_p = 0;
icvMoments_32f_C1R_t icvMoments_32f_C1R_p = 0;
icvMomentInitAlloc_64f_t icvMomentInitAlloc_64f_p = 0;
icvMomentFree_64f_t icvMomentFree_64f_p = 0;
icvGetSpatialMoment_64f_t icvGetSpatialMoment_64f_p = 0;
typedef CvStatus (CV_STDCALL * CvMomentIPPFunc)
( const void* img, int step, CvSize size, void* momentstate );
CV_IMPL void
cvMoments( const void* array, CvMoments* moments, int binary )
{
static CvFuncTable mom_tab;
static CvFuncTable mombin_tab;
static int inittab = 0;
double* tiles = 0;
void* ippmomentstate = 0;
CV_FUNCNAME("cvMoments");
__BEGIN__;
int type = 0, depth, cn, pix_size;
int coi = 0;
int x, y, k, tile_num = 1;
CvSize size, tile_size = { 32, 32 };
CvMat stub, *mat = (CvMat*)array;
CvFunc2DnC_1A1P func = 0;
CvMomentIPPFunc ipp_func = 0;
CvContour contour_header;
CvSeq* contour = 0;
CvSeqBlock block;
if( CV_IS_SEQ( array ))
{
contour = (CvSeq*)array;
if( !CV_IS_SEQ_POLYGON( contour ))
CV_ERROR( CV_StsBadArg, "The passed sequence is not a valid contour" );
}
if( !inittab )
{
icvInitMomentsInTileCnCRTable( &mom_tab );
icvInitMomentsInTileBinCnCRTable( &mombin_tab );
inittab = 1;
}
if( !moments )
CV_ERROR( CV_StsNullPtr, "" );
memset( moments, 0, sizeof(*moments));
if( !contour )
{
CV_CALL( mat = cvGetMat( mat, &stub, &coi ));
type = CV_MAT_TYPE( mat->type );
if( type == CV_32SC2 || type == CV_32FC2 )
{
CV_CALL( contour = cvPointSeqFromMat(
CV_SEQ_KIND_CURVE | CV_SEQ_FLAG_CLOSED,
mat, &contour_header, &block ));
}
}
if( contour )
{
icvContourMoments( contour, moments );
EXIT;
}
type = CV_MAT_TYPE( mat->type );
depth = CV_MAT_DEPTH( type );
cn = CV_MAT_CN( type );
pix_size = CV_ELEM_SIZE(type);
size = cvGetMatSize( mat );
if( cn > 1 && coi == 0 )
CV_ERROR( CV_StsBadArg, "Invalid image type" );
if( size.width <= 0 || size.height <= 0 )
{
EXIT;
}
if( type == CV_8UC1 )
ipp_func = (CvMomentIPPFunc)icvMoments_8u_C1R_p;
else if( type == CV_32FC1 )
ipp_func = (CvMomentIPPFunc)icvMoments_32f_C1R_p;
if( ipp_func && !binary )
{
int matstep = mat->step ? mat->step : CV_STUB_STEP;
IPPI_CALL( icvMomentInitAlloc_64f_p( &ippmomentstate, cvAlgHintAccurate ));
IPPI_CALL( ipp_func( mat->data.ptr, matstep, size, ippmomentstate ));
icvGetSpatialMoment_64f_p( ippmomentstate, 0, 0, 0, cvPoint(0,0), &moments->m00 );
icvGetSpatialMoment_64f_p( ippmomentstate, 1, 0, 0, cvPoint(0,0), &moments->m10 );
icvGetSpatialMoment_64f_p( ippmomentstate, 0, 1, 0, cvPoint(0,0), &moments->m01 );
icvGetSpatialMoment_64f_p( ippmomentstate, 2, 0, 0, cvPoint(0,0), &moments->m20 );
icvGetSpatialMoment_64f_p( ippmomentstate, 1, 1, 0, cvPoint(0,0), &moments->m11 );
icvGetSpatialMoment_64f_p( ippmomentstate, 0, 2, 0, cvPoint(0,0), &moments->m02 );
icvGetSpatialMoment_64f_p( ippmomentstate, 3, 0, 0, cvPoint(0,0), &moments->m30 );
icvGetSpatialMoment_64f_p( ippmomentstate, 2, 1, 0, cvPoint(0,0), &moments->m21 );
icvGetSpatialMoment_64f_p( ippmomentstate, 1, 2, 0, cvPoint(0,0), &moments->m12 );
icvGetSpatialMoment_64f_p( ippmomentstate, 0, 3, 0, cvPoint(0,0), &moments->m03 );
icvCompleteMomentState( moments );
EXIT;
}
func = (CvFunc2DnC_1A1P)(!binary ? mom_tab.fn_2d[depth] : mombin_tab.fn_2d[depth]);
if( !func )
CV_ERROR( CV_StsBadArg, cvUnsupportedFormat );
if( depth >= CV_32S && !binary )
tile_size = size;
else
tile_num = ((size.width + tile_size.width - 1)/tile_size.width)*
((size.height + tile_size.height - 1)/tile_size.height);
CV_CALL( tiles = (double*)cvAlloc( tile_num*10*sizeof(double)));
for( y = 0, k = 0; y < size.height; y += tile_size.height )
{
CvSize cur_tile_size = tile_size;
if( y + cur_tile_size.height > size.height )
cur_tile_size.height = size.height - y;
for( x = 0; x < size.width; x += tile_size.width, k++ )
{
if( x + cur_tile_size.width > size.width )
cur_tile_size.width = size.width - x;
assert( k < tile_num );
IPPI_CALL( func( mat->data.ptr + y*mat->step + x*pix_size,
mat->step, cur_tile_size, cn, coi, tiles + k*10 ));
}
}
icvAccumulateMoments( tiles, size, tile_size, moments );
__END__;
if( ippmomentstate )
icvMomentFree_64f_p( ippmomentstate );
cvFree( &tiles );
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvGetHuMoments
// Purpose: Returns Hu moments
// Context:
// Parameters:
// mState - moment structure filled by one of the icvMoments[Binary]*** function
// HuState - pointer to output structure containing seven Hu moments
// Returns:
// CV_NO_ERR if success or error code
// Notes:
//F*/
CV_IMPL void
cvGetHuMoments( CvMoments * mState, CvHuMoments * HuState )
{
CV_FUNCNAME( "cvGetHuMoments" );
__BEGIN__;
if( !mState || !HuState )
CV_ERROR_FROM_STATUS( CV_NULLPTR_ERR );
{
double m00s = mState->inv_sqrt_m00, m00 = m00s * m00s, s2 = m00 * m00, s3 = s2 * m00s;
double nu20 = mState->mu20 * s2,
nu11 = mState->mu11 * s2,
nu02 = mState->mu02 * s2,
nu30 = mState->mu30 * s3,
nu21 = mState->mu21 * s3, nu12 = mState->mu12 * s3, nu03 = mState->mu03 * s3;
double t0 = nu30 + nu12;
double t1 = nu21 + nu03;
double q0 = t0 * t0, q1 = t1 * t1;
double n4 = 4 * nu11;
double s = nu20 + nu02;
double d = nu20 - nu02;
HuState->hu1 = s;
HuState->hu2 = d * d + n4 * nu11;
HuState->hu4 = q0 + q1;
HuState->hu6 = d * (q0 - q1) + n4 * t0 * t1;
t0 *= q0 - 3 * q1;
t1 *= 3 * q0 - q1;
q0 = nu30 - 3 * nu12;
q1 = 3 * nu21 - nu03;
HuState->hu3 = q0 * q0 + q1 * q1;
HuState->hu5 = q0 * t0 + q1 * t1;
HuState->hu7 = q1 * t0 - q0 * t1;
}
__END__;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvGetSpatialMoment
// Purpose: Returns spatial moment(x_order, y_order) which is determined as:
// m(x_o,y_o) = sum (x ^ x_o)*(y ^ y_o)*I(x,y)
// 0 <= x_o, y_o; x_o + y_o <= 3
// Context:
// Parameters:
// mom - moment structure filled by one of the icvMoments[Binary]*** function
// x_order - x order of the moment
// y_order - y order of the moment
// Returns:
// moment value or large negative number (-DBL_MAX) if error
// Notes:
//F*/
CV_IMPL double
cvGetSpatialMoment( CvMoments * moments, int x_order, int y_order )
{
int order = x_order + y_order;
double moment = -DBL_MAX;
CV_FUNCNAME( "cvGetSpatialMoment" );
__BEGIN__;
if( !moments )
CV_ERROR_FROM_STATUS( CV_NULLPTR_ERR );
if( (x_order | y_order) < 0 || order > 3 )
CV_ERROR_FROM_STATUS( CV_BADRANGE_ERR );
moment = (&(moments->m00))[order + (order >> 1) + (order > 2) * 2 + y_order];
__END__;
return moment;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvGetCentralMoment
// Purpose: Returns central moment(x_order, y_order) which is determined as:
// mu(x_o,y_o) = sum ((x - xc)^ x_o)*((y - yc) ^ y_o)*I(x,y)
// 0 <= x_o, y_o; x_o + y_o <= 3,
// (xc, yc) = (m10/m00,m01/m00) - center of gravity
// Context:
// Parameters:
// mom - moment structure filled by one of the icvMoments[Binary]*** function
// x_order - x order of the moment
// y_order - y order of the moment
// Returns:
// moment value or large negative number (-DBL_MAX) if error
// Notes:
//F*/
CV_IMPL double
cvGetCentralMoment( CvMoments * moments, int x_order, int y_order )
{
int order = x_order + y_order;
double mu = 0;
CV_FUNCNAME( "cvGetCentralMoment" );
__BEGIN__;
if( !moments )
CV_ERROR_FROM_STATUS( CV_NULLPTR_ERR );
if( (x_order | y_order) < 0 || order > 3 )
CV_ERROR_FROM_STATUS( CV_BADRANGE_ERR );
if( order >= 2 )
{
mu = (&(moments->m00))[4 + order * 3 + y_order];
}
else if( order == 0 )
mu = moments->m00;
__END__;
return mu;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvGetNormalizedCentralMoment
// Purpose: Returns normalized central moment(x_order,y_order) which is determined as:
// nu(x_o,y_o) = mu(x_o, y_o)/(m00 ^ (((x_o + y_o)/2) + 1))
// 0 <= x_o, y_o; x_o + y_o <= 3,
// (xc, yc) = (m10/m00,m01/m00) - center of gravity
// Context:
// Parameters:
// mom - moment structure filled by one of the icvMoments[Binary]*** function
// x_order - x order of the moment
// y_order - y order of the moment
// Returns:
// moment value or large negative number (-DBL_MAX) if error
// Notes:
//F*/
CV_IMPL double
cvGetNormalizedCentralMoment( CvMoments * moments, int x_order, int y_order )
{
int order = x_order + y_order;
double mu = 0;
double m00s, m00;
CV_FUNCNAME( "cvGetCentralNormalizedMoment" );
__BEGIN__;
mu = cvGetCentralMoment( moments, x_order, y_order );
CV_CHECK();
m00s = moments->inv_sqrt_m00;
m00 = m00s * m00s;
while( --order >= 0 )
m00 *= m00s;
mu *= m00;
__END__;
return mu;
}
/* End of file. */

View File

@@ -0,0 +1,517 @@
/*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*/
#include "_cv.h"
IPCVAPI_IMPL( CvStatus, icvUpdateMotionHistory_8u32f_C1IR,
(const uchar * silIm, int silStep, float *mhiIm, int mhiStep,
CvSize size, float timestamp, float mhi_duration),
(silIm, silStep, mhiIm, mhiStep, size, timestamp, mhi_duration) )
{
int x, y;
/* function processes floating-point images using integer arithmetics */
Cv32suf v;
int ts, delbound;
int *mhi = (int *) mhiIm;
v.f = timestamp;
ts = v.i;
if( !silIm || !mhiIm )
return CV_NULLPTR_ERR;
if( size.height <= 0 || size.width <= 0 ||
silStep < size.width || mhiStep < size.width * CV_SIZEOF_FLOAT ||
(mhiStep & (CV_SIZEOF_FLOAT - 1)) != 0 )
return CV_BADSIZE_ERR;
if( mhi_duration < 0 )
return CV_BADFACTOR_ERR;
mhi_duration = timestamp - mhi_duration;
v.f = mhi_duration;
delbound = CV_TOGGLE_FLT( v.i );
mhiStep /= sizeof(mhi[0]);
if( mhiStep == size.width && silStep == size.width )
{
size.width *= size.height;
size.height = 1;
}
if( delbound > 0 )
for( y = 0; y < size.height; y++, silIm += silStep, mhi += mhiStep )
for( x = 0; x < size.width; x++ )
{
int val = mhi[x];
/* val = silIm[x] ? ts : val < delbound ? 0 : val; */
val &= (val < delbound) - 1;
val ^= (ts ^ val) & ((silIm[x] == 0) - 1);
mhi[x] = val;
}
else
for( y = 0; y < size.height; y++, silIm += silStep, mhi += mhiStep )
for( x = 0; x < size.width; x++ )
{
int val = mhi[x];
/* val = silIm[x] ? ts : val < delbound ? 0 : val; */
val &= (CV_TOGGLE_FLT( val ) < delbound) - 1;
val ^= (ts ^ val) & ((silIm[x] == 0) - 1);
mhi[x] = val;
}
return CV_OK;
}
/* motion templates */
CV_IMPL void
cvUpdateMotionHistory( const void* silhouette, void* mhimg,
double timestamp, double mhi_duration )
{
CvSize size;
CvMat silhstub, *silh = (CvMat*)silhouette;
CvMat mhistub, *mhi = (CvMat*)mhimg;
int mhi_step, silh_step;
CV_FUNCNAME( "cvUpdateMHIByTime" );
__BEGIN__;
CV_CALL( silh = cvGetMat( silh, &silhstub ));
CV_CALL( mhi = cvGetMat( mhi, &mhistub ));
if( !CV_IS_MASK_ARR( silh ))
CV_ERROR( CV_StsBadMask, "" );
if( CV_MAT_CN( mhi->type ) > 1 )
CV_ERROR( CV_BadNumChannels, "" );
if( CV_MAT_DEPTH( mhi->type ) != CV_32F )
CV_ERROR( CV_BadDepth, "" );
if( !CV_ARE_SIZES_EQ( mhi, silh ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
size = cvGetMatSize( mhi );
mhi_step = mhi->step;
silh_step = silh->step;
if( CV_IS_MAT_CONT( mhi->type & silh->type ))
{
size.width *= size.height;
mhi_step = silh_step = CV_STUB_STEP;
size.height = 1;
}
IPPI_CALL( icvUpdateMotionHistory_8u32f_C1IR( (const uchar*)(silh->data.ptr), silh_step,
mhi->data.fl, mhi_step, size,
(float)timestamp, (float)mhi_duration ));
__END__;
}
CV_IMPL void
cvCalcMotionGradient( const CvArr* mhiimg, CvArr* maskimg,
CvArr* orientation,
double delta1, double delta2,
int aperture_size )
{
CvMat *dX_min = 0, *dY_max = 0;
IplConvKernel* el = 0;
CV_FUNCNAME( "cvCalcMotionGradient" );
__BEGIN__;
CvMat mhistub, *mhi = (CvMat*)mhiimg;
CvMat maskstub, *mask = (CvMat*)maskimg;
CvMat orientstub, *orient = (CvMat*)orientation;
CvMat dX_min_row, dY_max_row, orient_row, mask_row;
CvSize size;
int x, y;
float gradient_epsilon = 1e-4f * aperture_size * aperture_size;
float min_delta, max_delta;
CV_CALL( mhi = cvGetMat( mhi, &mhistub ));
CV_CALL( mask = cvGetMat( mask, &maskstub ));
CV_CALL( orient = cvGetMat( orient, &orientstub ));
if( !CV_IS_MASK_ARR( mask ))
CV_ERROR( CV_StsBadMask, "" );
if( aperture_size < 3 || aperture_size > 7 || (aperture_size & 1) == 0 )
CV_ERROR( CV_StsOutOfRange, "aperture_size must be 3, 5 or 7" );
if( delta1 <= 0 || delta2 <= 0 )
CV_ERROR( CV_StsOutOfRange, "both delta's must be positive" );
if( CV_MAT_TYPE( mhi->type ) != CV_32FC1 || CV_MAT_TYPE( orient->type ) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat,
"MHI and orientation must be single-channel floating-point images" );
if( !CV_ARE_SIZES_EQ( mhi, mask ) || !CV_ARE_SIZES_EQ( orient, mhi ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( orient->data.ptr == mhi->data.ptr )
CV_ERROR( CV_StsInplaceNotSupported, "orientation image must be different from MHI" );
if( delta1 > delta2 )
{
double t;
CV_SWAP( delta1, delta2, t );
}
size = cvGetMatSize( mhi );
min_delta = (float)delta1;
max_delta = (float)delta2;
CV_CALL( dX_min = cvCreateMat( mhi->rows, mhi->cols, CV_32F ));
CV_CALL( dY_max = cvCreateMat( mhi->rows, mhi->cols, CV_32F ));
/* calc Dx and Dy */
CV_CALL( cvSobel( mhi, dX_min, 1, 0, aperture_size ));
CV_CALL( cvSobel( mhi, dY_max, 0, 1, aperture_size ));
cvGetRow( dX_min, &dX_min_row, 0 );
cvGetRow( dY_max, &dY_max_row, 0 );
cvGetRow( orient, &orient_row, 0 );
cvGetRow( mask, &mask_row, 0 );
/* calc gradient */
for( y = 0; y < size.height; y++ )
{
dX_min_row.data.ptr = dX_min->data.ptr + y*dX_min->step;
dY_max_row.data.ptr = dY_max->data.ptr + y*dY_max->step;
orient_row.data.ptr = orient->data.ptr + y*orient->step;
mask_row.data.ptr = mask->data.ptr + y*mask->step;
cvCartToPolar( &dX_min_row, &dY_max_row, 0, &orient_row, 1 );
/* make orientation zero where the gradient is very small */
for( x = 0; x < size.width; x++ )
{
float dY = dY_max_row.data.fl[x];
float dX = dX_min_row.data.fl[x];
if( fabs(dX) < gradient_epsilon && fabs(dY) < gradient_epsilon )
{
mask_row.data.ptr[x] = 0;
orient_row.data.i[x] = 0;
}
else
mask_row.data.ptr[x] = 1;
}
}
CV_CALL( el = cvCreateStructuringElementEx( aperture_size, aperture_size,
aperture_size/2, aperture_size/2, CV_SHAPE_RECT ));
cvErode( mhi, dX_min, el );
cvDilate( mhi, dY_max, el );
/* mask off pixels which have little motion difference in their neighborhood */
for( y = 0; y < size.height; y++ )
{
dX_min_row.data.ptr = dX_min->data.ptr + y*dX_min->step;
dY_max_row.data.ptr = dY_max->data.ptr + y*dY_max->step;
mask_row.data.ptr = mask->data.ptr + y*mask->step;
orient_row.data.ptr = orient->data.ptr + y*orient->step;
for( x = 0; x < size.width; x++ )
{
float d0 = dY_max_row.data.fl[x] - dX_min_row.data.fl[x];
if( mask_row.data.ptr[x] == 0 || d0 < min_delta || max_delta < d0 )
{
mask_row.data.ptr[x] = 0;
orient_row.data.i[x] = 0;
}
}
}
__END__;
cvReleaseMat( &dX_min );
cvReleaseMat( &dY_max );
cvReleaseStructuringElement( &el );
}
CV_IMPL double
cvCalcGlobalOrientation( const void* orientation, const void* maskimg, const void* mhiimg,
double curr_mhi_timestamp, double mhi_duration )
{
double angle = 0;
int hist_size = 12;
CvHistogram* hist = 0;
CV_FUNCNAME( "cvCalcGlobalOrientation" );
__BEGIN__;
CvMat mhistub, *mhi = (CvMat*)mhiimg;
CvMat maskstub, *mask = (CvMat*)maskimg;
CvMat orientstub, *orient = (CvMat*)orientation;
void* _orient;
float _ranges[] = { 0, 360 };
float* ranges = _ranges;
int base_orient;
double shift_orient = 0, shift_weight = 0, fbase_orient;
double a, b;
float delbound;
CvMat mhi_row, mask_row, orient_row;
int x, y, mhi_rows, mhi_cols;
CV_CALL( mhi = cvGetMat( mhi, &mhistub ));
CV_CALL( mask = cvGetMat( mask, &maskstub ));
CV_CALL( orient = cvGetMat( orient, &orientstub ));
if( !CV_IS_MASK_ARR( mask ))
CV_ERROR( CV_StsBadMask, "" );
if( CV_MAT_TYPE( mhi->type ) != CV_32FC1 || CV_MAT_TYPE( orient->type ) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat,
"MHI and orientation must be single-channel floating-point images" );
if( !CV_ARE_SIZES_EQ( mhi, mask ) || !CV_ARE_SIZES_EQ( orient, mhi ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( mhi_duration <= 0 )
CV_ERROR( CV_StsOutOfRange, "MHI duration must be positive" );
if( orient->data.ptr == mhi->data.ptr )
CV_ERROR( CV_StsInplaceNotSupported, "orientation image must be different from MHI" );
// calculate histogram of different orientation values
CV_CALL( hist = cvCreateHist( 1, &hist_size, CV_HIST_ARRAY, &ranges ));
_orient = orient;
cvCalcArrHist( &_orient, hist, 0, mask );
// find the maximum index (the dominant orientation)
cvGetMinMaxHistValue( hist, 0, 0, 0, &base_orient );
base_orient *= 360/hist_size;
// override timestamp with the maximum value in MHI
cvMinMaxLoc( mhi, 0, &curr_mhi_timestamp, 0, 0, mask );
// find the shift relative to the dominant orientation as weighted sum of relative angles
a = 254. / 255. / mhi_duration;
b = 1. - curr_mhi_timestamp * a;
fbase_orient = base_orient;
delbound = (float)(curr_mhi_timestamp - mhi_duration);
mhi_rows = mhi->rows;
mhi_cols = mhi->cols;
if( CV_IS_MAT_CONT( mhi->type & mask->type & orient->type ))
{
mhi_cols *= mhi_rows;
mhi_rows = 1;
}
cvGetRow( mhi, &mhi_row, 0 );
cvGetRow( mask, &mask_row, 0 );
cvGetRow( orient, &orient_row, 0 );
/*
a = 254/(255*dt)
b = 1 - t*a = 1 - 254*t/(255*dur) =
(255*dt - 254*t)/(255*dt) =
(dt - (t - dt)*254)/(255*dt);
--------------------------------------------------------
ax + b = 254*x/(255*dt) + (dt - (t - dt)*254)/(255*dt) =
(254*x + dt - (t - dt)*254)/(255*dt) =
((x - (t - dt))*254 + dt)/(255*dt) =
(((x - (t - dt))/dt)*254 + 1)/255 = (((x - low_time)/dt)*254 + 1)/255
*/
for( y = 0; y < mhi_rows; y++ )
{
mhi_row.data.ptr = mhi->data.ptr + mhi->step*y;
mask_row.data.ptr = mask->data.ptr + mask->step*y;
orient_row.data.ptr = orient->data.ptr + orient->step*y;
for( x = 0; x < mhi_cols; x++ )
if( mask_row.data.ptr[x] != 0 && mhi_row.data.fl[x] > delbound )
{
/*
orient in 0..360, base_orient in 0..360
-> (rel_angle = orient - base_orient) in -360..360.
rel_angle is translated to -180..180
*/
double weight = mhi_row.data.fl[x] * a + b;
int rel_angle = cvRound( orient_row.data.fl[x] - fbase_orient );
rel_angle += (rel_angle < -180 ? 360 : 0);
rel_angle += (rel_angle > 180 ? -360 : 0);
if( abs(rel_angle) < 90 )
{
shift_orient += weight * rel_angle;
shift_weight += weight;
}
}
}
// add the dominant orientation and the relative shift
if( shift_weight == 0 )
shift_weight = 0.01;
base_orient = base_orient + cvRound( shift_orient / shift_weight );
base_orient -= (base_orient < 360 ? 0 : 360);
base_orient += (base_orient >= 0 ? 0 : 360);
angle = base_orient;
__END__;
cvReleaseHist( &hist );
return angle;
}
CV_IMPL CvSeq*
cvSegmentMotion( const CvArr* mhiimg, CvArr* segmask, CvMemStorage* storage,
double timestamp, double seg_thresh )
{
CvSeq* components = 0;
CvMat* mask8u = 0;
CV_FUNCNAME( "cvSegmentMotion" );
__BEGIN__;
CvMat mhistub, *mhi = (CvMat*)mhiimg;
CvMat maskstub, *mask = (CvMat*)segmask;
Cv32suf v, comp_idx;
int stub_val, ts;
int x, y;
if( !storage )
CV_ERROR( CV_StsNullPtr, "NULL memory storage" );
CV_CALL( mhi = cvGetMat( mhi, &mhistub ));
CV_CALL( mask = cvGetMat( mask, &maskstub ));
if( CV_MAT_TYPE( mhi->type ) != CV_32FC1 || CV_MAT_TYPE( mask->type ) != CV_32FC1 )
CV_ERROR( CV_BadDepth, "Both MHI and the destination mask" );
if( !CV_ARE_SIZES_EQ( mhi, mask ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
CV_CALL( mask8u = cvCreateMat( mhi->rows + 2, mhi->cols + 2, CV_8UC1 ));
cvZero( mask8u );
cvZero( mask );
CV_CALL( components = cvCreateSeq( CV_SEQ_KIND_GENERIC, sizeof(CvSeq),
sizeof(CvConnectedComp), storage ));
v.f = (float)timestamp; ts = v.i;
v.f = FLT_MAX*0.1f; stub_val = v.i;
comp_idx.f = 1;
for( y = 0; y < mhi->rows; y++ )
{
int* mhi_row = (int*)(mhi->data.ptr + y*mhi->step);
for( x = 0; x < mhi->cols; x++ )
{
if( mhi_row[x] == 0 )
mhi_row[x] = stub_val;
}
}
for( y = 0; y < mhi->rows; y++ )
{
int* mhi_row = (int*)(mhi->data.ptr + y*mhi->step);
uchar* mask8u_row = mask8u->data.ptr + (y+1)*mask8u->step + 1;
for( x = 0; x < mhi->cols; x++ )
{
if( mhi_row[x] == ts && mask8u_row[x] == 0 )
{
CvConnectedComp comp;
int x1, y1;
CvScalar _seg_thresh = cvRealScalar(seg_thresh);
CvPoint seed = cvPoint(x,y);
CV_CALL( cvFloodFill( mhi, seed, cvRealScalar(0), _seg_thresh, _seg_thresh,
&comp, CV_FLOODFILL_MASK_ONLY + 2*256 + 4, mask8u ));
for( y1 = 0; y1 < comp.rect.height; y1++ )
{
int* mask_row1 = (int*)(mask->data.ptr +
(comp.rect.y + y1)*mask->step) + comp.rect.x;
uchar* mask8u_row1 = mask8u->data.ptr +
(comp.rect.y + y1+1)*mask8u->step + comp.rect.x+1;
for( x1 = 0; x1 < comp.rect.width; x1++ )
{
if( mask8u_row1[x1] > 1 )
{
mask8u_row1[x1] = 1;
mask_row1[x1] = comp_idx.i;
}
}
}
comp_idx.f++;
cvSeqPush( components, &comp );
}
}
}
for( y = 0; y < mhi->rows; y++ )
{
int* mhi_row = (int*)(mhi->data.ptr + y*mhi->step);
for( x = 0; x < mhi->cols; x++ )
{
if( mhi_row[x] == stub_val )
mhi_row[x] = 0;
}
}
__END__;
cvReleaseMat( &mask8u );
return components;
}
/* End of file. */

View File

@@ -0,0 +1,610 @@
/*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*/
#include "_cv.h"
/*
Finds L1 norm between two blocks.
*/
static int
icvCmpBlocksL1_8u_C1( const uchar * vec1, const uchar * vec2, int len )
{
int i, sum = 0;
for( i = 0; i <= len - 4; i += 4 )
{
int t0 = abs(vec1[i] - vec2[i]);
int t1 = abs(vec1[i + 1] - vec2[i + 1]);
int t2 = abs(vec1[i + 2] - vec2[i + 2]);
int t3 = abs(vec1[i + 3] - vec2[i + 3]);
sum += t0 + t1 + t2 + t3;
}
for( ; i < len; i++ )
{
int t0 = abs(vec1[i] - vec2[i]);
sum += t0;
}
return sum;
}
static void
icvCopyBM_8u_C1R( const uchar* src, int src_step,
uchar* dst, int dst_step, CvSize size )
{
for( ; size.height--; src += src_step, dst += dst_step )
memcpy( dst, src, size.width );
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvCalcOpticalFlowBM_8u32fR
// Purpose: calculate Optical flow for 2 images using block matching algorithm
// Context:
// Parameters:
// imgA, // pointer to first frame ROI
// imgB, // pointer to second frame ROI
// imgStep, // full width of input images in bytes
// imgSize, // size of the image
// blockSize, // size of basic blocks which are compared
// shiftSize, // coordinates increments.
// maxRange, // size of the scanned neighborhood.
// usePrevious, // flag of using previous velocity field
// velocityX, // pointer to ROI of horizontal and
// velocityY, // vertical components of optical flow
// velStep); // full width of velocity frames in bytes
// Returns: CV_OK or error code
// Notes:
//F*/
#define SMALL_DIFF 2
#define BIG_DIFF 128
static CvStatus CV_STDCALL
icvCalcOpticalFlowBM_8u32fR( uchar * imgA, uchar * imgB,
int imgStep, CvSize imgSize,
CvSize blockSize, CvSize shiftSize,
CvSize maxRange, int usePrev,
float *velocityX, float *velocityY,
int velStep )
{
const float back = 1.f / (float) (1 << 16);
/* scanning scheme coordinates */
CvPoint *ss = 0;
int ss_count = 0;
int stand_accept_level = blockSize.height * blockSize.width * SMALL_DIFF;
int stand_escape_level = blockSize.height * blockSize.width * BIG_DIFF;
int i, j;
int *int_velocityX = (int *) velocityX;
int *int_velocityY = (int *) velocityY;
/* if image sizes can't be divided by block sizes then right blocks will */
/* have not full width - BorderWidth */
/* and bottom blocks will */
/* have not full height - BorderHeight */
int BorderWidth;
int BorderHeight;
int CurrentWidth;
int CurrentHeight;
int NumberBlocksX;
int NumberBlocksY;
int Y1 = 0;
int X1 = 0;
int DownStep = blockSize.height * imgStep;
uchar *blockA = 0;
uchar *blockB = 0;
uchar *blockZ = 0;
int blSize = blockSize.width * blockSize.height;
int bufferSize = cvAlign(blSize + 9,16);
int cmpSize = cvAlign(blSize,4);
int patch_ofs = blSize & -8;
int64 patch_mask = (((int64) 1) << (blSize - patch_ofs * 8)) - 1;
velStep /= sizeof(velocityX[0]);
if( patch_ofs == blSize )
patch_mask = (int64) - 1;
/****************************************************************************************\
* Checking bad arguments *
\****************************************************************************************/
if( imgA == NULL )
return CV_NULLPTR_ERR;
if( imgB == NULL )
return CV_NULLPTR_ERR;
/****************************************************************************************\
* Allocate buffers *
\****************************************************************************************/
blockA = (uchar *) cvAlloc( bufferSize * 3 );
if( !blockA )
return CV_OUTOFMEM_ERR;
blockB = blockA + bufferSize;
blockZ = blockB + bufferSize;
memset( blockZ, 0, bufferSize );
ss = (CvPoint *) cvAlloc( (2 * maxRange.width + 1) * (2 * maxRange.height + 1) *
sizeof( CvPoint ));
if( !ss )
{
cvFree( &blockA );
return CV_OUTOFMEM_ERR;
}
/****************************************************************************************\
* Calculate scanning scheme *
\****************************************************************************************/
{
int X_shift_count = maxRange.width / shiftSize.width;
int Y_shift_count = maxRange.height / shiftSize.height;
int min_count = MIN( X_shift_count, Y_shift_count );
/* cycle by neighborhood rings */
/* scanning scheme is
. 9 10 11 12
. 8 1 2 13
. 7 * 3 14
. 6 5 4 15
20 19 18 17 16
*/
for( i = 0; i < min_count; i++ )
{
/* four cycles along sides */
int y = -(i + 1) * shiftSize.height;
int x = -(i + 1) * shiftSize.width;
/* upper side */
for( j = -i; j <= i + 1; j++, ss_count++ )
{
x += shiftSize.width;
ss[ss_count].x = x;
ss[ss_count].y = y;
}
/* right side */
for( j = -i; j <= i + 1; j++, ss_count++ )
{
y += shiftSize.height;
ss[ss_count].x = x;
ss[ss_count].y = y;
}
/* bottom side */
for( j = -i; j <= i + 1; j++, ss_count++ )
{
x -= shiftSize.width;
ss[ss_count].x = x;
ss[ss_count].y = y;
}
/* left side */
for( j = -i; j <= i + 1; j++, ss_count++ )
{
y -= shiftSize.height;
ss[ss_count].x = x;
ss[ss_count].y = y;
}
}
/* the rest part */
if( X_shift_count < Y_shift_count )
{
int xleft = -min_count * shiftSize.width;
/* cycle by neighbor rings */
for( i = min_count; i < Y_shift_count; i++ )
{
/* two cycles by x */
int y = -(i + 1) * shiftSize.height;
int x = xleft;
/* upper side */
for( j = -X_shift_count; j <= X_shift_count; j++, ss_count++ )
{
ss[ss_count].x = x;
ss[ss_count].y = y;
x += shiftSize.width;
}
x = xleft;
y = -y;
/* bottom side */
for( j = -X_shift_count; j <= X_shift_count; j++, ss_count++ )
{
ss[ss_count].x = x;
ss[ss_count].y = y;
x += shiftSize.width;
}
}
}
else if( X_shift_count > Y_shift_count )
{
int yupper = -min_count * shiftSize.height;
/* cycle by neighbor rings */
for( i = min_count; i < X_shift_count; i++ )
{
/* two cycles by y */
int x = -(i + 1) * shiftSize.width;
int y = yupper;
/* left side */
for( j = -Y_shift_count; j <= Y_shift_count; j++, ss_count++ )
{
ss[ss_count].x = x;
ss[ss_count].y = y;
y += shiftSize.height;
}
y = yupper;
x = -x;
/* right side */
for( j = -Y_shift_count; j <= Y_shift_count; j++, ss_count++ )
{
ss[ss_count].x = x;
ss[ss_count].y = y;
y += shiftSize.height;
}
}
}
}
/****************************************************************************************\
* Calculate some neeeded variables *
\****************************************************************************************/
/* Calculate number of full blocks */
NumberBlocksX = (int) imgSize.width / blockSize.width;
NumberBlocksY = (int) imgSize.height / blockSize.height;
/* add 1 if not full border blocks exist */
BorderWidth = imgSize.width % blockSize.width;
if( BorderWidth )
NumberBlocksX++;
else
BorderWidth = blockSize.width;
BorderHeight = imgSize.height % blockSize.height;
if( BorderHeight )
NumberBlocksY++;
else
BorderHeight = blockSize.height;
/****************************************************************************************\
* Round input velocities integer searching area center position *
\****************************************************************************************/
if( usePrev )
{
float *velxf = velocityX, *velyf = velocityY;
int* velx = (int*)velocityX, *vely = (int*)velocityY;
for( i = 0; i < NumberBlocksY; i++, velxf += velStep, velyf += velStep,
velx += velStep, vely += velStep )
{
for( j = 0; j < NumberBlocksX; j++ )
{
int vx = cvRound( velxf[j] ), vy = cvRound( velyf[j] );
velx[j] = vx; vely[j] = vy;
}
}
}
/****************************************************************************************\
* Main loop *
\****************************************************************************************/
Y1 = 0;
for( i = 0; i < NumberBlocksY; i++ )
{
/* calculate height of current block */
CurrentHeight = (i == NumberBlocksY - 1) ? BorderHeight : blockSize.height;
X1 = 0;
for( j = 0; j < NumberBlocksX; j++ )
{
int accept_level;
int escape_level;
int blDist;
int VelocityX = 0;
int VelocityY = 0;
int offX = 0, offY = 0;
int CountDirection = 1;
int main_flag = i < NumberBlocksY - 1 && j < NumberBlocksX - 1;
CvSize CurSize;
/* calculate width of current block */
CurrentWidth = (j == NumberBlocksX - 1) ? BorderWidth : blockSize.width;
/* compute initial offset */
if( usePrev )
{
offX = int_velocityX[j];
offY = int_velocityY[j];
}
CurSize.width = CurrentWidth;
CurSize.height = CurrentHeight;
if( main_flag )
{
icvCopyBM_8u_C1R( imgA + X1, imgStep, blockA,
CurSize.width, CurSize );
icvCopyBM_8u_C1R( imgB + (Y1 + offY)*imgStep + (X1 + offX),
imgStep, blockB, CurSize.width, CurSize );
*((int64 *) (blockA + patch_ofs)) &= patch_mask;
*((int64 *) (blockB + patch_ofs)) &= patch_mask;
}
else
{
memset( blockA, 0, bufferSize );
memset( blockB, 0, bufferSize );
icvCopyBM_8u_C1R( imgA + X1, imgStep, blockA, blockSize.width, CurSize );
icvCopyBM_8u_C1R( imgB + (Y1 + offY) * imgStep + (X1 + offX), imgStep,
blockB, blockSize.width, CurSize );
}
if( !main_flag )
{
int tmp = CurSize.width * CurSize.height;
accept_level = tmp * SMALL_DIFF;
escape_level = tmp * BIG_DIFF;
}
else
{
accept_level = stand_accept_level;
escape_level = stand_escape_level;
}
blDist = icvCmpBlocksL1_8u_C1( blockA, blockB, cmpSize );
if( blDist > accept_level )
{
int k;
int VelX = 0;
int VelY = 0;
/* walk around basic block */
/* cycle for neighborhood */
for( k = 0; k < ss_count; k++ )
{
int tmpDist;
int Y2 = Y1 + offY + ss[k].y;
int X2 = X1 + offX + ss[k].x;
/* if we break upper border */
if( Y2 < 0 )
{
continue;
}
/* if we break bottom border */
if( Y2 + CurrentHeight >= imgSize.height )
{
continue;
}
/* if we break left border */
if( X2 < 0 )
{
continue;
}
/* if we break right border */
if( X2 + CurrentWidth >= imgSize.width )
{
continue;
}
if( main_flag )
{
icvCopyBM_8u_C1R( imgB + Y2 * imgStep + X2,
imgStep, blockB, CurSize.width, CurSize );
*((int64 *) (blockB + patch_ofs)) &= patch_mask;
}
else
{
memset( blockB, 0, bufferSize );
icvCopyBM_8u_C1R( imgB + Y1 * imgStep + X1, imgStep,
blockB, blockSize.width, CurSize );
}
tmpDist = icvCmpBlocksL1_8u_C1( blockA, blockB, cmpSize );
if( tmpDist < accept_level )
{
VelX = ss[k].x;
VelY = ss[k].y;
break; /*for */
}
else if( tmpDist < blDist )
{
blDist = tmpDist;
VelX = ss[k].x;
VelY = ss[k].y;
CountDirection = 1;
}
else if( tmpDist == blDist )
{
VelX += ss[k].x;
VelY += ss[k].y;
CountDirection++;
}
}
if( blDist > escape_level )
{
VelX = VelY = 0;
CountDirection = 1;
}
if( CountDirection > 1 )
{
int temp = CountDirection == 2 ? 1 << 15 : ((1 << 16) / CountDirection);
VelocityX = VelX * temp;
VelocityY = VelY * temp;
}
else
{
VelocityX = VelX << 16;
VelocityY = VelY << 16;
}
} /*if */
int_velocityX[j] = VelocityX + (offX << 16);
int_velocityY[j] = VelocityY + (offY << 16);
X1 += blockSize.width;
} /*for */
int_velocityX += velStep;
int_velocityY += velStep;
imgA += DownStep;
Y1 += blockSize.height;
} /*for */
/****************************************************************************************\
* Converting fixed point velocities to floating point *
\****************************************************************************************/
{
float *velxf = velocityX, *velyf = velocityY;
int* velx = (int*)velocityX, *vely = (int*)velocityY;
for( i = 0; i < NumberBlocksY; i++, velxf += velStep, velyf += velStep,
velx += velStep, vely += velStep )
{
for( j = 0; j < NumberBlocksX; j++ )
{
float vx = (float)velx[j]*back, vy = (float)vely[j]*back;
velxf[j] = vx; velyf[j] = vy;
}
}
}
cvFree( &ss );
cvFree( &blockA );
return CV_OK;
} /*cvCalcOpticalFlowBM_8u */
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvCalcOpticalFlowBM
// Purpose: Optical flow implementation
// Context:
// Parameters:
// srcA, srcB - source image
// velx, vely - destination image
// Returns:
//
// Notes:
//F*/
CV_IMPL void
cvCalcOpticalFlowBM( const void* srcarrA, const void* srcarrB,
CvSize blockSize, CvSize shiftSize,
CvSize maxRange, int usePrevious,
void* velarrx, void* velarry )
{
CV_FUNCNAME( "cvCalcOpticalFlowBM" );
__BEGIN__;
CvMat stubA, *srcA = (CvMat*)srcarrA;
CvMat stubB, *srcB = (CvMat*)srcarrB;
CvMat stubx, *velx = (CvMat*)velarrx;
CvMat stuby, *vely = (CvMat*)velarry;
CV_CALL( srcA = cvGetMat( srcA, &stubA ));
CV_CALL( srcB = cvGetMat( srcB, &stubB ));
CV_CALL( velx = cvGetMat( velx, &stubx ));
CV_CALL( vely = cvGetMat( vely, &stuby ));
if( !CV_ARE_TYPES_EQ( srcA, srcB ))
CV_ERROR( CV_StsUnmatchedFormats, "Source images have different formats" );
if( !CV_ARE_TYPES_EQ( velx, vely ))
CV_ERROR( CV_StsUnmatchedFormats, "Destination images have different formats" );
if( !CV_ARE_SIZES_EQ( srcA, srcB ) ||
!CV_ARE_SIZES_EQ( velx, vely ) ||
(unsigned)(velx->width*blockSize.width - srcA->width) >= (unsigned)blockSize.width ||
(unsigned)(velx->height*blockSize.height - srcA->height) >= (unsigned)blockSize.height )
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( CV_MAT_TYPE( srcA->type ) != CV_8UC1 ||
CV_MAT_TYPE( velx->type ) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "Source images must have 8uC1 type and "
"destination images must have 32fC1 type" );
if( srcA->step != srcB->step || velx->step != vely->step )
CV_ERROR( CV_BadStep, "two source or two destination images have different steps" );
IPPI_CALL( icvCalcOpticalFlowBM_8u32fR( (uchar*)srcA->data.ptr, (uchar*)srcB->data.ptr,
srcA->step, cvGetMatSize( srcA ), blockSize,
shiftSize, maxRange, usePrevious,
velx->data.fl, vely->data.fl, velx->step ));
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,535 @@
/*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*/
#include "_cv.h"
#define CONV( A, B, C) ( (float)( A + (B<<1) + C ) )
typedef struct
{
float xx;
float xy;
float yy;
float xt;
float yt;
float alpha; /* alpha = 1 / ( 1/lambda + xx + yy ) */
}
icvDerProductEx;
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvCalcOpticalFlowHS_8u32fR (Horn & Schunck method )
// Purpose: calculate Optical flow for 2 images using Horn & Schunck algorithm
// Context:
// Parameters:
// imgA - pointer to first frame ROI
// imgB - pointer to second frame ROI
// imgStep - width of single row of source images in bytes
// imgSize - size of the source image ROI
// usePrevious - use previous (input) velocity field.
// velocityX - pointer to horizontal and
// velocityY - vertical components of optical flow ROI
// velStep - width of single row of velocity frames in bytes
// lambda - Lagrangian multiplier
// criteria - criteria of termination processmaximum number of iterations
//
// Returns: CV_OK - all ok
// CV_OUTOFMEM_ERR - insufficient memory for function work
// CV_NULLPTR_ERR - if one of input pointers is NULL
// CV_BADSIZE_ERR - wrong input sizes interrelation
//
// Notes: 1.Optical flow to be computed for every pixel in ROI
// 2.For calculating spatial derivatives we use 3x3 Sobel operator.
// 3.We use the following border mode.
// The last row or column is replicated for the border
// ( IPL_BORDER_REPLICATE in IPL ).
//
//
//F*/
static CvStatus CV_STDCALL
icvCalcOpticalFlowHS_8u32fR( uchar* imgA,
uchar* imgB,
int imgStep,
CvSize imgSize,
int usePrevious,
float* velocityX,
float* velocityY,
int velStep,
float lambda,
CvTermCriteria criteria )
{
/* Loops indexes */
int i, j, k, address;
/* Buffers for Sobel calculations */
float *MemX[2];
float *MemY[2];
float ConvX, ConvY;
float GradX, GradY, GradT;
int imageWidth = imgSize.width;
int imageHeight = imgSize.height;
int ConvLine;
int LastLine;
int BufferSize;
float Ilambda = 1 / lambda;
int iter = 0;
int Stop;
/* buffers derivatives product */
icvDerProductEx *II;
float *VelBufX[2];
float *VelBufY[2];
/* variables for storing number of first pixel of image line */
int Line1;
int Line2;
int Line3;
int pixNumber;
/* auxiliary */
int NoMem = 0;
/* Checking bad arguments */
if( imgA == NULL )
return CV_NULLPTR_ERR;
if( imgB == NULL )
return CV_NULLPTR_ERR;
if( imgSize.width <= 0 )
return CV_BADSIZE_ERR;
if( imgSize.height <= 0 )
return CV_BADSIZE_ERR;
if( imgSize.width > imgStep )
return CV_BADSIZE_ERR;
if( (velStep & 3) != 0 )
return CV_BADSIZE_ERR;
velStep /= 4;
/****************************************************************************************/
/* Allocating memory for all buffers */
/****************************************************************************************/
for( k = 0; k < 2; k++ )
{
MemX[k] = (float *) cvAlloc( (imgSize.height) * sizeof( float ));
if( MemX[k] == NULL )
NoMem = 1;
MemY[k] = (float *) cvAlloc( (imgSize.width) * sizeof( float ));
if( MemY[k] == NULL )
NoMem = 1;
VelBufX[k] = (float *) cvAlloc( imageWidth * sizeof( float ));
if( VelBufX[k] == NULL )
NoMem = 1;
VelBufY[k] = (float *) cvAlloc( imageWidth * sizeof( float ));
if( VelBufY[k] == NULL )
NoMem = 1;
}
BufferSize = imageHeight * imageWidth;
II = (icvDerProductEx *) cvAlloc( BufferSize * sizeof( icvDerProductEx ));
if( (II == NULL) )
NoMem = 1;
if( NoMem )
{
for( k = 0; k < 2; k++ )
{
if( MemX[k] )
cvFree( &MemX[k] );
if( MemY[k] )
cvFree( &MemY[k] );
if( VelBufX[k] )
cvFree( &VelBufX[k] );
if( VelBufY[k] )
cvFree( &VelBufY[k] );
}
if( II )
cvFree( &II );
return CV_OUTOFMEM_ERR;
}
/****************************************************************************************\
* Calculate first line of memX and memY *
\****************************************************************************************/
MemY[0][0] = MemY[1][0] = CONV( imgA[0], imgA[0], imgA[1] );
MemX[0][0] = MemX[1][0] = CONV( imgA[0], imgA[0], imgA[imgStep] );
for( j = 1; j < imageWidth - 1; j++ )
{
MemY[0][j] = MemY[1][j] = CONV( imgA[j - 1], imgA[j], imgA[j + 1] );
}
pixNumber = imgStep;
for( i = 1; i < imageHeight - 1; i++ )
{
MemX[0][i] = MemX[1][i] = CONV( imgA[pixNumber - imgStep],
imgA[pixNumber], imgA[pixNumber + imgStep] );
pixNumber += imgStep;
}
MemY[0][imageWidth - 1] =
MemY[1][imageWidth - 1] = CONV( imgA[imageWidth - 2],
imgA[imageWidth - 1], imgA[imageWidth - 1] );
MemX[0][imageHeight - 1] =
MemX[1][imageHeight - 1] = CONV( imgA[pixNumber - imgStep],
imgA[pixNumber], imgA[pixNumber] );
/****************************************************************************************\
* begin scan image, calc derivatives *
\****************************************************************************************/
ConvLine = 0;
Line2 = -imgStep;
address = 0;
LastLine = imgStep * (imageHeight - 1);
while( ConvLine < imageHeight )
{
/*Here we calculate derivatives for line of image */
int memYline = (ConvLine + 1) & 1;
Line2 += imgStep;
Line1 = Line2 - ((Line2 == 0) ? 0 : imgStep);
Line3 = Line2 + ((Line2 == LastLine) ? 0 : imgStep);
/* Process first pixel */
ConvX = CONV( imgA[Line1 + 1], imgA[Line2 + 1], imgA[Line3 + 1] );
ConvY = CONV( imgA[Line3], imgA[Line3], imgA[Line3 + 1] );
GradY = (ConvY - MemY[memYline][0]) * 0.125f;
GradX = (ConvX - MemX[1][ConvLine]) * 0.125f;
MemY[memYline][0] = ConvY;
MemX[1][ConvLine] = ConvX;
GradT = (float) (imgB[Line2] - imgA[Line2]);
II[address].xx = GradX * GradX;
II[address].xy = GradX * GradY;
II[address].yy = GradY * GradY;
II[address].xt = GradX * GradT;
II[address].yt = GradY * GradT;
II[address].alpha = 1 / (Ilambda + II[address].xx + II[address].yy);
address++;
/* Process middle of line */
for( j = 1; j < imageWidth - 1; j++ )
{
ConvX = CONV( imgA[Line1 + j + 1], imgA[Line2 + j + 1], imgA[Line3 + j + 1] );
ConvY = CONV( imgA[Line3 + j - 1], imgA[Line3 + j], imgA[Line3 + j + 1] );
GradY = (ConvY - MemY[memYline][j]) * 0.125f;
GradX = (ConvX - MemX[(j - 1) & 1][ConvLine]) * 0.125f;
MemY[memYline][j] = ConvY;
MemX[(j - 1) & 1][ConvLine] = ConvX;
GradT = (float) (imgB[Line2 + j] - imgA[Line2 + j]);
II[address].xx = GradX * GradX;
II[address].xy = GradX * GradY;
II[address].yy = GradY * GradY;
II[address].xt = GradX * GradT;
II[address].yt = GradY * GradT;
II[address].alpha = 1 / (Ilambda + II[address].xx + II[address].yy);
address++;
}
/* Process last pixel of line */
ConvX = CONV( imgA[Line1 + imageWidth - 1], imgA[Line2 + imageWidth - 1],
imgA[Line3 + imageWidth - 1] );
ConvY = CONV( imgA[Line3 + imageWidth - 2], imgA[Line3 + imageWidth - 1],
imgA[Line3 + imageWidth - 1] );
GradY = (ConvY - MemY[memYline][imageWidth - 1]) * 0.125f;
GradX = (ConvX - MemX[(imageWidth - 2) & 1][ConvLine]) * 0.125f;
MemY[memYline][imageWidth - 1] = ConvY;
GradT = (float) (imgB[Line2 + imageWidth - 1] - imgA[Line2 + imageWidth - 1]);
II[address].xx = GradX * GradX;
II[address].xy = GradX * GradY;
II[address].yy = GradY * GradY;
II[address].xt = GradX * GradT;
II[address].yt = GradY * GradT;
II[address].alpha = 1 / (Ilambda + II[address].xx + II[address].yy);
address++;
ConvLine++;
}
/****************************************************************************************\
* Prepare initial approximation *
\****************************************************************************************/
if( !usePrevious )
{
float *vx = velocityX;
float *vy = velocityY;
for( i = 0; i < imageHeight; i++ )
{
memset( vx, 0, imageWidth * sizeof( float ));
memset( vy, 0, imageWidth * sizeof( float ));
vx += velStep;
vy += velStep;
}
}
/****************************************************************************************\
* Perform iterations *
\****************************************************************************************/
iter = 0;
Stop = 0;
LastLine = velStep * (imageHeight - 1);
while( !Stop )
{
float Eps = 0;
address = 0;
iter++;
/****************************************************************************************\
* begin scan velocity and update it *
\****************************************************************************************/
Line2 = -velStep;
for( i = 0; i < imageHeight; i++ )
{
/* Here average velocity */
float averageX;
float averageY;
float tmp;
Line2 += velStep;
Line1 = Line2 - ((Line2 == 0) ? 0 : velStep);
Line3 = Line2 + ((Line2 == LastLine) ? 0 : velStep);
/* Process first pixel */
averageX = (velocityX[Line2] +
velocityX[Line2 + 1] + velocityX[Line1] + velocityX[Line3]) / 4;
averageY = (velocityY[Line2] +
velocityY[Line2 + 1] + velocityY[Line1] + velocityY[Line3]) / 4;
VelBufX[i & 1][0] = averageX -
(II[address].xx * averageX +
II[address].xy * averageY + II[address].xt) * II[address].alpha;
VelBufY[i & 1][0] = averageY -
(II[address].xy * averageX +
II[address].yy * averageY + II[address].yt) * II[address].alpha;
/* update Epsilon */
if( criteria.type & CV_TERMCRIT_EPS )
{
tmp = (float)fabs(velocityX[Line2] - VelBufX[i & 1][0]);
Eps = MAX( tmp, Eps );
tmp = (float)fabs(velocityY[Line2] - VelBufY[i & 1][0]);
Eps = MAX( tmp, Eps );
}
address++;
/* Process middle of line */
for( j = 1; j < imageWidth - 1; j++ )
{
averageX = (velocityX[Line2 + j - 1] +
velocityX[Line2 + j + 1] +
velocityX[Line1 + j] + velocityX[Line3 + j]) / 4;
averageY = (velocityY[Line2 + j - 1] +
velocityY[Line2 + j + 1] +
velocityY[Line1 + j] + velocityY[Line3 + j]) / 4;
VelBufX[i & 1][j] = averageX -
(II[address].xx * averageX +
II[address].xy * averageY + II[address].xt) * II[address].alpha;
VelBufY[i & 1][j] = averageY -
(II[address].xy * averageX +
II[address].yy * averageY + II[address].yt) * II[address].alpha;
/* update Epsilon */
if( criteria.type & CV_TERMCRIT_EPS )
{
tmp = (float)fabs(velocityX[Line2 + j] - VelBufX[i & 1][j]);
Eps = MAX( tmp, Eps );
tmp = (float)fabs(velocityY[Line2 + j] - VelBufY[i & 1][j]);
Eps = MAX( tmp, Eps );
}
address++;
}
/* Process last pixel of line */
averageX = (velocityX[Line2 + imageWidth - 2] +
velocityX[Line2 + imageWidth - 1] +
velocityX[Line1 + imageWidth - 1] +
velocityX[Line3 + imageWidth - 1]) / 4;
averageY = (velocityY[Line2 + imageWidth - 2] +
velocityY[Line2 + imageWidth - 1] +
velocityY[Line1 + imageWidth - 1] +
velocityY[Line3 + imageWidth - 1]) / 4;
VelBufX[i & 1][imageWidth - 1] = averageX -
(II[address].xx * averageX +
II[address].xy * averageY + II[address].xt) * II[address].alpha;
VelBufY[i & 1][imageWidth - 1] = averageY -
(II[address].xy * averageX +
II[address].yy * averageY + II[address].yt) * II[address].alpha;
/* update Epsilon */
if( criteria.type & CV_TERMCRIT_EPS )
{
tmp = (float)fabs(velocityX[Line2 + imageWidth - 1] -
VelBufX[i & 1][imageWidth - 1]);
Eps = MAX( tmp, Eps );
tmp = (float)fabs(velocityY[Line2 + imageWidth - 1] -
VelBufY[i & 1][imageWidth - 1]);
Eps = MAX( tmp, Eps );
}
address++;
/* store new velocity from old buffer to velocity frame */
if( i > 0 )
{
memcpy( &velocityX[Line1], VelBufX[(i - 1) & 1], imageWidth * sizeof( float ));
memcpy( &velocityY[Line1], VelBufY[(i - 1) & 1], imageWidth * sizeof( float ));
}
} /*for */
/* store new velocity from old buffer to velocity frame */
memcpy( &velocityX[imageWidth * (imageHeight - 1)],
VelBufX[(imageHeight - 1) & 1], imageWidth * sizeof( float ));
memcpy( &velocityY[imageWidth * (imageHeight - 1)],
VelBufY[(imageHeight - 1) & 1], imageWidth * sizeof( float ));
if( (criteria.type & CV_TERMCRIT_ITER) && (iter == criteria.max_iter) )
Stop = 1;
if( (criteria.type & CV_TERMCRIT_EPS) && (Eps < criteria.epsilon) )
Stop = 1;
}
/* Free memory */
for( k = 0; k < 2; k++ )
{
cvFree( &MemX[k] );
cvFree( &MemY[k] );
cvFree( &VelBufX[k] );
cvFree( &VelBufY[k] );
}
cvFree( &II );
return CV_OK;
} /*icvCalcOpticalFlowHS_8u32fR*/
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvCalcOpticalFlowHS
// Purpose: Optical flow implementation
// Context:
// Parameters:
// srcA, srcB - source image
// velx, vely - destination image
// Returns:
//
// Notes:
//F*/
CV_IMPL void
cvCalcOpticalFlowHS( const void* srcarrA, const void* srcarrB, int usePrevious,
void* velarrx, void* velarry,
double lambda, CvTermCriteria criteria )
{
CV_FUNCNAME( "cvCalcOpticalFlowHS" );
__BEGIN__;
CvMat stubA, *srcA = (CvMat*)srcarrA;
CvMat stubB, *srcB = (CvMat*)srcarrB;
CvMat stubx, *velx = (CvMat*)velarrx;
CvMat stuby, *vely = (CvMat*)velarry;
CV_CALL( srcA = cvGetMat( srcA, &stubA ));
CV_CALL( srcB = cvGetMat( srcB, &stubB ));
CV_CALL( velx = cvGetMat( velx, &stubx ));
CV_CALL( vely = cvGetMat( vely, &stuby ));
if( !CV_ARE_TYPES_EQ( srcA, srcB ))
CV_ERROR( CV_StsUnmatchedFormats, "Source images have different formats" );
if( !CV_ARE_TYPES_EQ( velx, vely ))
CV_ERROR( CV_StsUnmatchedFormats, "Destination images have different formats" );
if( !CV_ARE_SIZES_EQ( srcA, srcB ) ||
!CV_ARE_SIZES_EQ( velx, vely ) ||
!CV_ARE_SIZES_EQ( srcA, velx ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( CV_MAT_TYPE( srcA->type ) != CV_8UC1 ||
CV_MAT_TYPE( velx->type ) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "Source images must have 8uC1 type and "
"destination images must have 32fC1 type" );
if( srcA->step != srcB->step || velx->step != vely->step )
CV_ERROR( CV_BadStep, "source and destination images have different step" );
IPPI_CALL( icvCalcOpticalFlowHS_8u32fR( (uchar*)srcA->data.ptr, (uchar*)srcB->data.ptr,
srcA->step, cvGetMatSize( srcA ), usePrevious,
velx->data.fl, vely->data.fl,
velx->step, (float)lambda, criteria ));
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,611 @@
/*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*/
#include "_cv.h"
typedef struct
{
float xx;
float xy;
float yy;
float xt;
float yt;
}
icvDerProduct;
#define CONV( A, B, C) ((float)( A + (B<<1) + C ))
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvCalcOpticalFlowLK_8u32fR ( Lucas & Kanade method )
// Purpose: calculate Optical flow for 2 images using Lucas & Kanade algorithm
// Context:
// Parameters:
// imgA, // pointer to first frame ROI
// imgB, // pointer to second frame ROI
// imgStep, // width of single row of source images in bytes
// imgSize, // size of the source image ROI
// winSize, // size of the averaging window used for grouping
// velocityX, // pointer to horizontal and
// velocityY, // vertical components of optical flow ROI
// velStep // width of single row of velocity frames in bytes
//
// Returns: CV_OK - all ok
// CV_OUTOFMEM_ERR - insufficient memory for function work
// CV_NULLPTR_ERR - if one of input pointers is NULL
// CV_BADSIZE_ERR - wrong input sizes interrelation
//
// Notes: 1.Optical flow to be computed for every pixel in ROI
// 2.For calculating spatial derivatives we use 3x3 Sobel operator.
// 3.We use the following border mode.
// The last row or column is replicated for the border
// ( IPL_BORDER_REPLICATE in IPL ).
//
//
//F*/
static CvStatus CV_STDCALL
icvCalcOpticalFlowLK_8u32fR( uchar * imgA,
uchar * imgB,
int imgStep,
CvSize imgSize,
CvSize winSize,
float *velocityX,
float *velocityY, int velStep )
{
/* Loops indexes */
int i, j, k;
/* Gaussian separable kernels */
float GaussX[16];
float GaussY[16];
float *KerX;
float *KerY;
/* Buffers for Sobel calculations */
float *MemX[2];
float *MemY[2];
float ConvX, ConvY;
float GradX, GradY, GradT;
int winWidth = winSize.width;
int winHeight = winSize.height;
int imageWidth = imgSize.width;
int imageHeight = imgSize.height;
int HorRadius = (winWidth - 1) >> 1;
int VerRadius = (winHeight - 1) >> 1;
int PixelLine;
int ConvLine;
int BufferAddress;
int BufferHeight = 0;
int BufferWidth;
int BufferSize;
/* buffers derivatives product */
icvDerProduct *II;
/* buffers for gaussian horisontal convolution */
icvDerProduct *WII;
/* variables for storing number of first pixel of image line */
int Line1;
int Line2;
int Line3;
/* we must have 2*2 linear system coeffs
| A1B2 B1 | {u} {C1} {0}
| | { } + { } = { }
| A2 A1B2 | {v} {C2} {0}
*/
float A1B2, A2, B1, C1, C2;
int pixNumber;
/* auxiliary */
int NoMem = 0;
velStep /= sizeof(velocityX[0]);
/* Checking bad arguments */
if( imgA == NULL )
return CV_NULLPTR_ERR;
if( imgB == NULL )
return CV_NULLPTR_ERR;
if( imageHeight < winHeight )
return CV_BADSIZE_ERR;
if( imageWidth < winWidth )
return CV_BADSIZE_ERR;
if( winHeight >= 16 )
return CV_BADSIZE_ERR;
if( winWidth >= 16 )
return CV_BADSIZE_ERR;
if( !(winHeight & 1) )
return CV_BADSIZE_ERR;
if( !(winWidth & 1) )
return CV_BADSIZE_ERR;
BufferHeight = winHeight;
BufferWidth = imageWidth;
/****************************************************************************************/
/* Computing Gaussian coeffs */
/****************************************************************************************/
GaussX[0] = 1;
GaussY[0] = 1;
for( i = 1; i < winWidth; i++ )
{
GaussX[i] = 1;
for( j = i - 1; j > 0; j-- )
{
GaussX[j] += GaussX[j - 1];
}
}
for( i = 1; i < winHeight; i++ )
{
GaussY[i] = 1;
for( j = i - 1; j > 0; j-- )
{
GaussY[j] += GaussY[j - 1];
}
}
KerX = &GaussX[HorRadius];
KerY = &GaussY[VerRadius];
/****************************************************************************************/
/* Allocating memory for all buffers */
/****************************************************************************************/
for( k = 0; k < 2; k++ )
{
MemX[k] = (float *) cvAlloc( (imgSize.height) * sizeof( float ));
if( MemX[k] == NULL )
NoMem = 1;
MemY[k] = (float *) cvAlloc( (imgSize.width) * sizeof( float ));
if( MemY[k] == NULL )
NoMem = 1;
}
BufferSize = BufferHeight * BufferWidth;
II = (icvDerProduct *) cvAlloc( BufferSize * sizeof( icvDerProduct ));
WII = (icvDerProduct *) cvAlloc( BufferSize * sizeof( icvDerProduct ));
if( (II == NULL) || (WII == NULL) )
NoMem = 1;
if( NoMem )
{
for( k = 0; k < 2; k++ )
{
if( MemX[k] )
cvFree( &MemX[k] );
if( MemY[k] )
cvFree( &MemY[k] );
}
if( II )
cvFree( &II );
if( WII )
cvFree( &WII );
return CV_OUTOFMEM_ERR;
}
/****************************************************************************************/
/* Calculate first line of memX and memY */
/****************************************************************************************/
MemY[0][0] = MemY[1][0] = CONV( imgA[0], imgA[0], imgA[1] );
MemX[0][0] = MemX[1][0] = CONV( imgA[0], imgA[0], imgA[imgStep] );
for( j = 1; j < imageWidth - 1; j++ )
{
MemY[0][j] = MemY[1][j] = CONV( imgA[j - 1], imgA[j], imgA[j + 1] );
}
pixNumber = imgStep;
for( i = 1; i < imageHeight - 1; i++ )
{
MemX[0][i] = MemX[1][i] = CONV( imgA[pixNumber - imgStep],
imgA[pixNumber], imgA[pixNumber + imgStep] );
pixNumber += imgStep;
}
MemY[0][imageWidth - 1] =
MemY[1][imageWidth - 1] = CONV( imgA[imageWidth - 2],
imgA[imageWidth - 1], imgA[imageWidth - 1] );
MemX[0][imageHeight - 1] =
MemX[1][imageHeight - 1] = CONV( imgA[pixNumber - imgStep],
imgA[pixNumber], imgA[pixNumber] );
/****************************************************************************************/
/* begin scan image, calc derivatives and solve system */
/****************************************************************************************/
PixelLine = -VerRadius;
ConvLine = 0;
BufferAddress = -BufferWidth;
while( PixelLine < imageHeight )
{
if( ConvLine < imageHeight )
{
/*Here we calculate derivatives for line of image */
int address;
i = ConvLine;
int L1 = i - 1;
int L2 = i;
int L3 = i + 1;
int memYline = L3 & 1;
if( L1 < 0 )
L1 = 0;
if( L3 >= imageHeight )
L3 = imageHeight - 1;
BufferAddress += BufferWidth;
BufferAddress -= ((BufferAddress >= BufferSize) ? 0xffffffff : 0) & BufferSize;
address = BufferAddress;
Line1 = L1 * imgStep;
Line2 = L2 * imgStep;
Line3 = L3 * imgStep;
/* Process first pixel */
ConvX = CONV( imgA[Line1 + 1], imgA[Line2 + 1], imgA[Line3 + 1] );
ConvY = CONV( imgA[Line3], imgA[Line3], imgA[Line3 + 1] );
GradY = ConvY - MemY[memYline][0];
GradX = ConvX - MemX[1][L2];
MemY[memYline][0] = ConvY;
MemX[1][L2] = ConvX;
GradT = (float) (imgB[Line2] - imgA[Line2]);
II[address].xx = GradX * GradX;
II[address].xy = GradX * GradY;
II[address].yy = GradY * GradY;
II[address].xt = GradX * GradT;
II[address].yt = GradY * GradT;
address++;
/* Process middle of line */
for( j = 1; j < imageWidth - 1; j++ )
{
ConvX = CONV( imgA[Line1 + j + 1], imgA[Line2 + j + 1], imgA[Line3 + j + 1] );
ConvY = CONV( imgA[Line3 + j - 1], imgA[Line3 + j], imgA[Line3 + j + 1] );
GradY = ConvY - MemY[memYline][j];
GradX = ConvX - MemX[(j - 1) & 1][L2];
MemY[memYline][j] = ConvY;
MemX[(j - 1) & 1][L2] = ConvX;
GradT = (float) (imgB[Line2 + j] - imgA[Line2 + j]);
II[address].xx = GradX * GradX;
II[address].xy = GradX * GradY;
II[address].yy = GradY * GradY;
II[address].xt = GradX * GradT;
II[address].yt = GradY * GradT;
address++;
}
/* Process last pixel of line */
ConvX = CONV( imgA[Line1 + imageWidth - 1], imgA[Line2 + imageWidth - 1],
imgA[Line3 + imageWidth - 1] );
ConvY = CONV( imgA[Line3 + imageWidth - 2], imgA[Line3 + imageWidth - 1],
imgA[Line3 + imageWidth - 1] );
GradY = ConvY - MemY[memYline][imageWidth - 1];
GradX = ConvX - MemX[(imageWidth - 2) & 1][L2];
MemY[memYline][imageWidth - 1] = ConvY;
GradT = (float) (imgB[Line2 + imageWidth - 1] - imgA[Line2 + imageWidth - 1]);
II[address].xx = GradX * GradX;
II[address].xy = GradX * GradY;
II[address].yy = GradY * GradY;
II[address].xt = GradX * GradT;
II[address].yt = GradY * GradT;
address++;
/* End of derivatives for line */
/****************************************************************************************/
/* ---------Calculating horizontal convolution of processed line----------------------- */
/****************************************************************************************/
address -= BufferWidth;
/* process first HorRadius pixels */
for( j = 0; j < HorRadius; j++ )
{
int jj;
WII[address].xx = 0;
WII[address].xy = 0;
WII[address].yy = 0;
WII[address].xt = 0;
WII[address].yt = 0;
for( jj = -j; jj <= HorRadius; jj++ )
{
float Ker = KerX[jj];
WII[address].xx += II[address + jj].xx * Ker;
WII[address].xy += II[address + jj].xy * Ker;
WII[address].yy += II[address + jj].yy * Ker;
WII[address].xt += II[address + jj].xt * Ker;
WII[address].yt += II[address + jj].yt * Ker;
}
address++;
}
/* process inner part of line */
for( j = HorRadius; j < imageWidth - HorRadius; j++ )
{
int jj;
float Ker0 = KerX[0];
WII[address].xx = 0;
WII[address].xy = 0;
WII[address].yy = 0;
WII[address].xt = 0;
WII[address].yt = 0;
for( jj = 1; jj <= HorRadius; jj++ )
{
float Ker = KerX[jj];
WII[address].xx += (II[address - jj].xx + II[address + jj].xx) * Ker;
WII[address].xy += (II[address - jj].xy + II[address + jj].xy) * Ker;
WII[address].yy += (II[address - jj].yy + II[address + jj].yy) * Ker;
WII[address].xt += (II[address - jj].xt + II[address + jj].xt) * Ker;
WII[address].yt += (II[address - jj].yt + II[address + jj].yt) * Ker;
}
WII[address].xx += II[address].xx * Ker0;
WII[address].xy += II[address].xy * Ker0;
WII[address].yy += II[address].yy * Ker0;
WII[address].xt += II[address].xt * Ker0;
WII[address].yt += II[address].yt * Ker0;
address++;
}
/* process right side */
for( j = imageWidth - HorRadius; j < imageWidth; j++ )
{
int jj;
WII[address].xx = 0;
WII[address].xy = 0;
WII[address].yy = 0;
WII[address].xt = 0;
WII[address].yt = 0;
for( jj = -HorRadius; jj < imageWidth - j; jj++ )
{
float Ker = KerX[jj];
WII[address].xx += II[address + jj].xx * Ker;
WII[address].xy += II[address + jj].xy * Ker;
WII[address].yy += II[address + jj].yy * Ker;
WII[address].xt += II[address + jj].xt * Ker;
WII[address].yt += II[address + jj].yt * Ker;
}
address++;
}
}
/****************************************************************************************/
/* Calculating velocity line */
/****************************************************************************************/
if( PixelLine >= 0 )
{
int USpace;
int BSpace;
int address;
if( PixelLine < VerRadius )
USpace = PixelLine;
else
USpace = VerRadius;
if( PixelLine >= imageHeight - VerRadius )
BSpace = imageHeight - PixelLine - 1;
else
BSpace = VerRadius;
address = ((PixelLine - USpace) % BufferHeight) * BufferWidth;
for( j = 0; j < imageWidth; j++ )
{
int addr = address;
A1B2 = 0;
A2 = 0;
B1 = 0;
C1 = 0;
C2 = 0;
for( i = -USpace; i <= BSpace; i++ )
{
A2 += WII[addr + j].xx * KerY[i];
A1B2 += WII[addr + j].xy * KerY[i];
B1 += WII[addr + j].yy * KerY[i];
C2 += WII[addr + j].xt * KerY[i];
C1 += WII[addr + j].yt * KerY[i];
addr += BufferWidth;
addr -= ((addr >= BufferSize) ? 0xffffffff : 0) & BufferSize;
}
/****************************************************************************************\
* Solve Linear System *
\****************************************************************************************/
{
float delta = (A1B2 * A1B2 - A2 * B1);
if( delta )
{
/* system is not singular - solving by Kramer method */
float deltaX;
float deltaY;
float Idelta = 8 / delta;
deltaX = -(C1 * A1B2 - C2 * B1);
deltaY = -(A1B2 * C2 - A2 * C1);
velocityX[j] = deltaX * Idelta;
velocityY[j] = deltaY * Idelta;
}
else
{
/* singular system - find optical flow in gradient direction */
float Norm = (A1B2 + A2) * (A1B2 + A2) + (B1 + A1B2) * (B1 + A1B2);
if( Norm )
{
float IGradNorm = 8 / Norm;
float temp = -(C1 + C2) * IGradNorm;
velocityX[j] = (A1B2 + A2) * temp;
velocityY[j] = (B1 + A1B2) * temp;
}
else
{
velocityX[j] = 0;
velocityY[j] = 0;
}
}
}
/****************************************************************************************\
* End of Solving Linear System *
\****************************************************************************************/
} /*for */
velocityX += velStep;
velocityY += velStep;
} /*for */
PixelLine++;
ConvLine++;
}
/* Free memory */
for( k = 0; k < 2; k++ )
{
cvFree( &MemX[k] );
cvFree( &MemY[k] );
}
cvFree( &II );
cvFree( &WII );
return CV_OK;
} /*icvCalcOpticalFlowLK_8u32fR*/
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: cvCalcOpticalFlowLK
// Purpose: Optical flow implementation
// Context:
// Parameters:
// srcA, srcB - source image
// velx, vely - destination image
// Returns:
//
// Notes:
//F*/
CV_IMPL void
cvCalcOpticalFlowLK( const void* srcarrA, const void* srcarrB, CvSize winSize,
void* velarrx, void* velarry )
{
CV_FUNCNAME( "cvCalcOpticalFlowLK" );
__BEGIN__;
CvMat stubA, *srcA = (CvMat*)srcarrA;
CvMat stubB, *srcB = (CvMat*)srcarrB;
CvMat stubx, *velx = (CvMat*)velarrx;
CvMat stuby, *vely = (CvMat*)velarry;
CV_CALL( srcA = cvGetMat( srcA, &stubA ));
CV_CALL( srcB = cvGetMat( srcB, &stubB ));
CV_CALL( velx = cvGetMat( velx, &stubx ));
CV_CALL( vely = cvGetMat( vely, &stuby ));
if( !CV_ARE_TYPES_EQ( srcA, srcB ))
CV_ERROR( CV_StsUnmatchedFormats, "Source images have different formats" );
if( !CV_ARE_TYPES_EQ( velx, vely ))
CV_ERROR( CV_StsUnmatchedFormats, "Destination images have different formats" );
if( !CV_ARE_SIZES_EQ( srcA, srcB ) ||
!CV_ARE_SIZES_EQ( velx, vely ) ||
!CV_ARE_SIZES_EQ( srcA, velx ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( CV_MAT_TYPE( srcA->type ) != CV_8UC1 ||
CV_MAT_TYPE( velx->type ) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "Source images must have 8uC1 type and "
"destination images must have 32fC1 type" );
if( srcA->step != srcB->step || velx->step != vely->step )
CV_ERROR( CV_BadStep, "source and destination images have different step" );
IPPI_CALL( icvCalcOpticalFlowLK_8u32fR( (uchar*)srcA->data.ptr, (uchar*)srcB->data.ptr,
srcA->step, cvGetMatSize( srcA ), winSize,
velx->data.fl, vely->data.fl, velx->step ));
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,363 @@
/*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*/
#include "_cv.h"
#define _CV_ACOS_TABLE_SIZE 513
static const float icv_acos_table[_CV_ACOS_TABLE_SIZE] = {
3.14159265f, 3.05317551f, 3.01651113f, 2.98834964f, 2.96458497f, 2.94362719f,
2.92466119f, 2.90720289f, 2.89093699f, 2.87564455f, 2.86116621f, 2.84738169f,
2.83419760f, 2.82153967f, 2.80934770f, 2.79757211f, 2.78617145f, 2.77511069f,
2.76435988f, 2.75389319f, 2.74368816f, 2.73372510f, 2.72398665f, 2.71445741f,
2.70512362f, 2.69597298f, 2.68699438f, 2.67817778f, 2.66951407f, 2.66099493f,
2.65261279f, 2.64436066f, 2.63623214f, 2.62822133f, 2.62032277f, 2.61253138f,
2.60484248f, 2.59725167f, 2.58975488f, 2.58234828f, 2.57502832f, 2.56779164f,
2.56063509f, 2.55355572f, 2.54655073f, 2.53961750f, 2.53275354f, 2.52595650f,
2.51922417f, 2.51255441f, 2.50594525f, 2.49939476f, 2.49290115f, 2.48646269f,
2.48007773f, 2.47374472f, 2.46746215f, 2.46122860f, 2.45504269f, 2.44890314f,
2.44280867f, 2.43675809f, 2.43075025f, 2.42478404f, 2.41885841f, 2.41297232f,
2.40712480f, 2.40131491f, 2.39554173f, 2.38980439f, 2.38410204f, 2.37843388f,
2.37279910f, 2.36719697f, 2.36162673f, 2.35608768f, 2.35057914f, 2.34510044f,
2.33965094f, 2.33423003f, 2.32883709f, 2.32347155f, 2.31813284f, 2.31282041f,
2.30753373f, 2.30227228f, 2.29703556f, 2.29182309f, 2.28663439f, 2.28146900f,
2.27632647f, 2.27120637f, 2.26610827f, 2.26103177f, 2.25597646f, 2.25094195f,
2.24592786f, 2.24093382f, 2.23595946f, 2.23100444f, 2.22606842f, 2.22115104f,
2.21625199f, 2.21137096f, 2.20650761f, 2.20166166f, 2.19683280f, 2.19202074f,
2.18722520f, 2.18244590f, 2.17768257f, 2.17293493f, 2.16820274f, 2.16348574f,
2.15878367f, 2.15409630f, 2.14942338f, 2.14476468f, 2.14011997f, 2.13548903f,
2.13087163f, 2.12626757f, 2.12167662f, 2.11709859f, 2.11253326f, 2.10798044f,
2.10343994f, 2.09891156f, 2.09439510f, 2.08989040f, 2.08539725f, 2.08091550f,
2.07644495f, 2.07198545f, 2.06753681f, 2.06309887f, 2.05867147f, 2.05425445f,
2.04984765f, 2.04545092f, 2.04106409f, 2.03668703f, 2.03231957f, 2.02796159f,
2.02361292f, 2.01927344f, 2.01494300f, 2.01062146f, 2.00630870f, 2.00200457f,
1.99770895f, 1.99342171f, 1.98914271f, 1.98487185f, 1.98060898f, 1.97635399f,
1.97210676f, 1.96786718f, 1.96363511f, 1.95941046f, 1.95519310f, 1.95098292f,
1.94677982f, 1.94258368f, 1.93839439f, 1.93421185f, 1.93003595f, 1.92586659f,
1.92170367f, 1.91754708f, 1.91339673f, 1.90925250f, 1.90511432f, 1.90098208f,
1.89685568f, 1.89273503f, 1.88862003f, 1.88451060f, 1.88040664f, 1.87630806f,
1.87221477f, 1.86812668f, 1.86404371f, 1.85996577f, 1.85589277f, 1.85182462f,
1.84776125f, 1.84370256f, 1.83964848f, 1.83559892f, 1.83155381f, 1.82751305f,
1.82347658f, 1.81944431f, 1.81541617f, 1.81139207f, 1.80737194f, 1.80335570f,
1.79934328f, 1.79533460f, 1.79132959f, 1.78732817f, 1.78333027f, 1.77933581f,
1.77534473f, 1.77135695f, 1.76737240f, 1.76339101f, 1.75941271f, 1.75543743f,
1.75146510f, 1.74749565f, 1.74352900f, 1.73956511f, 1.73560389f, 1.73164527f,
1.72768920f, 1.72373560f, 1.71978441f, 1.71583556f, 1.71188899f, 1.70794462f,
1.70400241f, 1.70006228f, 1.69612416f, 1.69218799f, 1.68825372f, 1.68432127f,
1.68039058f, 1.67646160f, 1.67253424f, 1.66860847f, 1.66468420f, 1.66076139f,
1.65683996f, 1.65291986f, 1.64900102f, 1.64508338f, 1.64116689f, 1.63725148f,
1.63333709f, 1.62942366f, 1.62551112f, 1.62159943f, 1.61768851f, 1.61377831f,
1.60986877f, 1.60595982f, 1.60205142f, 1.59814349f, 1.59423597f, 1.59032882f,
1.58642196f, 1.58251535f, 1.57860891f, 1.57470259f, 1.57079633f, 1.56689007f,
1.56298375f, 1.55907731f, 1.55517069f, 1.55126383f, 1.54735668f, 1.54344917f,
1.53954124f, 1.53563283f, 1.53172389f, 1.52781434f, 1.52390414f, 1.51999323f,
1.51608153f, 1.51216900f, 1.50825556f, 1.50434117f, 1.50042576f, 1.49650927f,
1.49259163f, 1.48867280f, 1.48475270f, 1.48083127f, 1.47690845f, 1.47298419f,
1.46905841f, 1.46513106f, 1.46120207f, 1.45727138f, 1.45333893f, 1.44940466f,
1.44546850f, 1.44153038f, 1.43759024f, 1.43364803f, 1.42970367f, 1.42575709f,
1.42180825f, 1.41785705f, 1.41390346f, 1.40994738f, 1.40598877f, 1.40202755f,
1.39806365f, 1.39409701f, 1.39012756f, 1.38615522f, 1.38217994f, 1.37820164f,
1.37422025f, 1.37023570f, 1.36624792f, 1.36225684f, 1.35826239f, 1.35426449f,
1.35026307f, 1.34625805f, 1.34224937f, 1.33823695f, 1.33422072f, 1.33020059f,
1.32617649f, 1.32214834f, 1.31811607f, 1.31407960f, 1.31003885f, 1.30599373f,
1.30194417f, 1.29789009f, 1.29383141f, 1.28976803f, 1.28569989f, 1.28162688f,
1.27754894f, 1.27346597f, 1.26937788f, 1.26528459f, 1.26118602f, 1.25708205f,
1.25297262f, 1.24885763f, 1.24473698f, 1.24061058f, 1.23647833f, 1.23234015f,
1.22819593f, 1.22404557f, 1.21988898f, 1.21572606f, 1.21155670f, 1.20738080f,
1.20319826f, 1.19900898f, 1.19481283f, 1.19060973f, 1.18639955f, 1.18218219f,
1.17795754f, 1.17372548f, 1.16948589f, 1.16523866f, 1.16098368f, 1.15672081f,
1.15244994f, 1.14817095f, 1.14388370f, 1.13958808f, 1.13528396f, 1.13097119f,
1.12664966f, 1.12231921f, 1.11797973f, 1.11363107f, 1.10927308f, 1.10490563f,
1.10052856f, 1.09614174f, 1.09174500f, 1.08733820f, 1.08292118f, 1.07849378f,
1.07405585f, 1.06960721f, 1.06514770f, 1.06067715f, 1.05619540f, 1.05170226f,
1.04719755f, 1.04268110f, 1.03815271f, 1.03361221f, 1.02905939f, 1.02449407f,
1.01991603f, 1.01532509f, 1.01072102f, 1.00610363f, 1.00147268f, 0.99682798f,
0.99216928f, 0.98749636f, 0.98280898f, 0.97810691f, 0.97338991f, 0.96865772f,
0.96391009f, 0.95914675f, 0.95436745f, 0.94957191f, 0.94475985f, 0.93993099f,
0.93508504f, 0.93022170f, 0.92534066f, 0.92044161f, 0.91552424f, 0.91058821f,
0.90563319f, 0.90065884f, 0.89566479f, 0.89065070f, 0.88561619f, 0.88056088f,
0.87548438f, 0.87038629f, 0.86526619f, 0.86012366f, 0.85495827f, 0.84976956f,
0.84455709f, 0.83932037f, 0.83405893f, 0.82877225f, 0.82345981f, 0.81812110f,
0.81275556f, 0.80736262f, 0.80194171f, 0.79649221f, 0.79101352f, 0.78550497f,
0.77996593f, 0.77439569f, 0.76879355f, 0.76315878f, 0.75749061f, 0.75178826f,
0.74605092f, 0.74027775f, 0.73446785f, 0.72862033f, 0.72273425f, 0.71680861f,
0.71084240f, 0.70483456f, 0.69878398f, 0.69268952f, 0.68654996f, 0.68036406f,
0.67413051f, 0.66784794f, 0.66151492f, 0.65512997f, 0.64869151f, 0.64219789f,
0.63564741f, 0.62903824f, 0.62236849f, 0.61563615f, 0.60883911f, 0.60197515f,
0.59504192f, 0.58803694f, 0.58095756f, 0.57380101f, 0.56656433f, 0.55924437f,
0.55183778f, 0.54434099f, 0.53675018f, 0.52906127f, 0.52126988f, 0.51337132f,
0.50536051f, 0.49723200f, 0.48897987f, 0.48059772f, 0.47207859f, 0.46341487f,
0.45459827f, 0.44561967f, 0.43646903f, 0.42713525f, 0.41760600f, 0.40786755f,
0.39790449f, 0.38769946f, 0.37723277f, 0.36648196f, 0.35542120f, 0.34402054f,
0.33224495f, 0.32005298f, 0.30739505f, 0.29421096f, 0.28042645f, 0.26594810f,
0.25065566f, 0.23438976f, 0.21693146f, 0.19796546f, 0.17700769f, 0.15324301f,
0.12508152f, 0.08841715f, 0.00000000f
};
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvCalcPGH
// Purpose:
// Calculates PGH(pairwise geometric histogram) for contour given.
// Context:
// Parameters:
// contour - pointer to input contour object.
// pgh - output histogram
// ang_dim - number of angle bins (vertical size of histogram)
// dist_dim - number of distance bins (horizontal size of histogram)
// Returns:
// CV_OK or error code
// Notes:
//F*/
static CvStatus
icvCalcPGH( const CvSeq * contour, float *pgh, int angle_dim, int dist_dim )
{
char local_buffer[(1 << 14) + 32];
float *local_buffer_ptr = (float *)cvAlignPtr(local_buffer,32);
float *buffer = local_buffer_ptr;
double angle_scale = (angle_dim - 0.51) / icv_acos_table[0];
double dist_scale = DBL_EPSILON;
int buffer_size;
int i, count, pass;
int *pghi = (int *) pgh;
int hist_size = angle_dim * dist_dim;
CvSeqReader reader1, reader2; /* external and internal readers */
if( !contour || !pgh )
return CV_NULLPTR_ERR;
if( angle_dim <= 0 || angle_dim > 180 || dist_dim <= 0 )
return CV_BADRANGE_ERR;
if( !CV_IS_SEQ_POLYGON( contour ))
return CV_BADFLAG_ERR;
memset( pgh, 0, hist_size * sizeof( pgh[0] ));
count = contour->total;
/* allocate buffer for distances */
buffer_size = count * sizeof( float );
if( buffer_size > (int)sizeof(local_buffer) - 32 )
{
buffer = (float *) cvAlloc( buffer_size );
if( !buffer )
return CV_OUTOFMEM_ERR;
}
cvStartReadSeq( contour, &reader1, 0 );
cvStartReadSeq( contour, &reader2, 0 );
/* calc & store squared edge lengths, calculate maximal distance between edges */
for( i = 0; i < count; i++ )
{
CvPoint pt1, pt2;
double dx, dy;
CV_READ_EDGE( pt1, pt2, reader1 );
dx = pt2.x - pt1.x;
dy = pt2.y - pt1.y;
buffer[i] = (float)(1./sqrt(dx * dx + dy * dy));
}
/*
do 2 passes.
First calculates maximal distance.
Second calculates histogram itself.
*/
for( pass = 1; pass <= 2; pass++ )
{
double dist_coeff = 0, angle_coeff = 0;
/* run external loop */
for( i = 0; i < count; i++ )
{
CvPoint pt1, pt2;
int dx, dy;
int dist = 0;
CV_READ_EDGE( pt1, pt2, reader1 );
dx = pt2.x - pt1.x;
dy = pt2.y - pt1.y;
if( (dx | dy) != 0 )
{
int j;
if( pass == 2 )
{
dist_coeff = buffer[i] * dist_scale;
angle_coeff = buffer[i] * (_CV_ACOS_TABLE_SIZE / 2);
}
/* run internal loop (for current edge) */
for( j = 0; j < count; j++ )
{
CvPoint pt3, pt4;
CV_READ_EDGE( pt3, pt4, reader2 );
if( i != j ) /* process edge pair */
{
int d1 = (pt3.y - pt1.y) * dx - (pt3.x - pt1.x) * dy;
int d2 = (pt4.y - pt1.y) * dx - (pt2.x - pt1.x) * dy;
int cross_flag;
int *hist_row = 0;
if( pass == 2 )
{
int dp = (pt4.x - pt3.x) * dx + (pt4.y - pt3.y) * dy;
dp = cvRound( dp * angle_coeff * buffer[j] ) +
(_CV_ACOS_TABLE_SIZE / 2);
dp = MAX( dp, 0 );
dp = MIN( dp, _CV_ACOS_TABLE_SIZE - 1 );
hist_row = pghi + dist_dim *
cvRound( icv_acos_table[dp] * angle_scale );
d1 = cvRound( d1 * dist_coeff );
d2 = cvRound( d2 * dist_coeff );
}
cross_flag = (d1 ^ d2) < 0;
d1 = CV_IABS( d1 );
d2 = CV_IABS( d2 );
if( pass == 2 )
{
if( d1 >= dist_dim )
d1 = dist_dim - 1;
if( d2 >= dist_dim )
d2 = dist_dim - 1;
if( !cross_flag )
{
if( d1 > d2 ) /* make d1 <= d2 */
{
d1 ^= d2;
d2 ^= d1;
d1 ^= d2;
}
for( ; d1 <= d2; d1++ )
hist_row[d1]++;
}
else
{
for( ; d1 >= 0; d1-- )
hist_row[d1]++;
for( ; d2 >= 0; d2-- )
hist_row[d2]++;
}
}
else /* 1st pass */
{
d1 = CV_IMAX( d1, d2 );
dist = CV_IMAX( dist, d1 );
}
} /* end of processing of edge pair */
} /* end of internal loop */
if( pass == 1 )
{
double scale = dist * buffer[i];
dist_scale = MAX( dist_scale, scale );
}
}
} /* end of external loop */
if( pass == 1 )
{
dist_scale = (dist_dim - 0.51) / dist_scale;
}
} /* end of pass on loops */
/* convert hist to floats */
for( i = 0; i < hist_size; i++ )
{
((float *) pghi)[i] = (float) pghi[i];
}
if( buffer != local_buffer_ptr )
cvFree( &buffer );
return CV_OK;
}
CV_IMPL void
cvCalcPGH( const CvSeq * contour, CvHistogram * hist )
{
CV_FUNCNAME( "cvCalcPGH" );
__BEGIN__;
int size[CV_MAX_DIM];
int dims;
if( !CV_IS_HIST(hist))
CV_ERROR( CV_StsBadArg, "The histogram header is invalid " );
if( CV_IS_SPARSE_HIST( hist ))
CV_ERROR( CV_StsUnsupportedFormat, "Sparse histogram are not supported" );
dims = cvGetDims( hist->bins, size );
if( dims != 2 )
CV_ERROR( CV_StsBadSize, "The histogram must be two-dimensional" );
if( !CV_IS_SEQ_POLYGON( contour ) || CV_SEQ_ELTYPE( contour ) != CV_32SC2 )
CV_ERROR( CV_StsUnsupportedFormat, "The contour is not valid or the point type is not supported" );
IPPI_CALL( icvCalcPGH( contour, ((CvMatND*)(hist->bins))->data.fl, size[0], size[1] ));
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,378 @@
/*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*/
#include "_cv.h"
/* POSIT structure */
struct CvPOSITObject
{
int N;
float* inv_matr;
float* obj_vecs;
float* img_vecs;
};
static void icvPseudoInverse3D( float *a, float *b, int n, int method );
static CvStatus icvCreatePOSITObject( CvPoint3D32f *points,
int numPoints,
CvPOSITObject **ppObject )
{
int i;
/* Compute size of required memory */
/* buffer for inverse matrix = N*3*float */
/* buffer for storing weakImagePoints = numPoints * 2 * float */
/* buffer for storing object vectors = N*3*float */
/* buffer for storing image vectors = N*2*float */
int N = numPoints - 1;
int inv_matr_size = N * 3 * sizeof( float );
int obj_vec_size = inv_matr_size;
int img_vec_size = N * 2 * sizeof( float );
CvPOSITObject *pObject;
/* check bad arguments */
if( points == NULL )
return CV_NULLPTR_ERR;
if( numPoints < 4 )
return CV_BADSIZE_ERR;
if( ppObject == NULL )
return CV_NULLPTR_ERR;
/* memory allocation */
pObject = (CvPOSITObject *) cvAlloc( sizeof( CvPOSITObject ) +
inv_matr_size + obj_vec_size + img_vec_size );
if( !pObject )
return CV_OUTOFMEM_ERR;
/* part the memory between all structures */
pObject->N = N;
pObject->inv_matr = (float *) ((char *) pObject + sizeof( CvPOSITObject ));
pObject->obj_vecs = (float *) ((char *) (pObject->inv_matr) + inv_matr_size);
pObject->img_vecs = (float *) ((char *) (pObject->obj_vecs) + obj_vec_size);
/****************************************************************************************\
* Construct object vectors from object points *
\****************************************************************************************/
for( i = 0; i < numPoints - 1; i++ )
{
pObject->obj_vecs[i] = points[i + 1].x - points[0].x;
pObject->obj_vecs[N + i] = points[i + 1].y - points[0].y;
pObject->obj_vecs[2 * N + i] = points[i + 1].z - points[0].z;
}
/****************************************************************************************\
* Compute pseudoinverse matrix *
\****************************************************************************************/
icvPseudoInverse3D( pObject->obj_vecs, pObject->inv_matr, N, 0 );
*ppObject = pObject;
return CV_NO_ERR;
}
static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
float focalLength, CvTermCriteria criteria,
CvMatr32f rotation, CvVect32f translation )
{
int i, j, k;
int count = 0, converged = 0;
float inorm, jnorm, invInorm, invJnorm, invScale, scale = 0, inv_Z = 0;
float diff = (float)criteria.epsilon;
float inv_focalLength = 1 / focalLength;
/* init variables */
int N = pObject->N;
float *objectVectors = pObject->obj_vecs;
float *invMatrix = pObject->inv_matr;
float *imgVectors = pObject->img_vecs;
/* Check bad arguments */
if( imagePoints == NULL )
return CV_NULLPTR_ERR;
if( pObject == NULL )
return CV_NULLPTR_ERR;
if( focalLength <= 0 )
return CV_BADFACTOR_ERR;
if( !rotation )
return CV_NULLPTR_ERR;
if( !translation )
return CV_NULLPTR_ERR;
if( (criteria.type == 0) || (criteria.type > (CV_TERMCRIT_ITER | CV_TERMCRIT_EPS)))
return CV_BADFLAG_ERR;
if( (criteria.type & CV_TERMCRIT_EPS) && criteria.epsilon < 0 )
return CV_BADFACTOR_ERR;
if( (criteria.type & CV_TERMCRIT_ITER) && criteria.max_iter <= 0 )
return CV_BADFACTOR_ERR;
while( !converged )
{
if( count == 0 )
{
/* subtract out origin to get image vectors */
for( i = 0; i < N; i++ )
{
imgVectors[i] = imagePoints[i + 1].x - imagePoints[0].x;
imgVectors[N + i] = imagePoints[i + 1].y - imagePoints[0].y;
}
}
else
{
diff = 0;
/* Compute new SOP (scaled orthograthic projection) image from pose */
for( i = 0; i < N; i++ )
{
/* objectVector * k */
float old;
float tmp = objectVectors[i] * rotation[6] /*[2][0]*/ +
objectVectors[N + i] * rotation[7] /*[2][1]*/ +
objectVectors[2 * N + i] * rotation[8] /*[2][2]*/;
tmp *= inv_Z;
tmp += 1;
old = imgVectors[i];
imgVectors[i] = imagePoints[i + 1].x * tmp - imagePoints[0].x;
diff = MAX( diff, (float) fabs( imgVectors[i] - old ));
old = imgVectors[N + i];
imgVectors[N + i] = imagePoints[i + 1].y * tmp - imagePoints[0].y;
diff = MAX( diff, (float) fabs( imgVectors[N + i] - old ));
}
}
/* calculate I and J vectors */
for( i = 0; i < 2; i++ )
{
for( j = 0; j < 3; j++ )
{
rotation[3*i+j] /*[i][j]*/ = 0;
for( k = 0; k < N; k++ )
{
rotation[3*i+j] /*[i][j]*/ += invMatrix[j * N + k] * imgVectors[i * N + k];
}
}
}
inorm = rotation[0] /*[0][0]*/ * rotation[0] /*[0][0]*/ +
rotation[1] /*[0][1]*/ * rotation[1] /*[0][1]*/ +
rotation[2] /*[0][2]*/ * rotation[2] /*[0][2]*/;
jnorm = rotation[3] /*[1][0]*/ * rotation[3] /*[1][0]*/ +
rotation[4] /*[1][1]*/ * rotation[4] /*[1][1]*/ +
rotation[5] /*[1][2]*/ * rotation[5] /*[1][2]*/;
invInorm = cvInvSqrt( inorm );
invJnorm = cvInvSqrt( jnorm );
inorm *= invInorm;
jnorm *= invJnorm;
rotation[0] /*[0][0]*/ *= invInorm;
rotation[1] /*[0][1]*/ *= invInorm;
rotation[2] /*[0][2]*/ *= invInorm;
rotation[3] /*[1][0]*/ *= invJnorm;
rotation[4] /*[1][1]*/ *= invJnorm;
rotation[5] /*[1][2]*/ *= invJnorm;
/* row2 = row0 x row1 (cross product) */
rotation[6] /*->m[2][0]*/ = rotation[1] /*->m[0][1]*/ * rotation[5] /*->m[1][2]*/ -
rotation[2] /*->m[0][2]*/ * rotation[4] /*->m[1][1]*/;
rotation[7] /*->m[2][1]*/ = rotation[2] /*->m[0][2]*/ * rotation[3] /*->m[1][0]*/ -
rotation[0] /*->m[0][0]*/ * rotation[5] /*->m[1][2]*/;
rotation[8] /*->m[2][2]*/ = rotation[0] /*->m[0][0]*/ * rotation[4] /*->m[1][1]*/ -
rotation[1] /*->m[0][1]*/ * rotation[3] /*->m[1][0]*/;
scale = (inorm + jnorm) / 2.0f;
inv_Z = scale * inv_focalLength;
count++;
converged = ((criteria.type & CV_TERMCRIT_EPS) && (diff < criteria.epsilon));
converged |= ((criteria.type & CV_TERMCRIT_ITER) && (count == criteria.max_iter));
}
invScale = 1 / scale;
translation[0] = imagePoints[0].x * invScale;
translation[1] = imagePoints[0].y * invScale;
translation[2] = 1 / inv_Z;
return CV_NO_ERR;
}
static CvStatus icvReleasePOSITObject( CvPOSITObject ** ppObject )
{
cvFree( ppObject );
return CV_NO_ERR;
}
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvPseudoInverse3D
// Purpose: Pseudoinverse N x 3 matrix N >= 3
// Context:
// Parameters:
// a - input matrix
// b - pseudoinversed a
// n - number of rows in a
// method - if 0, then b = inv(transpose(a)*a) * transpose(a)
// if 1, then SVD used.
// Returns:
// Notes: Both matrix are stored by n-dimensional vectors.
// Now only method == 0 supported.
//F*/
void
icvPseudoInverse3D( float *a, float *b, int n, int method )
{
int k;
if( method == 0 )
{
float ata00 = 0;
float ata11 = 0;
float ata22 = 0;
float ata01 = 0;
float ata02 = 0;
float ata12 = 0;
float det = 0;
/* compute matrix ata = transpose(a) * a */
for( k = 0; k < n; k++ )
{
float a0 = a[k];
float a1 = a[n + k];
float a2 = a[2 * n + k];
ata00 += a0 * a0;
ata11 += a1 * a1;
ata22 += a2 * a2;
ata01 += a0 * a1;
ata02 += a0 * a2;
ata12 += a1 * a2;
}
/* inverse matrix ata */
{
float inv_det;
float p00 = ata11 * ata22 - ata12 * ata12;
float p01 = -(ata01 * ata22 - ata12 * ata02);
float p02 = ata12 * ata01 - ata11 * ata02;
float p11 = ata00 * ata22 - ata02 * ata02;
float p12 = -(ata00 * ata12 - ata01 * ata02);
float p22 = ata00 * ata11 - ata01 * ata01;
det += ata00 * p00;
det += ata01 * p01;
det += ata02 * p02;
inv_det = 1 / det;
/* compute resultant matrix */
for( k = 0; k < n; k++ )
{
float a0 = a[k];
float a1 = a[n + k];
float a2 = a[2 * n + k];
b[k] = (p00 * a0 + p01 * a1 + p02 * a2) * inv_det;
b[n + k] = (p01 * a0 + p11 * a1 + p12 * a2) * inv_det;
b[2 * n + k] = (p02 * a0 + p12 * a1 + p22 * a2) * inv_det;
}
}
}
/*if ( method == 1 )
{
}
*/
return;
}
CV_IMPL CvPOSITObject *
cvCreatePOSITObject( CvPoint3D32f * points, int numPoints )
{
CvPOSITObject *pObject = 0;
CV_FUNCNAME( "cvCreatePOSITObject" );
__BEGIN__;
IPPI_CALL( icvCreatePOSITObject( points, numPoints, &pObject ));
__END__;
return pObject;
}
CV_IMPL void
cvPOSIT( CvPOSITObject * pObject, CvPoint2D32f * imagePoints,
double focalLength, CvTermCriteria criteria,
CvMatr32f rotation, CvVect32f translation )
{
CV_FUNCNAME( "cvPOSIT" );
__BEGIN__;
IPPI_CALL( icvPOSIT( pObject, imagePoints,(float) focalLength, criteria,
rotation, translation ));
__END__;
}
CV_IMPL void
cvReleasePOSITObject( CvPOSITObject ** ppObject )
{
CV_FUNCNAME( "cvReleasePOSITObject" );
__BEGIN__;
IPPI_CALL( icvReleasePOSITObject( ppObject ));
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,44 @@
/*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*/
#include "_cv.h"
/* End of file. */

View File

@@ -0,0 +1,474 @@
/*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*/
#include "_cv.h"
typedef struct
{
int bottom;
int left;
float height;
float width;
float base_a;
float base_b;
}
icvMinAreaState;
#define CV_CALIPERS_MAXHEIGHT 0
#define CV_CALIPERS_MINAREARECT 1
#define CV_CALIPERS_MAXDIST 2
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvRotatingCalipers
// Purpose:
// Rotating calipers algorithm with some applications
//
// Context:
// Parameters:
// points - convex hull vertices ( any orientation )
// n - number of vertices
// mode - concrete application of algorithm
// can be CV_CALIPERS_MAXDIST or
// CV_CALIPERS_MINAREARECT
// left, bottom, right, top - indexes of extremal points
// out - output info.
// In case CV_CALIPERS_MAXDIST it points to float value -
// maximal height of polygon.
// In case CV_CALIPERS_MINAREARECT
// ((CvPoint2D32f*)out)[0] - corner
// ((CvPoint2D32f*)out)[1] - vector1
// ((CvPoint2D32f*)out)[0] - corner2
//
// ^
// |
// vector2 |
// |
// |____________\
// corner /
// vector1
//
// Returns:
// Notes:
//F*/
/* we will use usual cartesian coordinates */
static void
icvRotatingCalipers( CvPoint2D32f* points, int n, int mode, float* out )
{
float minarea = FLT_MAX;
float max_dist = 0;
char buffer[32];
int i, k;
CvPoint2D32f* vect = (CvPoint2D32f*)cvAlloc( n * sizeof(vect[0]) );
float* inv_vect_length = (float*)cvAlloc( n * sizeof(inv_vect_length[0]) );
int left = 0, bottom = 0, right = 0, top = 0;
int seq[4] = { -1, -1, -1, -1 };
/* rotating calipers sides will always have coordinates
(a,b) (-b,a) (-a,-b) (b, -a)
*/
/* this is a first base bector (a,b) initialized by (1,0) */
float orientation = 0;
float base_a;
float base_b = 0;
float left_x, right_x, top_y, bottom_y;
CvPoint2D32f pt0 = points[0];
left_x = right_x = pt0.x;
top_y = bottom_y = pt0.y;
for( i = 0; i < n; i++ )
{
double dx, dy;
if( pt0.x < left_x )
left_x = pt0.x, left = i;
if( pt0.x > right_x )
right_x = pt0.x, right = i;
if( pt0.y > top_y )
top_y = pt0.y, top = i;
if( pt0.y < bottom_y )
bottom_y = pt0.y, bottom = i;
CvPoint2D32f pt = points[(i+1) & (i+1 < n ? -1 : 0)];
dx = pt.x - pt0.x;
dy = pt.y - pt0.y;
vect[i].x = (float)dx;
vect[i].y = (float)dy;
inv_vect_length[i] = (float)(1./sqrt(dx*dx + dy*dy));
pt0 = pt;
}
//cvbInvSqrt( inv_vect_length, inv_vect_length, n );
/* find convex hull orientation */
{
double ax = vect[n-1].x;
double ay = vect[n-1].y;
for( i = 0; i < n; i++ )
{
double bx = vect[i].x;
double by = vect[i].y;
double convexity = ax * by - ay * bx;
if( convexity != 0 )
{
orientation = (convexity > 0) ? 1.f : (-1.f);
break;
}
ax = bx;
ay = by;
}
assert( orientation != 0 );
}
base_a = orientation;
/*****************************************************************************************/
/* init calipers position */
seq[0] = bottom;
seq[1] = right;
seq[2] = top;
seq[3] = left;
/*****************************************************************************************/
/* Main loop - evaluate angles and rotate calipers */
/* all of edges will be checked while rotating calipers by 90 degrees */
for( k = 0; k < n; k++ )
{
/* sinus of minimal angle */
/*float sinus;*/
/* compute cosine of angle between calipers side and polygon edge */
/* dp - dot product */
float dp0 = base_a * vect[seq[0]].x + base_b * vect[seq[0]].y;
float dp1 = -base_b * vect[seq[1]].x + base_a * vect[seq[1]].y;
float dp2 = -base_a * vect[seq[2]].x - base_b * vect[seq[2]].y;
float dp3 = base_b * vect[seq[3]].x - base_a * vect[seq[3]].y;
float cosalpha = dp0 * inv_vect_length[seq[0]];
float maxcos = cosalpha;
/* number of calipers edges, that has minimal angle with edge */
int main_element = 0;
/* choose minimal angle */
cosalpha = dp1 * inv_vect_length[seq[1]];
maxcos = (cosalpha > maxcos) ? (main_element = 1, cosalpha) : maxcos;
cosalpha = dp2 * inv_vect_length[seq[2]];
maxcos = (cosalpha > maxcos) ? (main_element = 2, cosalpha) : maxcos;
cosalpha = dp3 * inv_vect_length[seq[3]];
maxcos = (cosalpha > maxcos) ? (main_element = 3, cosalpha) : maxcos;
/*rotate calipers*/
{
//get next base
int pindex = seq[main_element];
float lead_x = vect[pindex].x*inv_vect_length[pindex];
float lead_y = vect[pindex].y*inv_vect_length[pindex];
switch( main_element )
{
case 0:
base_a = lead_x;
base_b = lead_y;
break;
case 1:
base_a = lead_y;
base_b = -lead_x;
break;
case 2:
base_a = -lead_x;
base_b = -lead_y;
break;
case 3:
base_a = -lead_y;
base_b = lead_x;
break;
default: assert(0);
}
}
/* change base point of main edge */
seq[main_element] += 1;
seq[main_element] = (seq[main_element] == n) ? 0 : seq[main_element];
switch (mode)
{
case CV_CALIPERS_MAXHEIGHT:
{
/* now main element lies on edge alligned to calipers side */
/* find opposite element i.e. transform */
/* 0->2, 1->3, 2->0, 3->1 */
int opposite_el = main_element ^ 2;
float dx = points[seq[opposite_el]].x - points[seq[main_element]].x;
float dy = points[seq[opposite_el]].y - points[seq[main_element]].y;
float dist;
if( main_element & 1 )
dist = (float)fabs(dx * base_a + dy * base_b);
else
dist = (float)fabs(dx * (-base_b) + dy * base_a);
if( dist > max_dist )
max_dist = dist;
break;
}
case CV_CALIPERS_MINAREARECT:
/* find area of rectangle */
{
float height;
float area;
/* find vector left-right */
float dx = points[seq[1]].x - points[seq[3]].x;
float dy = points[seq[1]].y - points[seq[3]].y;
/* dotproduct */
float width = dx * base_a + dy * base_b;
/* find vector left-right */
dx = points[seq[2]].x - points[seq[0]].x;
dy = points[seq[2]].y - points[seq[0]].y;
/* dotproduct */
height = -dx * base_b + dy * base_a;
area = width * height;
if( area <= minarea )
{
float *buf = (float *) buffer;
minarea = area;
/* leftist point */
((int *) buf)[0] = seq[3];
buf[1] = base_a;
buf[2] = width;
buf[3] = base_b;
buf[4] = height;
/* bottom point */
((int *) buf)[5] = seq[0];
buf[6] = area;
}
break;
}
} /*switch */
} /* for */
switch (mode)
{
case CV_CALIPERS_MINAREARECT:
{
float *buf = (float *) buffer;
float A1 = buf[1];
float B1 = buf[3];
float A2 = -buf[3];
float B2 = buf[1];
float C1 = A1 * points[((int *) buf)[0]].x + points[((int *) buf)[0]].y * B1;
float C2 = A2 * points[((int *) buf)[5]].x + points[((int *) buf)[5]].y * B2;
float idet = 1.f / (A1 * B2 - A2 * B1);
float px = (C1 * B2 - C2 * B1) * idet;
float py = (A1 * C2 - A2 * C1) * idet;
out[0] = px;
out[1] = py;
out[2] = A1 * buf[2];
out[3] = B1 * buf[2];
out[4] = A2 * buf[4];
out[5] = B2 * buf[4];
}
break;
case CV_CALIPERS_MAXHEIGHT:
{
out[0] = max_dist;
}
break;
}
cvFree( &vect );
cvFree( &inv_vect_length );
}
CV_IMPL CvBox2D
cvMinAreaRect2( const CvArr* array, CvMemStorage* storage )
{
CvMemStorage* temp_storage = 0;
CvBox2D box;
CvPoint2D32f* points = 0;
CV_FUNCNAME( "cvMinAreaRect2" );
memset(&box, 0, sizeof(box));
__BEGIN__;
int i, n;
CvSeqReader reader;
CvContour contour_header;
CvSeqBlock block;
CvSeq* ptseq = (CvSeq*)array;
CvPoint2D32f out[3];
if( CV_IS_SEQ(ptseq) )
{
if( !CV_IS_SEQ_POINT_SET(ptseq) &&
(CV_SEQ_KIND(ptseq) != CV_SEQ_KIND_CURVE || !CV_IS_SEQ_CONVEX(ptseq) ||
CV_SEQ_ELTYPE(ptseq) != CV_SEQ_ELTYPE_PPOINT ))
CV_ERROR( CV_StsUnsupportedFormat,
"Input sequence must consist of 2d points or pointers to 2d points" );
if( !storage )
storage = ptseq->storage;
}
else
{
CV_CALL( ptseq = cvPointSeqFromMat(
CV_SEQ_KIND_GENERIC, array, &contour_header, &block ));
}
if( storage )
{
CV_CALL( temp_storage = cvCreateChildMemStorage( storage ));
}
else
{
CV_CALL( temp_storage = cvCreateMemStorage(1 << 10));
}
if( !CV_IS_SEQ_CONVEX( ptseq ))
{
CV_CALL( ptseq = cvConvexHull2( ptseq, temp_storage, CV_CLOCKWISE, 1 ));
}
else if( !CV_IS_SEQ_POINT_SET( ptseq ))
{
CvSeqWriter writer;
if( !CV_IS_SEQ(ptseq->v_prev) || !CV_IS_SEQ_POINT_SET(ptseq->v_prev))
CV_ERROR( CV_StsBadArg,
"Convex hull must have valid pointer to point sequence stored in v_prev" );
cvStartReadSeq( ptseq, &reader );
cvStartWriteSeq( CV_SEQ_KIND_CURVE|CV_SEQ_FLAG_CONVEX|CV_SEQ_ELTYPE(ptseq->v_prev),
sizeof(CvContour), CV_ELEM_SIZE(ptseq->v_prev->flags),
temp_storage, &writer );
for( i = 0; i < ptseq->total; i++ )
{
CvPoint pt = **(CvPoint**)(reader.ptr);
CV_WRITE_SEQ_ELEM( pt, writer );
}
ptseq = cvEndWriteSeq( &writer );
}
n = ptseq->total;
CV_CALL( points = (CvPoint2D32f*)cvAlloc( n*sizeof(points[0]) ));
cvStartReadSeq( ptseq, &reader );
if( CV_SEQ_ELTYPE( ptseq ) == CV_32SC2 )
{
for( i = 0; i < n; i++ )
{
CvPoint pt;
CV_READ_SEQ_ELEM( pt, reader );
points[i].x = (float)pt.x;
points[i].y = (float)pt.y;
}
}
else
{
for( i = 0; i < n; i++ )
{
CV_READ_SEQ_ELEM( points[i], reader );
}
}
if( n > 2 )
{
icvRotatingCalipers( points, n, CV_CALIPERS_MINAREARECT, (float*)out );
box.center.x = out[0].x + (out[1].x + out[2].x)*0.5f;
box.center.y = out[0].y + (out[1].y + out[2].y)*0.5f;
box.size.height = (float)sqrt((double)out[1].x*out[1].x + (double)out[1].y*out[1].y);
box.size.width = (float)sqrt((double)out[2].x*out[2].x + (double)out[2].y*out[2].y);
box.angle = (float)atan2( -(double)out[1].y, (double)out[1].x );
}
else if( n == 2 )
{
box.center.x = (points[0].x + points[1].x)*0.5f;
box.center.y = (points[0].y + points[1].y)*0.5f;
double dx = points[1].x - points[0].x;
double dy = points[1].y - points[0].y;
box.size.height = (float)sqrt(dx*dx + dy*dy);
box.size.width = 0;
box.angle = (float)atan2( -dy, dx );
}
else
{
if( n == 1 )
box.center = points[0];
}
box.angle = (float)(box.angle*180/CV_PI);
__END__;
cvReleaseMemStorage( &temp_storage );
cvFree( &points );
return box;
}

View File

@@ -0,0 +1,894 @@
/*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*/
#include "_cv.h"
/**************************************************************************************\
* line samplers *
\**************************************************************************************/
CV_IMPL int
cvSampleLine( const void* img, CvPoint pt1, CvPoint pt2,
void* _buffer, int connectivity )
{
int count = -1;
CV_FUNCNAME( "cvSampleLine" );
__BEGIN__;
int i, coi = 0, pix_size;
CvMat stub, *mat = (CvMat*)img;
CvLineIterator iterator;
uchar* buffer = (uchar*)_buffer;
CV_CALL( mat = cvGetMat( mat, &stub, &coi ));
if( coi != 0 )
CV_ERROR( CV_BadCOI, "" );
if( !buffer )
CV_ERROR( CV_StsNullPtr, "" );
CV_CALL( count = cvInitLineIterator( mat, pt1, pt2, &iterator, connectivity ));
pix_size = CV_ELEM_SIZE(mat->type);
for( i = 0; i < count; i++ )
{
CV_MEMCPY_AUTO( buffer, iterator.ptr, pix_size );
buffer += pix_size;
CV_NEXT_LINE_POINT( iterator );
}
__END__;
return count;
}
static const void*
icvAdjustRect( const void* srcptr, int src_step, int pix_size,
CvSize src_size, CvSize win_size,
CvPoint ip, CvRect* pRect )
{
CvRect rect;
const char* src = (const char*)srcptr;
if( ip.x >= 0 )
{
src += ip.x*pix_size;
rect.x = 0;
}
else
{
rect.x = -ip.x;
if( rect.x > win_size.width )
rect.x = win_size.width;
}
if( ip.x + win_size.width < src_size.width )
rect.width = win_size.width;
else
{
rect.width = src_size.width - ip.x - 1;
if( rect.width < 0 )
{
src += rect.width*pix_size;
rect.width = 0;
}
assert( rect.width <= win_size.width );
}
if( ip.y >= 0 )
{
src += ip.y * src_step;
rect.y = 0;
}
else
rect.y = -ip.y;
if( ip.y + win_size.height < src_size.height )
rect.height = win_size.height;
else
{
rect.height = src_size.height - ip.y - 1;
if( rect.height < 0 )
{
src += rect.height*src_step;
rect.height = 0;
}
}
*pRect = rect;
return src - rect.x*pix_size;
}
#define ICV_DEF_GET_RECT_SUB_PIX_FUNC( flavor, srctype, dsttype, worktype, \
cast_macro, scale_macro, cast_macro2 )\
CvStatus CV_STDCALL icvGetRectSubPix_##flavor##_C1R \
( const srctype* src, int src_step, CvSize src_size, \
dsttype* dst, int dst_step, CvSize win_size, CvPoint2D32f center ) \
{ \
CvPoint ip; \
worktype a11, a12, a21, a22, b1, b2; \
float a, b; \
int i, j; \
\
center.x -= (win_size.width-1)*0.5f; \
center.y -= (win_size.height-1)*0.5f; \
\
ip.x = cvFloor( center.x ); \
ip.y = cvFloor( center.y ); \
\
a = center.x - ip.x; \
b = center.y - ip.y; \
a11 = scale_macro((1.f-a)*(1.f-b)); \
a12 = scale_macro(a*(1.f-b)); \
a21 = scale_macro((1.f-a)*b); \
a22 = scale_macro(a*b); \
b1 = scale_macro(1.f - b); \
b2 = scale_macro(b); \
\
src_step /= sizeof(src[0]); \
dst_step /= sizeof(dst[0]); \
\
if( 0 <= ip.x && ip.x + win_size.width < src_size.width && \
0 <= ip.y && ip.y + win_size.height < src_size.height ) \
{ \
/* extracted rectangle is totally inside the image */ \
src += ip.y * src_step + ip.x; \
\
if( icvCopySubpix_##flavor##_C1R_p && \
icvCopySubpix_##flavor##_C1R_p( src, src_step*sizeof(src[0]), \
dst, dst_step*sizeof(dst[0]), \
win_size, a, b ) >= 0 ) \
return CV_OK; \
\
for( i = 0; i < win_size.height; i++, src += src_step, \
dst += dst_step ) \
{ \
for( j = 0; j <= win_size.width - 2; j += 2 ) \
{ \
worktype s0 = cast_macro(src[j])*a11 + \
cast_macro(src[j+1])*a12 + \
cast_macro(src[j+src_step])*a21 + \
cast_macro(src[j+src_step+1])*a22; \
worktype s1 = cast_macro(src[j+1])*a11 + \
cast_macro(src[j+2])*a12 + \
cast_macro(src[j+src_step+1])*a21 + \
cast_macro(src[j+src_step+2])*a22; \
\
dst[j] = (dsttype)cast_macro2(s0); \
dst[j+1] = (dsttype)cast_macro2(s1); \
} \
\
for( ; j < win_size.width; j++ ) \
{ \
worktype s0 = cast_macro(src[j])*a11 + \
cast_macro(src[j+1])*a12 + \
cast_macro(src[j+src_step])*a21 + \
cast_macro(src[j+src_step+1])*a22; \
\
dst[j] = (dsttype)cast_macro2(s0); \
} \
} \
} \
else \
{ \
CvRect r; \
\
src = (const srctype*)icvAdjustRect( src, src_step*sizeof(*src), \
sizeof(*src), src_size, win_size,ip, &r); \
\
for( i = 0; i < win_size.height; i++, dst += dst_step ) \
{ \
const srctype *src2 = src + src_step; \
\
if( i < r.y || i >= r.height ) \
src2 -= src_step; \
\
for( j = 0; j < r.x; j++ ) \
{ \
worktype s0 = cast_macro(src[r.x])*b1 + \
cast_macro(src2[r.x])*b2; \
\
dst[j] = (dsttype)cast_macro2(s0); \
} \
\
for( ; j < r.width; j++ ) \
{ \
worktype s0 = cast_macro(src[j])*a11 + \
cast_macro(src[j+1])*a12 + \
cast_macro(src2[j])*a21 + \
cast_macro(src2[j+1])*a22; \
\
dst[j] = (dsttype)cast_macro2(s0); \
} \
\
for( ; j < win_size.width; j++ ) \
{ \
worktype s0 = cast_macro(src[r.width])*b1 + \
cast_macro(src2[r.width])*b2; \
\
dst[j] = (dsttype)cast_macro2(s0); \
} \
\
if( i < r.height ) \
src = src2; \
} \
} \
\
return CV_OK; \
}
#define ICV_DEF_GET_RECT_SUB_PIX_FUNC_C3( flavor, srctype, dsttype, worktype, \
cast_macro, scale_macro, mul_macro )\
static CvStatus CV_STDCALL icvGetRectSubPix_##flavor##_C3R \
( const srctype* src, int src_step, CvSize src_size, \
dsttype* dst, int dst_step, CvSize win_size, CvPoint2D32f center ) \
{ \
CvPoint ip; \
worktype a, b; \
int i, j; \
\
center.x -= (win_size.width-1)*0.5f; \
center.y -= (win_size.height-1)*0.5f; \
\
ip.x = cvFloor( center.x ); \
ip.y = cvFloor( center.y ); \
\
a = scale_macro( center.x - ip.x ); \
b = scale_macro( center.y - ip.y ); \
\
src_step /= sizeof( src[0] ); \
dst_step /= sizeof( dst[0] ); \
\
if( 0 <= ip.x && ip.x + win_size.width < src_size.width && \
0 <= ip.y && ip.y + win_size.height < src_size.height ) \
{ \
/* extracted rectangle is totally inside the image */ \
src += ip.y * src_step + ip.x*3; \
\
for( i = 0; i < win_size.height; i++, src += src_step, \
dst += dst_step ) \
{ \
for( j = 0; j < win_size.width; j++ ) \
{ \
worktype s0 = cast_macro(src[j*3]); \
worktype s1 = cast_macro(src[j*3 + src_step]); \
s0 += mul_macro( a, (cast_macro(src[j*3+3]) - s0)); \
s1 += mul_macro( a, (cast_macro(src[j*3+3+src_step]) - s1));\
dst[j*3] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
\
s0 = cast_macro(src[j*3+1]); \
s1 = cast_macro(src[j*3+1 + src_step]); \
s0 += mul_macro( a, (cast_macro(src[j*3+4]) - s0)); \
s1 += mul_macro( a, (cast_macro(src[j*3+4+src_step]) - s1));\
dst[j*3+1] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
\
s0 = cast_macro(src[j*3+2]); \
s1 = cast_macro(src[j*3+2 + src_step]); \
s0 += mul_macro( a, (cast_macro(src[j*3+5]) - s0)); \
s1 += mul_macro( a, (cast_macro(src[j*3+5+src_step]) - s1));\
dst[j*3+2] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
} \
} \
} \
else \
{ \
CvRect r; \
\
src = (const srctype*)icvAdjustRect( src, src_step*sizeof(*src), \
sizeof(*src)*3, src_size, win_size, ip, &r ); \
\
for( i = 0; i < win_size.height; i++, dst += dst_step ) \
{ \
const srctype *src2 = src + src_step; \
\
if( i < r.y || i >= r.height ) \
src2 -= src_step; \
\
for( j = 0; j < r.x; j++ ) \
{ \
worktype s0 = cast_macro(src[r.x*3]); \
worktype s1 = cast_macro(src2[r.x*3]); \
dst[j*3] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
\
s0 = cast_macro(src[r.x*3+1]); \
s1 = cast_macro(src2[r.x*3+1]); \
dst[j*3+1] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
\
s0 = cast_macro(src[r.x*3+2]); \
s1 = cast_macro(src2[r.x*3+2]); \
dst[j*3+2] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
} \
\
for( ; j < r.width; j++ ) \
{ \
worktype s0 = cast_macro(src[j*3]); \
worktype s1 = cast_macro(src2[j*3]); \
s0 += mul_macro( a, (cast_macro(src[j*3 + 3]) - s0)); \
s1 += mul_macro( a, (cast_macro(src2[j*3 + 3]) - s1)); \
dst[j*3] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
\
s0 = cast_macro(src[j*3+1]); \
s1 = cast_macro(src2[j*3+1]); \
s0 += mul_macro( a, (cast_macro(src[j*3 + 4]) - s0)); \
s1 += mul_macro( a, (cast_macro(src2[j*3 + 4]) - s1)); \
dst[j*3+1] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
\
s0 = cast_macro(src[j*3+2]); \
s1 = cast_macro(src2[j*3+2]); \
s0 += mul_macro( a, (cast_macro(src[j*3 + 5]) - s0)); \
s1 += mul_macro( a, (cast_macro(src2[j*3 + 5]) - s1)); \
dst[j*3+2] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
} \
\
for( ; j < win_size.width; j++ ) \
{ \
worktype s0 = cast_macro(src[r.width*3]); \
worktype s1 = cast_macro(src2[r.width*3]); \
dst[j*3] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
\
s0 = cast_macro(src[r.width*3+1]); \
s1 = cast_macro(src2[r.width*3+1]); \
dst[j*3+1] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
\
s0 = cast_macro(src[r.width*3+2]); \
s1 = cast_macro(src2[r.width*3+2]); \
dst[j*3+2] = (dsttype)(s0 + mul_macro( b, (s1 - s0))); \
} \
\
if( i < r.height ) \
src = src2; \
} \
} \
\
return CV_OK; \
}
CvStatus CV_STDCALL icvGetRectSubPix_8u32f_C1R
( const uchar* src, int src_step, CvSize src_size,
float* dst, int dst_step, CvSize win_size, CvPoint2D32f center )
{
CvPoint ip;
float a12, a22, b1, b2;
float a, b;
double s = 0;
int i, j;
center.x -= (win_size.width-1)*0.5f;
center.y -= (win_size.height-1)*0.5f;
ip.x = cvFloor( center.x );
ip.y = cvFloor( center.y );
if( win_size.width <= 0 || win_size.height <= 0 )
return CV_BADRANGE_ERR;
a = center.x - ip.x;
b = center.y - ip.y;
a = MAX(a,0.0001f);
a12 = a*(1.f-b);
a22 = a*b;
b1 = 1.f - b;
b2 = b;
s = (1. - a)/a;
src_step /= sizeof(src[0]);
dst_step /= sizeof(dst[0]);
if( 0 <= ip.x && ip.x + win_size.width < src_size.width &&
0 <= ip.y && ip.y + win_size.height < src_size.height )
{
// extracted rectangle is totally inside the image
src += ip.y * src_step + ip.x;
#if 0
if( icvCopySubpix_8u32f_C1R_p &&
icvCopySubpix_8u32f_C1R_p( src, src_step, dst,
dst_step*sizeof(dst[0]), win_size, a, b ) >= 0 )
return CV_OK;
#endif
for( ; win_size.height--; src += src_step, dst += dst_step )
{
float prev = (1 - a)*(b1*CV_8TO32F(src[0]) + b2*CV_8TO32F(src[src_step]));
for( j = 0; j < win_size.width; j++ )
{
float t = a12*CV_8TO32F(src[j+1]) + a22*CV_8TO32F(src[j+1+src_step]);
dst[j] = prev + t;
prev = (float)(t*s);
}
}
}
else
{
CvRect r;
src = (const uchar*)icvAdjustRect( src, src_step*sizeof(*src),
sizeof(*src), src_size, win_size,ip, &r);
for( i = 0; i < win_size.height; i++, dst += dst_step )
{
const uchar *src2 = src + src_step;
if( i < r.y || i >= r.height )
src2 -= src_step;
for( j = 0; j < r.x; j++ )
{
float s0 = CV_8TO32F(src[r.x])*b1 +
CV_8TO32F(src2[r.x])*b2;
dst[j] = (float)(s0);
}
if( j < r.width )
{
float prev = (1 - a)*(b1*CV_8TO32F(src[j]) + b2*CV_8TO32F(src2[j]));
for( ; j < r.width; j++ )
{
float t = a12*CV_8TO32F(src[j+1]) + a22*CV_8TO32F(src2[j+1]);
dst[j] = prev + t;
prev = (float)(t*s);
}
}
for( ; j < win_size.width; j++ )
{
float s0 = CV_8TO32F(src[r.width])*b1 +
CV_8TO32F(src2[r.width])*b2;
dst[j] = (float)(s0);
}
if( i < r.height )
src = src2;
}
}
return CV_OK;
}
#define ICV_SHIFT 16
#define ICV_SCALE(x) cvRound((x)*(1 << ICV_SHIFT))
#define ICV_MUL_SCALE(x,y) (((x)*(y) + (1 << (ICV_SHIFT-1))) >> ICV_SHIFT)
#define ICV_DESCALE(x) (((x)+(1 << (ICV_SHIFT-1))) >> ICV_SHIFT)
icvCopySubpix_8u_C1R_t icvCopySubpix_8u_C1R_p = 0;
icvCopySubpix_8u32f_C1R_t icvCopySubpix_8u32f_C1R_p = 0;
icvCopySubpix_32f_C1R_t icvCopySubpix_32f_C1R_p = 0;
ICV_DEF_GET_RECT_SUB_PIX_FUNC( 8u, uchar, uchar, int, CV_NOP, ICV_SCALE, ICV_DESCALE )
//ICV_DEF_GET_RECT_SUB_PIX_FUNC( 8u32f, uchar, float, float, CV_8TO32F, CV_NOP, CV_NOP )
ICV_DEF_GET_RECT_SUB_PIX_FUNC( 32f, float, float, float, CV_NOP, CV_NOP, CV_NOP )
ICV_DEF_GET_RECT_SUB_PIX_FUNC_C3( 8u, uchar, uchar, int, CV_NOP, ICV_SCALE, ICV_MUL_SCALE )
ICV_DEF_GET_RECT_SUB_PIX_FUNC_C3( 8u32f, uchar, float, float, CV_8TO32F, CV_NOP, CV_MUL )
ICV_DEF_GET_RECT_SUB_PIX_FUNC_C3( 32f, float, float, float, CV_NOP, CV_NOP, CV_MUL )
#define ICV_DEF_INIT_SUBPIX_TAB( FUNCNAME, FLAG ) \
static void icvInit##FUNCNAME##FLAG##Table( CvFuncTable* tab ) \
{ \
tab->fn_2d[CV_8U] = (void*)icv##FUNCNAME##_8u_##FLAG; \
tab->fn_2d[CV_32F] = (void*)icv##FUNCNAME##_32f_##FLAG; \
\
tab->fn_2d[1] = (void*)icv##FUNCNAME##_8u32f_##FLAG; \
}
ICV_DEF_INIT_SUBPIX_TAB( GetRectSubPix, C1R )
ICV_DEF_INIT_SUBPIX_TAB( GetRectSubPix, C3R )
typedef CvStatus (CV_STDCALL *CvGetRectSubPixFunc)( const void* src, int src_step,
CvSize src_size, void* dst,
int dst_step, CvSize win_size,
CvPoint2D32f center );
CV_IMPL void
cvGetRectSubPix( const void* srcarr, void* dstarr, CvPoint2D32f center )
{
static CvFuncTable gr_tab[2];
static int inittab = 0;
CV_FUNCNAME( "cvGetRectSubPix" );
__BEGIN__;
CvMat srcstub, *src = (CvMat*)srcarr;
CvMat dststub, *dst = (CvMat*)dstarr;
CvSize src_size, dst_size;
CvGetRectSubPixFunc func;
int cn, src_step, dst_step;
if( !inittab )
{
icvInitGetRectSubPixC1RTable( gr_tab + 0 );
icvInitGetRectSubPixC3RTable( gr_tab + 1 );
inittab = 1;
}
if( !CV_IS_MAT(src))
CV_CALL( src = cvGetMat( src, &srcstub ));
if( !CV_IS_MAT(dst))
CV_CALL( dst = cvGetMat( dst, &dststub ));
cn = CV_MAT_CN( src->type );
if( (cn != 1 && cn != 3) || !CV_ARE_CNS_EQ( src, dst ))
CV_ERROR( CV_StsUnsupportedFormat, "" );
src_size = cvGetMatSize( src );
dst_size = cvGetMatSize( dst );
src_step = src->step ? src->step : CV_STUB_STEP;
dst_step = dst->step ? dst->step : CV_STUB_STEP;
if( dst_size.width > src_size.width || dst_size.height > src_size.height )
CV_ERROR( CV_StsBadSize, "destination ROI must be smaller than source ROI" );
if( CV_ARE_DEPTHS_EQ( src, dst ))
{
func = (CvGetRectSubPixFunc)(gr_tab[cn != 1].fn_2d[CV_MAT_DEPTH(src->type)]);
}
else
{
if( CV_MAT_DEPTH( src->type ) != CV_8U || CV_MAT_DEPTH( dst->type ) != CV_32F )
CV_ERROR( CV_StsUnsupportedFormat, "" );
func = (CvGetRectSubPixFunc)(gr_tab[cn != 1].fn_2d[1]);
}
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
IPPI_CALL( func( src->data.ptr, src_step, src_size,
dst->data.ptr, dst_step, dst_size, center ));
__END__;
}
#define ICV_32F8U(x) ((uchar)cvRound(x))
#define ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC( flavor, srctype, dsttype, \
worktype, cast_macro, cvt ) \
static CvStatus CV_STDCALL \
icvGetQuadrangleSubPix_##flavor##_C1R \
( const srctype * src, int src_step, CvSize src_size, \
dsttype *dst, int dst_step, CvSize win_size, const float *matrix ) \
{ \
int x, y; \
double dx = (win_size.width - 1)*0.5; \
double dy = (win_size.height - 1)*0.5; \
double A11 = matrix[0], A12 = matrix[1], A13 = matrix[2]-A11*dx-A12*dy; \
double A21 = matrix[3], A22 = matrix[4], A23 = matrix[5]-A21*dx-A22*dy; \
\
src_step /= sizeof(srctype); \
dst_step /= sizeof(dsttype); \
\
for( y = 0; y < win_size.height; y++, dst += dst_step ) \
{ \
double xs = A12*y + A13; \
double ys = A22*y + A23; \
double xe = A11*(win_size.width-1) + A12*y + A13; \
double ye = A21*(win_size.width-1) + A22*y + A23; \
\
if( (unsigned)(cvFloor(xs)-1) < (unsigned)(src_size.width - 3) && \
(unsigned)(cvFloor(ys)-1) < (unsigned)(src_size.height - 3) && \
(unsigned)(cvFloor(xe)-1) < (unsigned)(src_size.width - 3) && \
(unsigned)(cvFloor(ye)-1) < (unsigned)(src_size.height - 3)) \
{ \
for( x = 0; x < win_size.width; x++ ) \
{ \
int ixs = cvFloor( xs ); \
int iys = cvFloor( ys ); \
const srctype *ptr = src + src_step*iys + ixs; \
double a = xs - ixs, b = ys - iys, a1 = 1.f - a; \
worktype p0 = cvt(ptr[0])*a1 + cvt(ptr[1])*a; \
worktype p1 = cvt(ptr[src_step])*a1 + cvt(ptr[src_step+1])*a;\
xs += A11; \
ys += A21; \
\
dst[x] = cast_macro(p0 + b * (p1 - p0)); \
} \
} \
else \
{ \
for( x = 0; x < win_size.width; x++ ) \
{ \
int ixs = cvFloor( xs ), iys = cvFloor( ys ); \
double a = xs - ixs, b = ys - iys, a1 = 1.f - a; \
const srctype *ptr0, *ptr1; \
worktype p0, p1; \
xs += A11; ys += A21; \
\
if( (unsigned)iys < (unsigned)(src_size.height-1) ) \
ptr0 = src + src_step*iys, ptr1 = ptr0 + src_step; \
else \
ptr0 = ptr1 = src + (iys < 0 ? 0 : src_size.height-1)*src_step; \
\
if( (unsigned)ixs < (unsigned)(src_size.width-1) ) \
{ \
p0 = cvt(ptr0[ixs])*a1 + cvt(ptr0[ixs+1])*a; \
p1 = cvt(ptr1[ixs])*a1 + cvt(ptr1[ixs+1])*a; \
} \
else \
{ \
ixs = ixs < 0 ? 0 : src_size.width - 1; \
p0 = cvt(ptr0[ixs]); p1 = cvt(ptr1[ixs]); \
} \
dst[x] = cast_macro(p0 + b * (p1 - p0)); \
} \
} \
} \
\
return CV_OK; \
}
#define ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC_C3( flavor, srctype, dsttype, \
worktype, cast_macro, cvt ) \
static CvStatus CV_STDCALL \
icvGetQuadrangleSubPix_##flavor##_C3R \
( const srctype * src, int src_step, CvSize src_size, \
dsttype *dst, int dst_step, CvSize win_size, const float *matrix ) \
{ \
int x, y; \
double dx = (win_size.width - 1)*0.5; \
double dy = (win_size.height - 1)*0.5; \
double A11 = matrix[0], A12 = matrix[1], A13 = matrix[2]-A11*dx-A12*dy; \
double A21 = matrix[3], A22 = matrix[4], A23 = matrix[5]-A21*dx-A22*dy; \
\
src_step /= sizeof(srctype); \
dst_step /= sizeof(dsttype); \
\
for( y = 0; y < win_size.height; y++, dst += dst_step ) \
{ \
double xs = A12*y + A13; \
double ys = A22*y + A23; \
double xe = A11*(win_size.width-1) + A12*y + A13; \
double ye = A21*(win_size.width-1) + A22*y + A23; \
\
if( (unsigned)(cvFloor(xs)-1) < (unsigned)(src_size.width - 3) && \
(unsigned)(cvFloor(ys)-1) < (unsigned)(src_size.height - 3) && \
(unsigned)(cvFloor(xe)-1) < (unsigned)(src_size.width - 3) && \
(unsigned)(cvFloor(ye)-1) < (unsigned)(src_size.height - 3)) \
{ \
for( x = 0; x < win_size.width; x++ ) \
{ \
int ixs = cvFloor( xs ); \
int iys = cvFloor( ys ); \
const srctype *ptr = src + src_step*iys + ixs*3; \
double a = xs - ixs, b = ys - iys, a1 = 1.f - a; \
worktype p0, p1; \
xs += A11; \
ys += A21; \
\
p0 = cvt(ptr[0])*a1 + cvt(ptr[3])*a; \
p1 = cvt(ptr[src_step])*a1 + cvt(ptr[src_step+3])*a; \
dst[x*3] = cast_macro(p0 + b * (p1 - p0)); \
\
p0 = cvt(ptr[1])*a1 + cvt(ptr[4])*a; \
p1 = cvt(ptr[src_step+1])*a1 + cvt(ptr[src_step+4])*a; \
dst[x*3+1] = cast_macro(p0 + b * (p1 - p0)); \
\
p0 = cvt(ptr[2])*a1 + cvt(ptr[5])*a; \
p1 = cvt(ptr[src_step+2])*a1 + cvt(ptr[src_step+5])*a; \
dst[x*3+2] = cast_macro(p0 + b * (p1 - p0)); \
} \
} \
else \
{ \
for( x = 0; x < win_size.width; x++ ) \
{ \
int ixs = cvFloor(xs), iys = cvFloor(ys); \
double a = xs - ixs, b = ys - iys; \
const srctype *ptr0, *ptr1; \
xs += A11; ys += A21; \
\
if( (unsigned)iys < (unsigned)(src_size.height-1) ) \
ptr0 = src + src_step*iys, ptr1 = ptr0 + src_step; \
else \
ptr0 = ptr1 = src + (iys < 0 ? 0 : src_size.height-1)*src_step; \
\
if( (unsigned)ixs < (unsigned)(src_size.width - 1) ) \
{ \
double a1 = 1.f - a; \
worktype p0, p1; \
ptr0 += ixs*3; ptr1 += ixs*3; \
p0 = cvt(ptr0[0])*a1 + cvt(ptr0[3])*a; \
p1 = cvt(ptr1[0])*a1 + cvt(ptr1[3])*a; \
dst[x*3] = cast_macro(p0 + b * (p1 - p0)); \
\
p0 = cvt(ptr0[1])*a1 + cvt(ptr0[4])*a; \
p1 = cvt(ptr1[1])*a1 + cvt(ptr1[4])*a; \
dst[x*3+1] = cast_macro(p0 + b * (p1 - p0)); \
\
p0 = cvt(ptr0[2])*a1 + cvt(ptr0[5])*a; \
p1 = cvt(ptr1[2])*a1 + cvt(ptr1[5])*a; \
dst[x*3+2] = cast_macro(p0 + b * (p1 - p0)); \
} \
else \
{ \
double b1 = 1.f - b; \
ixs = ixs < 0 ? 0 : src_size.width - 1; \
ptr0 += ixs*3; ptr1 += ixs*3; \
\
dst[x*3] = cast_macro(cvt(ptr0[0])*b1 + cvt(ptr1[0])*b);\
dst[x*3+1]=cast_macro(cvt(ptr0[1])*b1 + cvt(ptr1[1])*b);\
dst[x*3+2]=cast_macro(cvt(ptr0[2])*b1 + cvt(ptr1[2])*b);\
} \
} \
} \
} \
\
return CV_OK; \
}
/*#define srctype uchar
#define dsttype uchar
#define worktype float
#define cvt CV_8TO32F
#define cast_macro ICV_32F8U
#undef srctype
#undef dsttype
#undef worktype
#undef cvt
#undef cast_macro*/
ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC( 8u, uchar, uchar, double, ICV_32F8U, CV_8TO32F )
ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC( 32f, float, float, double, CV_CAST_32F, CV_NOP )
ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC( 8u32f, uchar, float, double, CV_CAST_32F, CV_8TO32F )
ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC_C3( 8u, uchar, uchar, double, ICV_32F8U, CV_8TO32F )
ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC_C3( 32f, float, float, double, CV_CAST_32F, CV_NOP )
ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC_C3( 8u32f, uchar, float, double, CV_CAST_32F, CV_8TO32F )
ICV_DEF_INIT_SUBPIX_TAB( GetQuadrangleSubPix, C1R )
ICV_DEF_INIT_SUBPIX_TAB( GetQuadrangleSubPix, C3R )
typedef CvStatus (CV_STDCALL *CvGetQuadrangleSubPixFunc)(
const void* src, int src_step,
CvSize src_size, void* dst,
int dst_step, CvSize win_size,
const float* matrix );
CV_IMPL void
cvGetQuadrangleSubPix( const void* srcarr, void* dstarr, const CvMat* mat )
{
static CvFuncTable gq_tab[2];
static int inittab = 0;
CV_FUNCNAME( "cvGetQuadrangleSubPix" );
__BEGIN__;
CvMat srcstub, *src = (CvMat*)srcarr;
CvMat dststub, *dst = (CvMat*)dstarr;
CvSize src_size, dst_size;
CvGetQuadrangleSubPixFunc func;
float m[6];
int k, cn;
if( !inittab )
{
icvInitGetQuadrangleSubPixC1RTable( gq_tab + 0 );
icvInitGetQuadrangleSubPixC3RTable( gq_tab + 1 );
inittab = 1;
}
if( !CV_IS_MAT(src))
CV_CALL( src = cvGetMat( src, &srcstub ));
if( !CV_IS_MAT(dst))
CV_CALL( dst = cvGetMat( dst, &dststub ));
if( !CV_IS_MAT(mat))
CV_ERROR( CV_StsBadArg, "map matrix is not valid" );
cn = CV_MAT_CN( src->type );
if( (cn != 1 && cn != 3) || !CV_ARE_CNS_EQ( src, dst ))
CV_ERROR( CV_StsUnsupportedFormat, "" );
src_size = cvGetMatSize( src );
dst_size = cvGetMatSize( dst );
/*if( dst_size.width > src_size.width || dst_size.height > src_size.height )
CV_ERROR( CV_StsBadSize, "destination ROI must not be larger than source ROI" );*/
if( mat->rows != 2 || mat->cols != 3 )
CV_ERROR( CV_StsBadArg,
"Transformation matrix must be 2x3" );
if( CV_MAT_TYPE( mat->type ) == CV_32FC1 )
{
for( k = 0; k < 3; k++ )
{
m[k] = mat->data.fl[k];
m[3 + k] = ((float*)(mat->data.ptr + mat->step))[k];
}
}
else if( CV_MAT_TYPE( mat->type ) == CV_64FC1 )
{
for( k = 0; k < 3; k++ )
{
m[k] = (float)mat->data.db[k];
m[3 + k] = (float)((double*)(mat->data.ptr + mat->step))[k];
}
}
else
CV_ERROR( CV_StsUnsupportedFormat,
"The transformation matrix should have 32fC1 or 64fC1 type" );
if( CV_ARE_DEPTHS_EQ( src, dst ))
{
func = (CvGetQuadrangleSubPixFunc)(gq_tab[cn != 1].fn_2d[CV_MAT_DEPTH(src->type)]);
}
else
{
if( CV_MAT_DEPTH( src->type ) != CV_8U || CV_MAT_DEPTH( dst->type ) != CV_32F )
CV_ERROR( CV_StsUnsupportedFormat, "" );
func = (CvGetQuadrangleSubPixFunc)(gq_tab[cn != 1].fn_2d[1]);
}
if( !func )
CV_ERROR( CV_StsUnsupportedFormat, "" );
IPPI_CALL( func( src->data.ptr, src->step, src_size,
dst->data.ptr, dst->step, dst_size, m ));
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,547 @@
/*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*/
#include "_cv.h"
/****************************************************************************************\
* Watershed *
\****************************************************************************************/
typedef struct CvWSNode
{
struct CvWSNode* next;
int mask_ofs;
int img_ofs;
}
CvWSNode;
typedef struct CvWSQueue
{
CvWSNode* first;
CvWSNode* last;
}
CvWSQueue;
static CvWSNode*
icvAllocWSNodes( CvMemStorage* storage )
{
CvWSNode* n = 0;
CV_FUNCNAME( "icvAllocWSNodes" );
__BEGIN__;
int i, count = (storage->block_size - sizeof(CvMemBlock))/sizeof(*n) - 1;
CV_CALL( n = (CvWSNode*)cvMemStorageAlloc( storage, count*sizeof(*n) ));
for( i = 0; i < count-1; i++ )
n[i].next = n + i + 1;
n[count-1].next = 0;
__END__;
return n;
}
CV_IMPL void
cvWatershed( const CvArr* srcarr, CvArr* dstarr )
{
const int IN_QUEUE = -2;
const int WSHED = -1;
const int NQ = 256;
CvMemStorage* storage = 0;
CV_FUNCNAME( "cvWatershed" );
__BEGIN__;
CvMat sstub, *src;
CvMat dstub, *dst;
CvSize size;
CvWSNode* free_node = 0, *node;
CvWSQueue q[NQ];
int active_queue;
int i, j;
int db, dg, dr;
int* mask;
uchar* img;
int mstep, istep;
int subs_tab[513];
// MAX(a,b) = b + MAX(a-b,0)
#define ws_max(a,b) ((b) + subs_tab[(a)-(b)+NQ])
// MIN(a,b) = a - MAX(a-b,0)
#define ws_min(a,b) ((a) - subs_tab[(a)-(b)+NQ])
#define ws_push(idx,mofs,iofs) \
{ \
if( !free_node ) \
CV_CALL( free_node = icvAllocWSNodes( storage ));\
node = free_node; \
free_node = free_node->next;\
node->next = 0; \
node->mask_ofs = mofs; \
node->img_ofs = iofs; \
if( q[idx].last ) \
q[idx].last->next=node; \
else \
q[idx].first = node; \
q[idx].last = node; \
}
#define ws_pop(idx,mofs,iofs) \
{ \
node = q[idx].first; \
q[idx].first = node->next; \
if( !node->next ) \
q[idx].last = 0; \
node->next = free_node; \
free_node = node; \
mofs = node->mask_ofs; \
iofs = node->img_ofs; \
}
#define c_diff(ptr1,ptr2,diff) \
{ \
db = abs((ptr1)[0] - (ptr2)[0]);\
dg = abs((ptr1)[1] - (ptr2)[1]);\
dr = abs((ptr1)[2] - (ptr2)[2]);\
diff = ws_max(db,dg); \
diff = ws_max(diff,dr); \
assert( 0 <= diff && diff <= 255 ); \
}
CV_CALL( src = cvGetMat( srcarr, &sstub ));
CV_CALL( dst = cvGetMat( dstarr, &dstub ));
if( CV_MAT_TYPE(src->type) != CV_8UC3 )
CV_ERROR( CV_StsUnsupportedFormat, "Only 8-bit, 3-channel input images are supported" );
if( CV_MAT_TYPE(dst->type) != CV_32SC1 )
CV_ERROR( CV_StsUnsupportedFormat,
"Only 32-bit, 1-channel output images are supported" );
if( !CV_ARE_SIZES_EQ( src, dst ))
CV_ERROR( CV_StsUnmatchedSizes, "The input and output images must have the same size" );
size = cvGetMatSize(src);
CV_CALL( storage = cvCreateMemStorage() );
istep = src->step;
img = src->data.ptr;
mstep = dst->step / sizeof(mask[0]);
mask = dst->data.i;
memset( q, 0, NQ*sizeof(q[0]) );
for( i = 0; i < 256; i++ )
subs_tab[i] = 0;
for( i = 256; i <= 512; i++ )
subs_tab[i] = i - 256;
// draw a pixel-wide border of dummy "watershed" (i.e. boundary) pixels
for( j = 0; j < size.width; j++ )
mask[j] = mask[j + mstep*(size.height-1)] = WSHED;
// initial phase: put all the neighbor pixels of each marker to the ordered queue -
// determine the initial boundaries of the basins
for( i = 1; i < size.height-1; i++ )
{
img += istep; mask += mstep;
mask[0] = mask[size.width-1] = WSHED;
for( j = 1; j < size.width-1; j++ )
{
int* m = mask + j;
if( m[0] < 0 ) m[0] = 0;
if( m[0] == 0 && (m[-1] > 0 || m[1] > 0 || m[-mstep] > 0 || m[mstep] > 0) )
{
uchar* ptr = img + j*3;
int idx = 256, t;
if( m[-1] > 0 )
c_diff( ptr, ptr - 3, idx );
if( m[1] > 0 )
{
c_diff( ptr, ptr + 3, t );
idx = ws_min( idx, t );
}
if( m[-mstep] > 0 )
{
c_diff( ptr, ptr - istep, t );
idx = ws_min( idx, t );
}
if( m[mstep] > 0 )
{
c_diff( ptr, ptr + istep, t );
idx = ws_min( idx, t );
}
assert( 0 <= idx && idx <= 255 );
ws_push( idx, i*mstep + j, i*istep + j*3 );
m[0] = IN_QUEUE;
}
}
}
// find the first non-empty queue
for( i = 0; i < NQ; i++ )
if( q[i].first )
break;
// if there is no markers, exit immediately
if( i == NQ )
EXIT;
active_queue = i;
img = src->data.ptr;
mask = dst->data.i;
// recursively fill the basins
for(;;)
{
int mofs, iofs;
int lab = 0, t;
int* m;
uchar* ptr;
if( q[active_queue].first == 0 )
{
for( i = active_queue+1; i < NQ; i++ )
if( q[i].first )
break;
if( i == NQ )
break;
active_queue = i;
}
ws_pop( active_queue, mofs, iofs );
m = mask + mofs;
ptr = img + iofs;
t = m[-1];
if( t > 0 ) lab = t;
t = m[1];
if( t > 0 )
if( lab == 0 ) lab = t;
else if( t != lab ) lab = WSHED;
t = m[-mstep];
if( t > 0 )
if( lab == 0 ) lab = t;
else if( t != lab ) lab = WSHED;
t = m[mstep];
if( t > 0 )
if( lab == 0 ) lab = t;
else if( t != lab ) lab = WSHED;
assert( lab != 0 );
m[0] = lab;
if( lab == WSHED )
continue;
if( m[-1] == 0 )
{
c_diff( ptr, ptr - 3, t );
ws_push( t, mofs - 1, iofs - 3 );
active_queue = ws_min( active_queue, t );
m[-1] = IN_QUEUE;
}
if( m[1] == 0 )
{
c_diff( ptr, ptr + 3, t );
ws_push( t, mofs + 1, iofs + 3 );
active_queue = ws_min( active_queue, t );
m[1] = IN_QUEUE;
}
if( m[-mstep] == 0 )
{
c_diff( ptr, ptr - istep, t );
ws_push( t, mofs - mstep, iofs - istep );
active_queue = ws_min( active_queue, t );
m[-mstep] = IN_QUEUE;
}
if( m[mstep] == 0 )
{
c_diff( ptr, ptr + 3, t );
ws_push( t, mofs + mstep, iofs + istep );
active_queue = ws_min( active_queue, t );
m[mstep] = IN_QUEUE;
}
}
__END__;
cvReleaseMemStorage( &storage );
}
/****************************************************************************************\
* Meanshift *
\****************************************************************************************/
CV_IMPL void
cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
double sp0, double sr, int max_level,
CvTermCriteria termcrit )
{
const int cn = 3;
const int MAX_LEVELS = 8;
CvMat* src_pyramid[MAX_LEVELS+1];
CvMat* dst_pyramid[MAX_LEVELS+1];
CvMat* mask0 = 0;
int i, j, level;
//uchar* submask = 0;
#define cdiff(ofs0) (tab[c0-dptr[ofs0]+255] + \
tab[c1-dptr[(ofs0)+1]+255] + tab[c2-dptr[(ofs0)+2]+255] >= isr22)
memset( src_pyramid, 0, sizeof(src_pyramid) );
memset( dst_pyramid, 0, sizeof(dst_pyramid) );
CV_FUNCNAME( "cvPyrMeanShiftFiltering" );
__BEGIN__;
double sr2 = sr * sr;
int isr2 = cvRound(sr2), isr22 = MAX(isr2,16);
int tab[768];
CvMat sstub0, *src0;
CvMat dstub0, *dst0;
CV_CALL( src0 = cvGetMat( srcarr, &sstub0 ));
CV_CALL( dst0 = cvGetMat( dstarr, &dstub0 ));
if( CV_MAT_TYPE(src0->type) != CV_8UC3 )
CV_ERROR( CV_StsUnsupportedFormat, "Only 8-bit, 3-channel images are supported" );
if( !CV_ARE_TYPES_EQ( src0, dst0 ))
CV_ERROR( CV_StsUnmatchedFormats, "The input and output images must have the same type" );
if( !CV_ARE_SIZES_EQ( src0, dst0 ))
CV_ERROR( CV_StsUnmatchedSizes, "The input and output images must have the same size" );
if( (unsigned)max_level > (unsigned)MAX_LEVELS )
CV_ERROR( CV_StsOutOfRange, "The number of pyramid levels is too large or negative" );
if( !(termcrit.type & CV_TERMCRIT_ITER) )
termcrit.max_iter = 5;
termcrit.max_iter = MAX(termcrit.max_iter,1);
termcrit.max_iter = MIN(termcrit.max_iter,100);
if( !(termcrit.type & CV_TERMCRIT_EPS) )
termcrit.epsilon = 1.f;
termcrit.epsilon = MAX(termcrit.epsilon, 0.f);
for( i = 0; i < 768; i++ )
tab[i] = (i - 255)*(i - 255);
// 1. construct pyramid
src_pyramid[0] = src0;
dst_pyramid[0] = dst0;
for( level = 1; level <= max_level; level++ )
{
CV_CALL( src_pyramid[level] = cvCreateMat( (src_pyramid[level-1]->rows+1)/2,
(src_pyramid[level-1]->cols+1)/2, src_pyramid[level-1]->type ));
CV_CALL( dst_pyramid[level] = cvCreateMat( src_pyramid[level]->rows,
src_pyramid[level]->cols, src_pyramid[level]->type ));
CV_CALL( cvPyrDown( src_pyramid[level-1], src_pyramid[level] ));
//CV_CALL( cvResize( src_pyramid[level-1], src_pyramid[level], CV_INTER_AREA ));
}
CV_CALL( mask0 = cvCreateMat( src0->rows, src0->cols, CV_8UC1 ));
//CV_CALL( submask = (uchar*)cvAlloc( (sp+2)*(sp+2) ));
// 2. apply meanshift, starting from the pyramid top (i.e. the smallest layer)
for( level = max_level; level >= 0; level-- )
{
CvMat* src = src_pyramid[level];
CvSize size = cvGetMatSize(src);
uchar* sptr = src->data.ptr;
int sstep = src->step;
uchar* mask = 0;
int mstep = 0;
uchar* dptr;
int dstep;
float sp = (float)(sp0 / (1 << level));
sp = MAX( sp, 1 );
if( level < max_level )
{
CvSize size1 = cvGetMatSize(dst_pyramid[level+1]);
CvMat m = cvMat( size.height, size.width, CV_8UC1, mask0->data.ptr );
dstep = dst_pyramid[level+1]->step;
dptr = dst_pyramid[level+1]->data.ptr + dstep + cn;
mstep = m.step;
mask = m.data.ptr + mstep;
//cvResize( dst_pyramid[level+1], dst_pyramid[level], CV_INTER_CUBIC );
cvPyrUp( dst_pyramid[level+1], dst_pyramid[level] );
cvZero( &m );
for( i = 1; i < size1.height-1; i++, dptr += dstep - (size1.width-2)*3, mask += mstep*2 )
{
for( j = 1; j < size1.width-1; j++, dptr += cn )
{
int c0 = dptr[0], c1 = dptr[1], c2 = dptr[2];
mask[j*2 - 1] = cdiff(-3) || cdiff(3) || cdiff(-dstep-3) || cdiff(-dstep) ||
cdiff(-dstep+3) || cdiff(dstep-3) || cdiff(dstep) || cdiff(dstep+3);
}
}
cvDilate( &m, &m, 0, 1 );
mask = m.data.ptr;
}
dptr = dst_pyramid[level]->data.ptr;
dstep = dst_pyramid[level]->step;
for( i = 0; i < size.height; i++, sptr += sstep - size.width*3,
dptr += dstep - size.width*3,
mask += mstep )
{
for( j = 0; j < size.width; j++, sptr += 3, dptr += 3 )
{
int x0 = j, y0 = i, x1, y1, iter;
int c0, c1, c2;
if( mask && !mask[j] )
continue;
c0 = sptr[0], c1 = sptr[1], c2 = sptr[2];
// iterate meanshift procedure
for( iter = 0; iter < termcrit.max_iter; iter++ )
{
uchar* ptr;
int x, y, count = 0;
int minx, miny, maxx, maxy;
int s0 = 0, s1 = 0, s2 = 0, sx = 0, sy = 0;
double icount;
int stop_flag;
//mean shift: process pixels in window (p-sigmaSp)x(p+sigmaSp)
minx = cvRound(x0 - sp); minx = MAX(minx, 0);
miny = cvRound(y0 - sp); miny = MAX(miny, 0);
maxx = cvRound(x0 + sp); maxx = MIN(maxx, size.width-1);
maxy = cvRound(y0 + sp); maxy = MIN(maxy, size.height-1);
ptr = sptr + (miny - i)*sstep + (minx - j)*3;
for( y = miny; y <= maxy; y++, ptr += sstep - (maxx-minx+1)*3 )
{
int row_count = 0;
x = minx;
for( ; x + 3 <= maxx; x += 4, ptr += 12 )
{
int t0 = ptr[0], t1 = ptr[1], t2 = ptr[2];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
s0 += t0; s1 += t1; s2 += t2;
sx += x; row_count++;
}
t0 = ptr[3], t1 = ptr[4], t2 = ptr[5];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
s0 += t0; s1 += t1; s2 += t2;
sx += x+1; row_count++;
}
t0 = ptr[6], t1 = ptr[7], t2 = ptr[8];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
s0 += t0; s1 += t1; s2 += t2;
sx += x+2; row_count++;
}
t0 = ptr[9], t1 = ptr[10], t2 = ptr[11];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
s0 += t0; s1 += t1; s2 += t2;
sx += x+3; row_count++;
}
}
for( ; x <= maxx; x++, ptr += 3 )
{
int t0 = ptr[0], t1 = ptr[1], t2 = ptr[2];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
s0 += t0; s1 += t1; s2 += t2;
sx += x; row_count++;
}
}
count += row_count;
sy += y*row_count;
}
if( count == 0 )
break;
icount = 1./count;
x1 = cvRound(sx*icount);
y1 = cvRound(sy*icount);
s0 = cvRound(s0*icount);
s1 = cvRound(s1*icount);
s2 = cvRound(s2*icount);
stop_flag = x0 == x1 && y0 == y1 || abs(x1-x0) + abs(y1-y0) +
tab[s0 - c0 + 255] + tab[s1 - c1 + 255] +
tab[s2 - c2 + 255] <= termcrit.epsilon;
x0 = x1; y0 = y1;
c0 = s0; c1 = s1; c2 = s2;
if( stop_flag )
break;
}
dptr[0] = (uchar)c0;
dptr[1] = (uchar)c1;
dptr[2] = (uchar)c2;
}
}
}
__END__;
for( i = 1; i <= MAX_LEVELS; i++ )
{
cvReleaseMat( &src_pyramid[i] );
cvReleaseMat( &dst_pyramid[i] );
}
cvReleaseMat( &mask0 );
}

View File

@@ -0,0 +1,438 @@
/*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*/
#include "_cv.h"
#define _CV_SNAKE_BIG 2.e+38f
#define _CV_SNAKE_IMAGE 1
#define _CV_SNAKE_GRAD 2
/*F///////////////////////////////////////////////////////////////////////////////////////
// Name: icvSnake8uC1R
// Purpose:
// Context:
// Parameters:
// src - source image,
// srcStep - its step in bytes,
// roi - size of ROI,
// pt - pointer to snake points array
// n - size of points array,
// alpha - pointer to coefficient of continuity energy,
// beta - pointer to coefficient of curvature energy,
// gamma - pointer to coefficient of image energy,
// coeffUsage - if CV_VALUE - alpha, beta, gamma point to single value
// if CV_MATAY - point to arrays
// criteria - termination criteria.
// scheme - image energy scheme
// if _CV_SNAKE_IMAGE - image intensity is energy
// if _CV_SNAKE_GRAD - magnitude of gradient is energy
// Returns:
//F*/
static CvStatus
icvSnake8uC1R( unsigned char *src,
int srcStep,
CvSize roi,
CvPoint * pt,
int n,
float *alpha,
float *beta,
float *gamma,
int coeffUsage, CvSize win, CvTermCriteria criteria, int scheme )
{
int i, j, k;
int neighbors = win.height * win.width;
int centerx = win.width >> 1;
int centery = win.height >> 1;
float invn;
int iteration = 0;
int converged = 0;
float *Econt;
float *Ecurv;
float *Eimg;
float *E;
float _alpha, _beta, _gamma;
/*#ifdef GRAD_SNAKE */
float *gradient = NULL;
uchar *map = NULL;
int map_width = ((roi.width - 1) >> 3) + 1;
int map_height = ((roi.height - 1) >> 3) + 1;
CvSepFilter pX, pY;
#define WTILE_SIZE 8
#define TILE_SIZE (WTILE_SIZE + 2)
short dx[TILE_SIZE*TILE_SIZE], dy[TILE_SIZE*TILE_SIZE];
CvMat _dx = cvMat( TILE_SIZE, TILE_SIZE, CV_16SC1, dx );
CvMat _dy = cvMat( TILE_SIZE, TILE_SIZE, CV_16SC1, dy );
CvMat _src = cvMat( roi.height, roi.width, CV_8UC1, src );
/* inner buffer of convolution process */
//char ConvBuffer[400];
/*#endif */
/* check bad arguments */
if( src == NULL )
return CV_NULLPTR_ERR;
if( (roi.height <= 0) || (roi.width <= 0) )
return CV_BADSIZE_ERR;
if( srcStep < roi.width )
return CV_BADSIZE_ERR;
if( pt == NULL )
return CV_NULLPTR_ERR;
if( n < 3 )
return CV_BADSIZE_ERR;
if( alpha == NULL )
return CV_NULLPTR_ERR;
if( beta == NULL )
return CV_NULLPTR_ERR;
if( gamma == NULL )
return CV_NULLPTR_ERR;
if( coeffUsage != CV_VALUE && coeffUsage != CV_ARRAY )
return CV_BADFLAG_ERR;
if( (win.height <= 0) || (!(win.height & 1)))
return CV_BADSIZE_ERR;
if( (win.width <= 0) || (!(win.width & 1)))
return CV_BADSIZE_ERR;
invn = 1 / ((float) n);
if( scheme == _CV_SNAKE_GRAD )
{
pX.init_deriv( TILE_SIZE+2, CV_8UC1, CV_16SC1, 1, 0, 3 );
pY.init_deriv( TILE_SIZE+2, CV_8UC1, CV_16SC1, 0, 1, 3 );
gradient = (float *) cvAlloc( roi.height * roi.width * sizeof( float ));
if( !gradient )
return CV_OUTOFMEM_ERR;
map = (uchar *) cvAlloc( map_width * map_height );
if( !map )
{
cvFree( &gradient );
return CV_OUTOFMEM_ERR;
}
/* clear map - no gradient computed */
memset( (void *) map, 0, map_width * map_height );
}
Econt = (float *) cvAlloc( neighbors * sizeof( float ));
Ecurv = (float *) cvAlloc( neighbors * sizeof( float ));
Eimg = (float *) cvAlloc( neighbors * sizeof( float ));
E = (float *) cvAlloc( neighbors * sizeof( float ));
while( !converged )
{
float ave_d = 0;
int moved = 0;
converged = 0;
iteration++;
/* compute average distance */
for( i = 1; i < n; i++ )
{
int diffx = pt[i - 1].x - pt[i].x;
int diffy = pt[i - 1].y - pt[i].y;
ave_d += cvSqrt( (float) (diffx * diffx + diffy * diffy) );
}
ave_d += cvSqrt( (float) ((pt[0].x - pt[n - 1].x) *
(pt[0].x - pt[n - 1].x) +
(pt[0].y - pt[n - 1].y) * (pt[0].y - pt[n - 1].y)));
ave_d *= invn;
/* average distance computed */
for( i = 0; i < n; i++ )
{
/* Calculate Econt */
float maxEcont = 0;
float maxEcurv = 0;
float maxEimg = 0;
float minEcont = _CV_SNAKE_BIG;
float minEcurv = _CV_SNAKE_BIG;
float minEimg = _CV_SNAKE_BIG;
float Emin = _CV_SNAKE_BIG;
int offsetx = 0;
int offsety = 0;
float tmp;
/* compute bounds */
int left = MIN( pt[i].x, win.width >> 1 );
int right = MIN( roi.width - 1 - pt[i].x, win.width >> 1 );
int upper = MIN( pt[i].y, win.height >> 1 );
int bottom = MIN( roi.height - 1 - pt[i].y, win.height >> 1 );
maxEcont = 0;
minEcont = _CV_SNAKE_BIG;
for( j = -upper; j <= bottom; j++ )
{
for( k = -left; k <= right; k++ )
{
int diffx, diffy;
float energy;
if( i == 0 )
{
diffx = pt[n - 1].x - (pt[i].x + k);
diffy = pt[n - 1].y - (pt[i].y + j);
}
else
{
diffx = pt[i - 1].x - (pt[i].x + k);
diffy = pt[i - 1].y - (pt[i].y + j);
}
Econt[(j + centery) * win.width + k + centerx] = energy =
(float) fabs( ave_d -
cvSqrt( (float) (diffx * diffx + diffy * diffy) ));
maxEcont = MAX( maxEcont, energy );
minEcont = MIN( minEcont, energy );
}
}
tmp = maxEcont - minEcont;
tmp = (tmp == 0) ? 0 : (1 / tmp);
for( k = 0; k < neighbors; k++ )
{
Econt[k] = (Econt[k] - minEcont) * tmp;
}
/* Calculate Ecurv */
maxEcurv = 0;
minEcurv = _CV_SNAKE_BIG;
for( j = -upper; j <= bottom; j++ )
{
for( k = -left; k <= right; k++ )
{
int tx, ty;
float energy;
if( i == 0 )
{
tx = pt[n - 1].x - 2 * (pt[i].x + k) + pt[i + 1].x;
ty = pt[n - 1].y - 2 * (pt[i].y + j) + pt[i + 1].y;
}
else if( i == n - 1 )
{
tx = pt[i - 1].x - 2 * (pt[i].x + k) + pt[0].x;
ty = pt[i - 1].y - 2 * (pt[i].y + j) + pt[0].y;
}
else
{
tx = pt[i - 1].x - 2 * (pt[i].x + k) + pt[i + 1].x;
ty = pt[i - 1].y - 2 * (pt[i].y + j) + pt[i + 1].y;
}
Ecurv[(j + centery) * win.width + k + centerx] = energy =
(float) (tx * tx + ty * ty);
maxEcurv = MAX( maxEcurv, energy );
minEcurv = MIN( minEcurv, energy );
}
}
tmp = maxEcurv - minEcurv;
tmp = (tmp == 0) ? 0 : (1 / tmp);
for( k = 0; k < neighbors; k++ )
{
Ecurv[k] = (Ecurv[k] - minEcurv) * tmp;
}
/* Calculate Eimg */
for( j = -upper; j <= bottom; j++ )
{
for( k = -left; k <= right; k++ )
{
float energy;
if( scheme == _CV_SNAKE_GRAD )
{
/* look at map and check status */
int x = (pt[i].x + k)/WTILE_SIZE;
int y = (pt[i].y + j)/WTILE_SIZE;
if( map[y * map_width + x] == 0 )
{
int l, m;
/* evaluate block location */
int upshift = y ? 1 : 0;
int leftshift = x ? 1 : 0;
int bottomshift = MIN( 1, roi.height - (y + 1)*WTILE_SIZE );
int rightshift = MIN( 1, roi.width - (x + 1)*WTILE_SIZE );
CvRect g_roi = { x*WTILE_SIZE - leftshift, y*WTILE_SIZE - upshift,
leftshift + WTILE_SIZE + rightshift, upshift + WTILE_SIZE + bottomshift };
CvMat _src1;
cvGetSubArr( &_src, &_src1, g_roi );
pX.process( &_src1, &_dx );
pY.process( &_src1, &_dy );
for( l = 0; l < WTILE_SIZE + bottomshift; l++ )
{
for( m = 0; m < WTILE_SIZE + rightshift; m++ )
{
gradient[(y*WTILE_SIZE + l) * roi.width + x*WTILE_SIZE + m] =
(float) (dx[(l + upshift) * TILE_SIZE + m + leftshift] *
dx[(l + upshift) * TILE_SIZE + m + leftshift] +
dy[(l + upshift) * TILE_SIZE + m + leftshift] *
dy[(l + upshift) * TILE_SIZE + m + leftshift]);
}
}
map[y * map_width + x] = 1;
}
Eimg[(j + centery) * win.width + k + centerx] = energy =
gradient[(pt[i].y + j) * roi.width + pt[i].x + k];
}
else
{
Eimg[(j + centery) * win.width + k + centerx] = energy =
src[(pt[i].y + j) * srcStep + pt[i].x + k];
}
maxEimg = MAX( maxEimg, energy );
minEimg = MIN( minEimg, energy );
}
}
tmp = (maxEimg - minEimg);
tmp = (tmp == 0) ? 0 : (1 / tmp);
for( k = 0; k < neighbors; k++ )
{
Eimg[k] = (minEimg - Eimg[k]) * tmp;
}
/* locate coefficients */
if( coeffUsage == CV_VALUE)
{
_alpha = *alpha;
_beta = *beta;
_gamma = *gamma;
}
else
{
_alpha = alpha[i];
_beta = beta[i];
_gamma = gamma[i];
}
/* Find Minimize point in the neighbors */
for( k = 0; k < neighbors; k++ )
{
E[k] = _alpha * Econt[k] + _beta * Ecurv[k] + _gamma * Eimg[k];
}
Emin = _CV_SNAKE_BIG;
for( j = -upper; j <= bottom; j++ )
{
for( k = -left; k <= right; k++ )
{
if( E[(j + centery) * win.width + k + centerx] < Emin )
{
Emin = E[(j + centery) * win.width + k + centerx];
offsetx = k;
offsety = j;
}
}
}
if( offsetx || offsety )
{
pt[i].x += offsetx;
pt[i].y += offsety;
moved++;
}
}
converged = (moved == 0);
if( (criteria.type & CV_TERMCRIT_ITER) && (iteration >= criteria.max_iter) )
converged = 1;
if( (criteria.type & CV_TERMCRIT_EPS) && (moved <= criteria.epsilon) )
converged = 1;
}
cvFree( &Econt );
cvFree( &Ecurv );
cvFree( &Eimg );
cvFree( &E );
if( scheme == _CV_SNAKE_GRAD )
{
cvFree( &gradient );
cvFree( &map );
}
return CV_OK;
}
CV_IMPL void
cvSnakeImage( const IplImage* src, CvPoint* points,
int length, float *alpha,
float *beta, float *gamma,
int coeffUsage, CvSize win,
CvTermCriteria criteria, int calcGradient )
{
CV_FUNCNAME( "cvSnakeImage" );
__BEGIN__;
uchar *data;
CvSize size;
int step;
if( src->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, "input image has more than one channel" );
if( src->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
cvGetRawData( src, &data, &step, &size );
IPPI_CALL( icvSnake8uC1R( data, step, size, points, length,
alpha, beta, gamma, coeffUsage, win, criteria,
calcGradient ? _CV_SNAKE_GRAD : _CV_SNAKE_IMAGE ));
__END__;
}
/* end of file */

View File

@@ -0,0 +1,850 @@
/*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*/
#include "_cv.h"
CV_IMPL CvSubdiv2D *
cvCreateSubdiv2D( int subdiv_type, int header_size,
int vtx_size, int quadedge_size, CvMemStorage * storage )
{
CvSubdiv2D *subdiv = 0;
CV_FUNCNAME( "cvCleateSubdiv2D" );
__BEGIN__;
if( !storage )
CV_ERROR( CV_StsNullPtr, "" );
if( header_size < (int)sizeof( *subdiv ) ||
quadedge_size < (int)sizeof( CvQuadEdge2D ) ||
vtx_size < (int)sizeof( CvSubdiv2DPoint ))
CV_ERROR_FROM_STATUS( CV_BADSIZE_ERR );
subdiv = (CvSubdiv2D *) cvCreateGraph( subdiv_type, header_size,
vtx_size, quadedge_size, storage );
__END__;
return subdiv;
}
/****************************************************************************************\
* Quad Edge algebra *
\****************************************************************************************/
static CvSubdiv2DEdge
cvSubdiv2DMakeEdge( CvSubdiv2D * subdiv )
{
CvQuadEdge2D *edge = 0;
CvSubdiv2DEdge edgehandle = 0;
CV_FUNCNAME( "cvSubdiv2DMakeEdge" );
__BEGIN__;
if( !subdiv )
CV_ERROR( CV_StsNullPtr, "" );
edge = (CvQuadEdge2D*)cvSetNew( (CvSet*)subdiv->edges );
CV_CHECK();
memset( edge->pt, 0, sizeof( edge->pt ));
edgehandle = (CvSubdiv2DEdge) edge;
edge->next[0] = edgehandle;
edge->next[1] = edgehandle + 3;
edge->next[2] = edgehandle + 2;
edge->next[3] = edgehandle + 1;
subdiv->quad_edges++;
__END__;
return edgehandle;
}
static CvSubdiv2DPoint *
cvSubdiv2DAddPoint( CvSubdiv2D * subdiv, CvPoint2D32f pt, int is_virtual )
{
CvSubdiv2DPoint *subdiv_point = 0;
subdiv_point = (CvSubdiv2DPoint*)cvSetNew( (CvSet*)subdiv );
if( subdiv_point )
{
memset( subdiv_point, 0, subdiv->elem_size );
subdiv_point->pt = pt;
subdiv_point->first = 0;
subdiv_point->flags |= is_virtual ? CV_SUBDIV2D_VIRTUAL_POINT_FLAG : 0;
}
return subdiv_point;
}
static void
cvSubdiv2DSplice( CvSubdiv2DEdge edgeA, CvSubdiv2DEdge edgeB )
{
CvSubdiv2DEdge *a_next = &CV_SUBDIV2D_NEXT_EDGE( edgeA );
CvSubdiv2DEdge *b_next = &CV_SUBDIV2D_NEXT_EDGE( edgeB );
CvSubdiv2DEdge a_rot = cvSubdiv2DRotateEdge( *a_next, 1 );
CvSubdiv2DEdge b_rot = cvSubdiv2DRotateEdge( *b_next, 1 );
CvSubdiv2DEdge *a_rot_next = &CV_SUBDIV2D_NEXT_EDGE( a_rot );
CvSubdiv2DEdge *b_rot_next = &CV_SUBDIV2D_NEXT_EDGE( b_rot );
CvSubdiv2DEdge t;
CV_SWAP( *a_next, *b_next, t );
CV_SWAP( *a_rot_next, *b_rot_next, t );
}
static void
cvSubdiv2DSetEdgePoints( CvSubdiv2DEdge edge,
CvSubdiv2DPoint * org_pt, CvSubdiv2DPoint * dst_pt )
{
CvQuadEdge2D *quadedge = (CvQuadEdge2D *) (edge & ~3);
CV_FUNCNAME( "cvSubdiv2DSetEdgePoints" );
__BEGIN__;
if( !quadedge )
CV_ERROR( CV_StsNullPtr, "" );
quadedge->pt[edge & 3] = org_pt;
quadedge->pt[(edge + 2) & 3] = dst_pt;
__END__;
}
static void
cvSubdiv2DDeleteEdge( CvSubdiv2D * subdiv, CvSubdiv2DEdge edge )
{
CvQuadEdge2D *quadedge = (CvQuadEdge2D *) (edge & ~3);
CV_FUNCNAME( "cvSubdiv2DDeleteEdge" );
__BEGIN__;
if( !subdiv || !quadedge )
CV_ERROR( CV_StsNullPtr, "" );
cvSubdiv2DSplice( edge, cvSubdiv2DGetEdge( edge, CV_PREV_AROUND_ORG ));
{
CvSubdiv2DEdge sym_edge = cvSubdiv2DSymEdge( edge );
cvSubdiv2DSplice( sym_edge, cvSubdiv2DGetEdge( sym_edge, CV_PREV_AROUND_ORG ));
}
cvSetRemoveByPtr( (CvSet*)(subdiv->edges), quadedge );
subdiv->quad_edges--;
__END__;
}
static CvSubdiv2DEdge
cvSubdiv2DConnectEdges( CvSubdiv2D * subdiv, CvSubdiv2DEdge edgeA, CvSubdiv2DEdge edgeB )
{
CvSubdiv2DEdge new_edge = 0;
CV_FUNCNAME( "cvSubdiv2DConnectPoints" );
__BEGIN__;
CvSubdiv2DPoint *orgB, *dstA;
if( !subdiv )
CV_ERROR( CV_StsNullPtr, "" );
new_edge = cvSubdiv2DMakeEdge( subdiv );
cvSubdiv2DSplice( new_edge, cvSubdiv2DGetEdge( edgeA, CV_NEXT_AROUND_LEFT ));
cvSubdiv2DSplice( cvSubdiv2DSymEdge( new_edge ), edgeB );
dstA = cvSubdiv2DEdgeDst( edgeA );
orgB = cvSubdiv2DEdgeOrg( edgeB );
cvSubdiv2DSetEdgePoints( new_edge, dstA, orgB );
__END__;
return new_edge;
}
static void
cvSubdiv2DSwapEdges( CvSubdiv2DEdge edge )
{
CvSubdiv2DEdge sym_edge = cvSubdiv2DSymEdge( edge );
CvSubdiv2DEdge a = cvSubdiv2DGetEdge( edge, CV_PREV_AROUND_ORG );
CvSubdiv2DEdge b = cvSubdiv2DGetEdge( sym_edge, CV_PREV_AROUND_ORG );
CvSubdiv2DPoint *dstB, *dstA;
cvSubdiv2DSplice( edge, a );
cvSubdiv2DSplice( sym_edge, b );
dstA = cvSubdiv2DEdgeDst( a );
dstB = cvSubdiv2DEdgeDst( b );
cvSubdiv2DSetEdgePoints( edge, dstA, dstB );
cvSubdiv2DSplice( edge, cvSubdiv2DGetEdge( a, CV_NEXT_AROUND_LEFT ));
cvSubdiv2DSplice( sym_edge, cvSubdiv2DGetEdge( b, CV_NEXT_AROUND_LEFT ));
}
static int
icvIsRightOf( CvPoint2D32f& pt, CvSubdiv2DEdge edge )
{
CvSubdiv2DPoint *org = cvSubdiv2DEdgeOrg(edge), *dst = cvSubdiv2DEdgeDst(edge);
Cv32suf cw_area;
cw_area.f = (float)cvTriangleArea( pt, dst->pt, org->pt );
return (cw_area.i > 0)*2 - (cw_area.i*2 != 0);
}
CV_IMPL CvSubdiv2DPointLocation
cvSubdiv2DLocate( CvSubdiv2D * subdiv, CvPoint2D32f pt,
CvSubdiv2DEdge * _edge, CvSubdiv2DPoint ** _point )
{
CvSubdiv2DEdge edge = 0;
CvSubdiv2DPoint *point = 0;
CvSubdiv2DPointLocation location = CV_PTLOC_ERROR;
int i, max_edges;
int right_of_curr = 0;
CV_FUNCNAME( "cvSubdiv2DLocate" );
__BEGIN__;
if( !subdiv )
CV_ERROR( CV_StsNullPtr, "" );
if( !CV_IS_SUBDIV2D(subdiv) )
CV_ERROR_FROM_STATUS( CV_BADFLAG_ERR );
max_edges = subdiv->quad_edges * 4;
edge = subdiv->recent_edge;
if( max_edges == 0 )
CV_ERROR_FROM_STATUS( CV_BADSIZE_ERR );
if( !edge )
CV_ERROR_FROM_STATUS( CV_NOTDEFINED_ERR );
location = CV_PTLOC_OUTSIDE_RECT;
if( pt.x < subdiv->topleft.x || pt.y < subdiv->topleft.y ||
pt.x >= subdiv->bottomright.x || pt.y >= subdiv->bottomright.y )
CV_ERROR_FROM_STATUS( CV_BADRANGE_ERR );
location = CV_PTLOC_ERROR;
right_of_curr = icvIsRightOf( pt, edge );
if( right_of_curr > 0 )
{
edge = cvSubdiv2DSymEdge( edge );
right_of_curr = -right_of_curr;
}
for( i = 0; i < max_edges; i++ )
{
CvSubdiv2DEdge onext_edge = cvSubdiv2DNextEdge( edge );
CvSubdiv2DEdge dprev_edge = cvSubdiv2DGetEdge( edge, CV_PREV_AROUND_DST );
int right_of_onext = icvIsRightOf( pt, onext_edge );
int right_of_dprev = icvIsRightOf( pt, dprev_edge );
if( right_of_dprev > 0 )
{
if( right_of_onext > 0 || right_of_onext == 0 && right_of_curr == 0 )
{
location = CV_PTLOC_INSIDE;
EXIT;
}
else
{
right_of_curr = right_of_onext;
edge = onext_edge;
}
}
else
{
if( right_of_onext > 0 )
{
if( right_of_dprev == 0 && right_of_curr == 0 )
{
location = CV_PTLOC_INSIDE;
EXIT;
}
else
{
right_of_curr = right_of_dprev;
edge = dprev_edge;
}
}
else if( right_of_curr == 0 &&
icvIsRightOf( cvSubdiv2DEdgeDst( onext_edge )->pt, edge ) >= 0 )
{
edge = cvSubdiv2DSymEdge( edge );
}
else
{
right_of_curr = right_of_onext;
edge = onext_edge;
}
}
}
__END__;
subdiv->recent_edge = edge;
if( location == CV_PTLOC_INSIDE )
{
double t1, t2, t3;
CvPoint2D32f org_pt = cvSubdiv2DEdgeOrg( edge )->pt;
CvPoint2D32f dst_pt = cvSubdiv2DEdgeDst( edge )->pt;
t1 = fabs( pt.x - org_pt.x );
t1 += fabs( pt.y - org_pt.y );
t2 = fabs( pt.x - dst_pt.x );
t2 += fabs( pt.y - dst_pt.y );
t3 = fabs( org_pt.x - dst_pt.x );
t3 += fabs( org_pt.y - dst_pt.y );
if( t1 < FLT_EPSILON )
{
location = CV_PTLOC_VERTEX;
point = cvSubdiv2DEdgeOrg( edge );
edge = 0;
}
else if( t2 < FLT_EPSILON )
{
location = CV_PTLOC_VERTEX;
point = cvSubdiv2DEdgeDst( edge );
edge = 0;
}
else if( (t1 < t3 || t2 < t3) &&
fabs( cvTriangleArea( pt, org_pt, dst_pt )) < FLT_EPSILON )
{
location = CV_PTLOC_ON_EDGE;
point = 0;
}
}
if( location == CV_PTLOC_ERROR )
{
edge = 0;
point = 0;
}
if( _edge )
*_edge = edge;
if( _point )
*_point = point;
return location;
}
CV_INLINE int
icvIsPtInCircle3( CvPoint2D32f pt, CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c )
{
double val = (a.x * a.x + a.y * a.y) * cvTriangleArea( b, c, pt );
val -= (b.x * b.x + b.y * b.y) * cvTriangleArea( a, c, pt );
val += (c.x * c.x + c.y * c.y) * cvTriangleArea( a, b, pt );
val -= (pt.x * pt.x + pt.y * pt.y) * cvTriangleArea( a, b, c );
return val > FLT_EPSILON ? 1 : val < -FLT_EPSILON ? -1 : 0;
}
CV_IMPL CvSubdiv2DPoint *
cvSubdivDelaunay2DInsert( CvSubdiv2D * subdiv, CvPoint2D32f pt )
{
CvSubdiv2DPoint *point = 0;
CvSubdiv2DPointLocation location = CV_PTLOC_ERROR;
CvSubdiv2DPoint *curr_point = 0, *first_point = 0;
CvSubdiv2DEdge curr_edge = 0, deleted_edge = 0, base_edge = 0;
int i, max_edges;
CV_FUNCNAME( "cvSubdivDelaunay2DInsert" );
__BEGIN__;
if( !subdiv )
CV_ERROR( CV_StsNullPtr, "" );
if( !CV_IS_SUBDIV2D(subdiv) )
CV_ERROR_FROM_STATUS( CV_BADFLAG_ERR );
location = cvSubdiv2DLocate( subdiv, pt, &curr_edge, &curr_point );
switch (location)
{
case CV_PTLOC_ERROR:
CV_ERROR_FROM_STATUS( CV_BADSIZE_ERR );
case CV_PTLOC_OUTSIDE_RECT:
CV_ERROR_FROM_STATUS( CV_BADRANGE_ERR );
case CV_PTLOC_VERTEX:
point = curr_point;
break;
case CV_PTLOC_ON_EDGE:
deleted_edge = curr_edge;
subdiv->recent_edge = curr_edge = cvSubdiv2DGetEdge( curr_edge, CV_PREV_AROUND_ORG );
cvSubdiv2DDeleteEdge( subdiv, deleted_edge );
/* no break */
case CV_PTLOC_INSIDE:
assert( curr_edge != 0 );
subdiv->is_geometry_valid = 0;
curr_point = cvSubdiv2DAddPoint( subdiv, pt, 0 );
CV_CHECK();
base_edge = cvSubdiv2DMakeEdge( subdiv );
first_point = cvSubdiv2DEdgeOrg( curr_edge );
cvSubdiv2DSetEdgePoints( base_edge, first_point, curr_point );
cvSubdiv2DSplice( base_edge, curr_edge );
do
{
base_edge = cvSubdiv2DConnectEdges( subdiv, curr_edge,
cvSubdiv2DSymEdge( base_edge ));
curr_edge = cvSubdiv2DGetEdge( base_edge, CV_PREV_AROUND_ORG );
}
while( cvSubdiv2DEdgeDst( curr_edge ) != first_point );
curr_edge = cvSubdiv2DGetEdge( base_edge, CV_PREV_AROUND_ORG );
max_edges = subdiv->quad_edges * 4;
for( i = 0; i < max_edges; i++ )
{
CvSubdiv2DPoint *temp_dst = 0, *curr_org = 0, *curr_dst = 0;
CvSubdiv2DEdge temp_edge = cvSubdiv2DGetEdge( curr_edge, CV_PREV_AROUND_ORG );
temp_dst = cvSubdiv2DEdgeDst( temp_edge );
curr_org = cvSubdiv2DEdgeOrg( curr_edge );
curr_dst = cvSubdiv2DEdgeDst( curr_edge );
if( icvIsRightOf( temp_dst->pt, curr_edge ) > 0 &&
icvIsPtInCircle3( curr_org->pt, temp_dst->pt,
curr_dst->pt, curr_point->pt ) < 0 )
{
cvSubdiv2DSwapEdges( curr_edge );
curr_edge = cvSubdiv2DGetEdge( curr_edge, CV_PREV_AROUND_ORG );
}
else if( curr_org == first_point )
{
break;
}
else
{
curr_edge = cvSubdiv2DGetEdge( cvSubdiv2DNextEdge( curr_edge ),
CV_PREV_AROUND_LEFT );
}
}
break;
default:
assert( 0 );
CV_ERROR_FROM_STATUS( CV_NOTDEFINED_ERR );
}
point = curr_point;
__END__;
//icvSubdiv2DCheck( subdiv );
return point;
}
CV_IMPL void
cvInitSubdivDelaunay2D( CvSubdiv2D * subdiv, CvRect rect )
{
float big_coord = 3.f * MAX( rect.width, rect.height );
CvPoint2D32f ppA, ppB, ppC;
CvSubdiv2DPoint *pA, *pB, *pC;
CvSubdiv2DEdge edge_AB, edge_BC, edge_CA;
float rx = (float) rect.x;
float ry = (float) rect.y;
CV_FUNCNAME( "cvSubdivDelaunay2DInit" );
__BEGIN__;
if( !subdiv )
CV_ERROR( CV_StsNullPtr, "" );
cvClearSet( (CvSet *) (subdiv->edges) );
cvClearSet( (CvSet *) subdiv );
subdiv->quad_edges = 0;
subdiv->recent_edge = 0;
subdiv->is_geometry_valid = 0;
subdiv->topleft = cvPoint2D32f( rx, ry );
subdiv->bottomright = cvPoint2D32f( rx + rect.width, ry + rect.height );
ppA = cvPoint2D32f( rx + big_coord, ry );
ppB = cvPoint2D32f( rx, ry + big_coord );
ppC = cvPoint2D32f( rx - big_coord, ry - big_coord );
pA = cvSubdiv2DAddPoint( subdiv, ppA, 0 );
pB = cvSubdiv2DAddPoint( subdiv, ppB, 0 );
pC = cvSubdiv2DAddPoint( subdiv, ppC, 0 );
edge_AB = cvSubdiv2DMakeEdge( subdiv );
edge_BC = cvSubdiv2DMakeEdge( subdiv );
edge_CA = cvSubdiv2DMakeEdge( subdiv );
cvSubdiv2DSetEdgePoints( edge_AB, pA, pB );
cvSubdiv2DSetEdgePoints( edge_BC, pB, pC );
cvSubdiv2DSetEdgePoints( edge_CA, pC, pA );
cvSubdiv2DSplice( edge_AB, cvSubdiv2DSymEdge( edge_CA ));
cvSubdiv2DSplice( edge_BC, cvSubdiv2DSymEdge( edge_AB ));
cvSubdiv2DSplice( edge_CA, cvSubdiv2DSymEdge( edge_BC ));
subdiv->recent_edge = edge_AB;
__END__;
}
CV_IMPL void
cvClearSubdivVoronoi2D( CvSubdiv2D * subdiv )
{
int elem_size;
int i, total;
CvSeqReader reader;
CV_FUNCNAME( "cvClearVoronoi2D" );
__BEGIN__;
if( !subdiv )
CV_ERROR( CV_StsNullPtr, "" );
/* clear pointers to voronoi points */
total = subdiv->edges->total;
elem_size = subdiv->edges->elem_size;
cvStartReadSeq( (CvSeq *) (subdiv->edges), &reader, 0 );
for( i = 0; i < total; i++ )
{
CvQuadEdge2D *quadedge = (CvQuadEdge2D *) reader.ptr;
quadedge->pt[1] = quadedge->pt[3] = 0;
CV_NEXT_SEQ_ELEM( elem_size, reader );
}
/* remove voronoi points */
total = subdiv->total;
elem_size = subdiv->elem_size;
cvStartReadSeq( (CvSeq *) subdiv, &reader, 0 );
for( i = 0; i < total; i++ )
{
CvSubdiv2DPoint *pt = (CvSubdiv2DPoint *) reader.ptr;
/* check for virtual point. it is also check that the point exists */
if( pt->flags & CV_SUBDIV2D_VIRTUAL_POINT_FLAG )
{
cvSetRemoveByPtr( (CvSet*)subdiv, pt );
}
CV_NEXT_SEQ_ELEM( elem_size, reader );
}
subdiv->is_geometry_valid = 0;
__END__;
}
CV_IMPL void
cvCalcSubdivVoronoi2D( CvSubdiv2D * subdiv )
{
CvSeqReader reader;
int i, total, elem_size;
CV_FUNCNAME( "cvCalcSubdivVoronoi2D" );
__BEGIN__;
if( !subdiv )
CV_ERROR( CV_StsNullPtr, "" );
/* check if it is already calculated */
if( subdiv->is_geometry_valid )
EXIT;
total = subdiv->edges->total;
elem_size = subdiv->edges->elem_size;
cvClearSubdivVoronoi2D( subdiv );
cvStartReadSeq( (CvSeq *) (subdiv->edges), &reader, 0 );
if( total <= 3 )
EXIT;
/* skip first three edges (bounding triangle) */
for( i = 0; i < 3; i++ )
CV_NEXT_SEQ_ELEM( elem_size, reader );
/* loop through all quad-edges */
for( ; i < total; i++ )
{
CvQuadEdge2D *quadedge = (CvQuadEdge2D *) (reader.ptr);
if( CV_IS_SET_ELEM( quadedge ))
{
CvSubdiv2DEdge edge0 = (CvSubdiv2DEdge) quadedge, edge1, edge2;
double a0, b0, c0, a1, b1, c1;
CvPoint2D32f virt_point;
CvSubdiv2DPoint *voronoi_point;
if( !quadedge->pt[3] )
{
edge1 = cvSubdiv2DGetEdge( edge0, CV_NEXT_AROUND_LEFT );
edge2 = cvSubdiv2DGetEdge( edge1, CV_NEXT_AROUND_LEFT );
icvCreateCenterNormalLine( edge0, &a0, &b0, &c0 );
icvCreateCenterNormalLine( edge1, &a1, &b1, &c1 );
icvIntersectLines3( &a0, &b0, &c0, &a1, &b1, &c1, &virt_point );
if( fabs( virt_point.x ) < FLT_MAX * 0.5 &&
fabs( virt_point.y ) < FLT_MAX * 0.5 )
{
voronoi_point = cvSubdiv2DAddPoint( subdiv, virt_point, 1 );
quadedge->pt[3] =
((CvQuadEdge2D *) (edge1 & ~3))->pt[3 - (edge1 & 2)] =
((CvQuadEdge2D *) (edge2 & ~3))->pt[3 - (edge2 & 2)] = voronoi_point;
}
}
if( !quadedge->pt[1] )
{
edge1 = cvSubdiv2DGetEdge( edge0, CV_NEXT_AROUND_RIGHT );
edge2 = cvSubdiv2DGetEdge( edge1, CV_NEXT_AROUND_RIGHT );
icvCreateCenterNormalLine( edge0, &a0, &b0, &c0 );
icvCreateCenterNormalLine( edge1, &a1, &b1, &c1 );
icvIntersectLines3( &a0, &b0, &c0, &a1, &b1, &c1, &virt_point );
if( fabs( virt_point.x ) < FLT_MAX * 0.5 &&
fabs( virt_point.y ) < FLT_MAX * 0.5 )
{
voronoi_point = cvSubdiv2DAddPoint( subdiv, virt_point, 1 );
quadedge->pt[1] =
((CvQuadEdge2D *) (edge1 & ~3))->pt[1 + (edge1 & 2)] =
((CvQuadEdge2D *) (edge2 & ~3))->pt[1 + (edge2 & 2)] = voronoi_point;
}
}
}
CV_NEXT_SEQ_ELEM( elem_size, reader );
}
subdiv->is_geometry_valid = 1;
__END__;
}
static int
icvIsRightOf2( const CvPoint2D32f& pt, const CvPoint2D32f& org, const CvPoint2D32f& diff )
{
Cv32suf cw_area;
cw_area.f = (org.x - pt.x)*diff.y - (org.y - pt.y)*diff.x;
return (cw_area.i > 0)*2 - (cw_area.i*2 != 0);
}
CV_IMPL CvSubdiv2DPoint*
cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt )
{
CvSubdiv2DPoint* point = 0;
CvPoint2D32f start;
CvPoint2D32f diff;
CvSubdiv2DPointLocation loc;
CvSubdiv2DEdge edge;
int i;
CV_FUNCNAME("cvFindNearestPoint2D");
__BEGIN__;
if( !subdiv )
CV_ERROR( CV_StsNullPtr, "" );
if( !CV_IS_SUBDIV2D( subdiv ))
CV_ERROR( CV_StsNullPtr, "" );
if( !subdiv->is_geometry_valid )
cvCalcSubdivVoronoi2D( subdiv );
loc = cvSubdiv2DLocate( subdiv, pt, &edge, &point );
switch( loc )
{
case CV_PTLOC_ON_EDGE:
case CV_PTLOC_INSIDE:
break;
default:
EXIT;
}
point = 0;
start = cvSubdiv2DEdgeOrg( edge )->pt;
diff.x = pt.x - start.x;
diff.y = pt.y - start.y;
edge = cvSubdiv2DRotateEdge( edge, 1 );
for( i = 0; i < subdiv->total; i++ )
{
CvPoint2D32f t;
for(;;)
{
assert( cvSubdiv2DEdgeDst( edge ));
t = cvSubdiv2DEdgeDst( edge )->pt;
if( icvIsRightOf2( t, start, diff ) >= 0 )
break;
edge = cvSubdiv2DGetEdge( edge, CV_NEXT_AROUND_LEFT );
}
for(;;)
{
assert( cvSubdiv2DEdgeOrg( edge ));
t = cvSubdiv2DEdgeOrg( edge )->pt;
if( icvIsRightOf2( t, start, diff ) < 0 )
break;
edge = cvSubdiv2DGetEdge( edge, CV_PREV_AROUND_LEFT );
}
{
CvPoint2D32f tempDiff = cvSubdiv2DEdgeDst( edge )->pt;
t = cvSubdiv2DEdgeOrg( edge )->pt;
tempDiff.x -= t.x;
tempDiff.y -= t.y;
if( icvIsRightOf2( pt, t, tempDiff ) >= 0 )
{
point = cvSubdiv2DEdgeOrg( cvSubdiv2DRotateEdge( edge, 3 ));
break;
}
}
edge = cvSubdiv2DSymEdge( edge );
}
__END__;
return point;
}
/* Removed from the main interface */
#if 0
/* Adds new isolated quadedge to the subdivision */
OPENCVAPI CvSubdiv2DEdge cvSubdiv2DMakeEdge( CvSubdiv2D* subdiv );
/* Adds new isolated point to subdivision */
OPENCVAPI CvSubdiv2DPoint* cvSubdiv2DAddPoint( CvSubdiv2D* subdiv,
CvPoint2D32f pt, int is_virtual );
/* Does a splice operation for two quadedges */
OPENCVAPI void cvSubdiv2DSplice( CvSubdiv2DEdge edgeA, CvSubdiv2DEdge edgeB );
/* Assigns ending [non-virtual] points for given quadedge */
OPENCVAPI void cvSubdiv2DSetEdgePoints( CvSubdiv2DEdge edge,
CvSubdiv2DPoint* org_pt,
CvSubdiv2DPoint* dst_pt );
/* Removes quadedge from subdivision */
OPENCVAPI void cvSubdiv2DDeleteEdge( CvSubdiv2D* subdiv, CvSubdiv2DEdge edge );
/* Connects estination point of the first edge with origin point of the second edge */
OPENCVAPI CvSubdiv2DEdge cvSubdiv2DConnectEdges( CvSubdiv2D* subdiv,
CvSubdiv2DEdge edgeA,
CvSubdiv2DEdge edgeB );
/* Swaps diagonal in two connected Delaunay facets */
OPENCVAPI void cvSubdiv2DSwapEdges( CvSubdiv2DEdge edge );
#endif
/* End of file. */

View File

@@ -0,0 +1,435 @@
/*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*/
#include "_cv.h"
#define ICV_DEF_INTEGRAL_OP_C1( flavor, arrtype, sumtype, sqsumtype, worktype, \
cast_macro, cast_sqr_macro ) \
static CvStatus CV_STDCALL \
icvIntegralImage_##flavor##_C1R( const arrtype* src, int srcstep,\
sumtype* sum, int sumstep, \
sqsumtype* sqsum, int sqsumstep,\
sumtype* tilted, int tiltedstep,\
CvSize size ) \
{ \
int x, y; \
sumtype s; \
sqsumtype sq; \
sumtype* buf = 0; \
\
srcstep /= sizeof(src[0]); \
\
memset( sum, 0, (size.width+1)*sizeof(sum[0])); \
sumstep /= sizeof(sum[0]); \
sum += sumstep + 1; \
\
if( sqsum ) \
{ \
memset( sqsum, 0, (size.width+1)*sizeof(sqsum[0])); \
sqsumstep /= sizeof(sqsum[0]); \
sqsum += sqsumstep + 1; \
} \
\
if( tilted ) \
{ \
memset( tilted, 0, (size.width+1)*sizeof(tilted[0])); \
tiltedstep /= sizeof(tilted[0]); \
tilted += tiltedstep + 1; \
} \
\
if( sqsum == 0 && tilted == 0 ) \
{ \
for( y = 0; y < size.height; y++, src += srcstep, \
sum += sumstep ) \
{ \
sum[-1] = 0; \
for( x = 0, s = 0; x < size.width; x++ ) \
{ \
sumtype t = cast_macro(src[x]); \
s += t; \
sum[x] = sum[x - sumstep] + s; \
} \
} \
} \
else if( tilted == 0 ) \
{ \
for( y = 0; y < size.height; y++, src += srcstep, \
sum += sumstep, sqsum += sqsumstep ) \
{ \
sum[-1] = 0; \
sqsum[-1] = 0; \
\
for( x = 0, s = 0, sq = 0; x < size.width; x++ ) \
{ \
worktype it = src[x]; \
sumtype t = cast_macro(it); \
sqsumtype tq = cast_sqr_macro(it); \
s += t; \
sq += tq; \
t = sum[x - sumstep] + s; \
tq = sqsum[x - sqsumstep] + sq; \
sum[x] = t; \
sqsum[x] = tq; \
} \
} \
} \
else \
{ \
if( sqsum == 0 ) \
{ \
assert(0); \
return CV_NULLPTR_ERR; \
} \
\
buf = (sumtype*)cvStackAlloc((size.width + 1 )* sizeof(buf[0]));\
sum[-1] = tilted[-1] = 0; \
sqsum[-1] = 0; \
\
for( x = 0, s = 0, sq = 0; x < size.width; x++ ) \
{ \
worktype it = src[x]; \
sumtype t = cast_macro(it); \
sqsumtype tq = cast_sqr_macro(it); \
buf[x] = tilted[x] = t; \
s += t; \
sq += tq; \
sum[x] = s; \
sqsum[x] = sq; \
} \
\
if( size.width == 1 ) \
buf[1] = 0; \
\
for( y = 1; y < size.height; y++ ) \
{ \
worktype it; \
sumtype t0; \
sqsumtype tq0; \
\
src += srcstep; \
sum += sumstep; \
sqsum += sqsumstep; \
tilted += tiltedstep; \
\
it = src[0/*x*/]; \
s = t0 = cast_macro(it); \
sq = tq0 = cast_sqr_macro(it); \
\
sum[-1] = 0; \
sqsum[-1] = 0; \
/*tilted[-1] = buf[0];*/ \
tilted[-1] = tilted[-tiltedstep]; \
\
sum[0] = sum[-sumstep] + t0; \
sqsum[0] = sqsum[-sqsumstep] + tq0; \
tilted[0] = tilted[-tiltedstep] + t0 + buf[1]; \
\
for( x = 1; x < size.width - 1; x++ ) \
{ \
sumtype t1 = buf[x]; \
buf[x-1] = t1 + t0; \
it = src[x]; \
t0 = cast_macro(it); \
tq0 = cast_sqr_macro(it); \
s += t0; \
sq += tq0; \
sum[x] = sum[x - sumstep] + s; \
sqsum[x] = sqsum[x - sqsumstep] + sq; \
t1 += buf[x+1] + t0 + tilted[x - tiltedstep - 1];\
tilted[x] = t1; \
} \
\
if( size.width > 1 ) \
{ \
sumtype t1 = buf[x]; \
buf[x-1] = t1 + t0; \
it = src[x]; /*+*/ \
t0 = cast_macro(it); \
tq0 = cast_sqr_macro(it); \
s += t0; \
sq += tq0; \
sum[x] = sum[x - sumstep] + s; \
sqsum[x] = sqsum[x - sqsumstep] + sq; \
tilted[x] = t0 + t1 + tilted[x - tiltedstep - 1];\
buf[x] = t0; \
} \
} \
} \
\
return CV_OK; \
}
ICV_DEF_INTEGRAL_OP_C1( 8u32s, uchar, int, double, int, CV_NOP, CV_8TO32F_SQR )
ICV_DEF_INTEGRAL_OP_C1( 8u64f, uchar, double, double, int, CV_8TO32F, CV_8TO32F_SQR )
ICV_DEF_INTEGRAL_OP_C1( 32f64f, float, double, double, double, CV_NOP, CV_SQR )
ICV_DEF_INTEGRAL_OP_C1( 64f, double, double, double, double, CV_NOP, CV_SQR )
#define ICV_DEF_INTEGRAL_OP_CN( flavor, arrtype, sumtype, sqsumtype, \
worktype, cast_macro, cast_sqr_macro ) \
static CvStatus CV_STDCALL \
icvIntegralImage_##flavor##_CnR( const arrtype* src, int srcstep,\
sumtype* sum, int sumstep, \
sqsumtype* sqsum, int sqsumstep,\
CvSize size, int cn ) \
{ \
int x, y; \
srcstep /= sizeof(src[0]); \
\
memset( sum, 0, (size.width+1)*cn*sizeof(sum[0])); \
sumstep /= sizeof(sum[0]); \
sum += sumstep + cn; \
\
if( sqsum ) \
{ \
memset( sqsum, 0, (size.width+1)*cn*sizeof(sqsum[0])); \
sqsumstep /= sizeof(sqsum[0]); \
sqsum += sqsumstep + cn; \
} \
\
size.width *= cn; \
\
if( sqsum == 0 ) \
{ \
for( y = 0; y < size.height; y++, src += srcstep, \
sum += sumstep ) \
{ \
for( x = -cn; x < 0; x++ ) \
sum[x] = 0; \
\
for( x = 0; x < size.width; x++ ) \
sum[x] = cast_macro(src[x]) + sum[x - cn]; \
\
for( x = 0; x < size.width; x++ ) \
sum[x] = sum[x] + sum[x - sumstep]; \
} \
} \
else \
{ \
for( y = 0; y < size.height; y++, src += srcstep, \
sum += sumstep, sqsum += sqsumstep ) \
{ \
for( x = -cn; x < 0; x++ ) \
{ \
sum[x] = 0; \
sqsum[x] = 0; \
} \
\
for( x = 0; x < size.width; x++ ) \
{ \
worktype it = src[x]; \
sumtype t = cast_macro(it) + sum[x-cn]; \
sqsumtype tq = cast_sqr_macro(it) + sqsum[x-cn];\
sum[x] = t; \
sqsum[x] = tq; \
} \
\
for( x = 0; x < size.width; x++ ) \
{ \
sumtype t = sum[x] + sum[x - sumstep]; \
sqsumtype tq = sqsum[x] + sqsum[x - sqsumstep]; \
sum[x] = t; \
sqsum[x] = tq; \
} \
} \
} \
\
return CV_OK; \
}
ICV_DEF_INTEGRAL_OP_CN( 8u32s, uchar, int, double, int, CV_NOP, CV_8TO32F_SQR )
ICV_DEF_INTEGRAL_OP_CN( 8u64f, uchar, double, double, int, CV_8TO32F, CV_8TO32F_SQR )
ICV_DEF_INTEGRAL_OP_CN( 32f64f, float, double, double, double, CV_NOP, CV_SQR )
ICV_DEF_INTEGRAL_OP_CN( 64f, double, double, double, double, CV_NOP, CV_SQR )
static void icvInitIntegralImageTable( CvFuncTable* table_c1, CvFuncTable* table_cn )
{
table_c1->fn_2d[CV_8U] = (void*)icvIntegralImage_8u64f_C1R;
table_c1->fn_2d[CV_32F] = (void*)icvIntegralImage_32f64f_C1R;
table_c1->fn_2d[CV_64F] = (void*)icvIntegralImage_64f_C1R;
table_cn->fn_2d[CV_8U] = (void*)icvIntegralImage_8u64f_CnR;
table_cn->fn_2d[CV_32F] = (void*)icvIntegralImage_32f64f_CnR;
table_cn->fn_2d[CV_64F] = (void*)icvIntegralImage_64f_CnR;
}
typedef CvStatus (CV_STDCALL * CvIntegralImageFuncC1)(
const void* src, int srcstep, void* sum, int sumstep,
void* sqsum, int sqsumstep, void* tilted, int tiltedstep,
CvSize size );
typedef CvStatus (CV_STDCALL * CvIntegralImageFuncCn)(
const void* src, int srcstep, void* sum, int sumstep,
void* sqsum, int sqsumstep, CvSize size, int cn );
icvIntegral_8u32s_C1R_t icvIntegral_8u32s_C1R_p = 0;
icvSqrIntegral_8u32s64f_C1R_t icvSqrIntegral_8u32s64f_C1R_p = 0;
CV_IMPL void
cvIntegral( const CvArr* image, CvArr* sumImage,
CvArr* sumSqImage, CvArr* tiltedSumImage )
{
static CvFuncTable tab_c1, tab_cn;
static int inittab = 0;
CV_FUNCNAME( "cvIntegralImage" );
__BEGIN__;
CvMat src_stub, *src = (CvMat*)image;
CvMat sum_stub, *sum = (CvMat*)sumImage;
CvMat sqsum_stub, *sqsum = (CvMat*)sumSqImage;
CvMat tilted_stub, *tilted = (CvMat*)tiltedSumImage;
int coi0 = 0, coi1 = 0, coi2 = 0, coi3 = 0;
int depth, cn;
int src_step, sum_step, sqsum_step, tilted_step;
CvIntegralImageFuncC1 func_c1 = 0;
CvIntegralImageFuncCn func_cn = 0;
CvSize size;
if( !inittab )
{
icvInitIntegralImageTable( &tab_c1, &tab_cn );
inittab = 1;
}
CV_CALL( src = cvGetMat( src, &src_stub, &coi0 ));
CV_CALL( sum = cvGetMat( sum, &sum_stub, &coi1 ));
if( sum->width != src->width + 1 ||
sum->height != src->height + 1 )
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( CV_MAT_DEPTH( sum->type ) != CV_64F &&
(CV_MAT_DEPTH( src->type ) != CV_8U ||
CV_MAT_DEPTH( sum->type ) != CV_32S ) ||
!CV_ARE_CNS_EQ( src, sum ))
CV_ERROR( CV_StsUnsupportedFormat,
"Sum array must have 64f type (or 32s type in case of 8u source array) "
"and the same number of channels as the source array" );
if( sqsum )
{
CV_CALL( sqsum = cvGetMat( sqsum, &sqsum_stub, &coi2 ));
if( !CV_ARE_SIZES_EQ( sum, sqsum ) )
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( CV_MAT_DEPTH( sqsum->type ) != CV_64F || !CV_ARE_CNS_EQ( src, sqsum ))
CV_ERROR( CV_StsUnsupportedFormat,
"Squares sum array must be 64f "
"and the same number of channels as the source array" );
}
if( tilted )
{
if( !sqsum )
CV_ERROR( CV_StsNullPtr,
"Squared sum array must be passed if tilted sum array is passed" );
CV_CALL( tilted = cvGetMat( tilted, &tilted_stub, &coi3 ));
if( !CV_ARE_SIZES_EQ( sum, tilted ) )
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( !CV_ARE_TYPES_EQ( sum, tilted ) )
CV_ERROR( CV_StsUnmatchedFormats,
"Sum and tilted sum must have the same types" );
if( CV_MAT_CN(tilted->type) != 1 )
CV_ERROR( CV_StsNotImplemented,
"Tilted sum can not be computed for multi-channel arrays" );
}
if( coi0 || coi1 || coi2 || coi3 )
CV_ERROR( CV_BadCOI, "COI is not supported by the function" );
depth = CV_MAT_DEPTH(src->type);
cn = CV_MAT_CN(src->type);
if( CV_MAT_DEPTH( sum->type ) == CV_32S )
{
func_c1 = (CvIntegralImageFuncC1)icvIntegralImage_8u32s_C1R;
func_cn = (CvIntegralImageFuncCn)icvIntegralImage_8u32s_CnR;
}
else
{
func_c1 = (CvIntegralImageFuncC1)tab_c1.fn_2d[depth];
func_cn = (CvIntegralImageFuncCn)tab_cn.fn_2d[depth];
if( !func_c1 && !func_cn )
CV_ERROR( CV_StsUnsupportedFormat, "This source image format is unsupported" );
}
size = cvGetMatSize(src);
src_step = src->step ? src->step : CV_STUB_STEP;
sum_step = sum->step ? sum->step : CV_STUB_STEP;
sqsum_step = !sqsum ? 0 : sqsum->step ? sqsum->step : CV_STUB_STEP;
tilted_step = !tilted ? 0 : tilted->step ? tilted->step : CV_STUB_STEP;
if( cn == 1 )
{
if( depth == CV_8U && !tilted && CV_MAT_DEPTH(sum->type) == CV_32S )
{
if( !sqsum && icvIntegral_8u32s_C1R_p &&
icvIntegral_8u32s_C1R_p( src->data.ptr, src_step,
sum->data.i, sum_step, size, 0 ) >= 0 )
EXIT;
if( sqsum && icvSqrIntegral_8u32s64f_C1R_p &&
icvSqrIntegral_8u32s64f_C1R_p( src->data.ptr, src_step, sum->data.i,
sum_step, sqsum->data.db, sqsum_step, size, 0, 0 ) >= 0 )
EXIT;
}
IPPI_CALL( func_c1( src->data.ptr, src_step, sum->data.ptr, sum_step,
sqsum ? sqsum->data.ptr : 0, sqsum_step,
tilted ? tilted->data.ptr : 0, tilted_step, size ));
}
else
{
IPPI_CALL( func_cn( src->data.ptr, src_step, sum->data.ptr, sum_step,
sqsum ? sqsum->data.ptr : 0, sqsum_step, size, cn ));
}
__END__;
}
/* End of file. */

View File

@@ -0,0 +1,59 @@
/*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*/
#include "_cv.h"
#undef IPCVAPI_EX
#define IPCVAPI_EX(type,func_name,names,modules,arg) \
{ (void**)&func_name##_p, (void*)(size_t)-1, names, modules, 0 },
static CvPluginFuncInfo cv_ipp_tab[] =
{
#undef _CV_IPP_H_
#include "_cvipp.h"
#undef _CV_IPP_H_
{0, 0, 0, 0, 0}
};
static CvModuleInfo cv_info = { 0, "cv", CV_VERSION, cv_ipp_tab };
CvModule cv_module( &cv_info );
/* End of file. */

View File

@@ -0,0 +1,214 @@
/* ////////////////////////////////////////////////////////////////////
//
// CvMat helper tables
//
// */
#include "_cv.h"
const float icv8x32fTab_cv[] =
{
-256.f, -255.f, -254.f, -253.f, -252.f, -251.f, -250.f, -249.f,
-248.f, -247.f, -246.f, -245.f, -244.f, -243.f, -242.f, -241.f,
-240.f, -239.f, -238.f, -237.f, -236.f, -235.f, -234.f, -233.f,
-232.f, -231.f, -230.f, -229.f, -228.f, -227.f, -226.f, -225.f,
-224.f, -223.f, -222.f, -221.f, -220.f, -219.f, -218.f, -217.f,
-216.f, -215.f, -214.f, -213.f, -212.f, -211.f, -210.f, -209.f,
-208.f, -207.f, -206.f, -205.f, -204.f, -203.f, -202.f, -201.f,
-200.f, -199.f, -198.f, -197.f, -196.f, -195.f, -194.f, -193.f,
-192.f, -191.f, -190.f, -189.f, -188.f, -187.f, -186.f, -185.f,
-184.f, -183.f, -182.f, -181.f, -180.f, -179.f, -178.f, -177.f,
-176.f, -175.f, -174.f, -173.f, -172.f, -171.f, -170.f, -169.f,
-168.f, -167.f, -166.f, -165.f, -164.f, -163.f, -162.f, -161.f,
-160.f, -159.f, -158.f, -157.f, -156.f, -155.f, -154.f, -153.f,
-152.f, -151.f, -150.f, -149.f, -148.f, -147.f, -146.f, -145.f,
-144.f, -143.f, -142.f, -141.f, -140.f, -139.f, -138.f, -137.f,
-136.f, -135.f, -134.f, -133.f, -132.f, -131.f, -130.f, -129.f,
-128.f, -127.f, -126.f, -125.f, -124.f, -123.f, -122.f, -121.f,
-120.f, -119.f, -118.f, -117.f, -116.f, -115.f, -114.f, -113.f,
-112.f, -111.f, -110.f, -109.f, -108.f, -107.f, -106.f, -105.f,
-104.f, -103.f, -102.f, -101.f, -100.f, -99.f, -98.f, -97.f,
-96.f, -95.f, -94.f, -93.f, -92.f, -91.f, -90.f, -89.f,
-88.f, -87.f, -86.f, -85.f, -84.f, -83.f, -82.f, -81.f,
-80.f, -79.f, -78.f, -77.f, -76.f, -75.f, -74.f, -73.f,
-72.f, -71.f, -70.f, -69.f, -68.f, -67.f, -66.f, -65.f,
-64.f, -63.f, -62.f, -61.f, -60.f, -59.f, -58.f, -57.f,
-56.f, -55.f, -54.f, -53.f, -52.f, -51.f, -50.f, -49.f,
-48.f, -47.f, -46.f, -45.f, -44.f, -43.f, -42.f, -41.f,
-40.f, -39.f, -38.f, -37.f, -36.f, -35.f, -34.f, -33.f,
-32.f, -31.f, -30.f, -29.f, -28.f, -27.f, -26.f, -25.f,
-24.f, -23.f, -22.f, -21.f, -20.f, -19.f, -18.f, -17.f,
-16.f, -15.f, -14.f, -13.f, -12.f, -11.f, -10.f, -9.f,
-8.f, -7.f, -6.f, -5.f, -4.f, -3.f, -2.f, -1.f,
0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f,
8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f,
16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f,
24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f,
32.f, 33.f, 34.f, 35.f, 36.f, 37.f, 38.f, 39.f,
40.f, 41.f, 42.f, 43.f, 44.f, 45.f, 46.f, 47.f,
48.f, 49.f, 50.f, 51.f, 52.f, 53.f, 54.f, 55.f,
56.f, 57.f, 58.f, 59.f, 60.f, 61.f, 62.f, 63.f,
64.f, 65.f, 66.f, 67.f, 68.f, 69.f, 70.f, 71.f,
72.f, 73.f, 74.f, 75.f, 76.f, 77.f, 78.f, 79.f,
80.f, 81.f, 82.f, 83.f, 84.f, 85.f, 86.f, 87.f,
88.f, 89.f, 90.f, 91.f, 92.f, 93.f, 94.f, 95.f,
96.f, 97.f, 98.f, 99.f, 100.f, 101.f, 102.f, 103.f,
104.f, 105.f, 106.f, 107.f, 108.f, 109.f, 110.f, 111.f,
112.f, 113.f, 114.f, 115.f, 116.f, 117.f, 118.f, 119.f,
120.f, 121.f, 122.f, 123.f, 124.f, 125.f, 126.f, 127.f,
128.f, 129.f, 130.f, 131.f, 132.f, 133.f, 134.f, 135.f,
136.f, 137.f, 138.f, 139.f, 140.f, 141.f, 142.f, 143.f,
144.f, 145.f, 146.f, 147.f, 148.f, 149.f, 150.f, 151.f,
152.f, 153.f, 154.f, 155.f, 156.f, 157.f, 158.f, 159.f,
160.f, 161.f, 162.f, 163.f, 164.f, 165.f, 166.f, 167.f,
168.f, 169.f, 170.f, 171.f, 172.f, 173.f, 174.f, 175.f,
176.f, 177.f, 178.f, 179.f, 180.f, 181.f, 182.f, 183.f,
184.f, 185.f, 186.f, 187.f, 188.f, 189.f, 190.f, 191.f,
192.f, 193.f, 194.f, 195.f, 196.f, 197.f, 198.f, 199.f,
200.f, 201.f, 202.f, 203.f, 204.f, 205.f, 206.f, 207.f,
208.f, 209.f, 210.f, 211.f, 212.f, 213.f, 214.f, 215.f,
216.f, 217.f, 218.f, 219.f, 220.f, 221.f, 222.f, 223.f,
224.f, 225.f, 226.f, 227.f, 228.f, 229.f, 230.f, 231.f,
232.f, 233.f, 234.f, 235.f, 236.f, 237.f, 238.f, 239.f,
240.f, 241.f, 242.f, 243.f, 244.f, 245.f, 246.f, 247.f,
248.f, 249.f, 250.f, 251.f, 252.f, 253.f, 254.f, 255.f,
256.f, 257.f, 258.f, 259.f, 260.f, 261.f, 262.f, 263.f,
264.f, 265.f, 266.f, 267.f, 268.f, 269.f, 270.f, 271.f,
272.f, 273.f, 274.f, 275.f, 276.f, 277.f, 278.f, 279.f,
280.f, 281.f, 282.f, 283.f, 284.f, 285.f, 286.f, 287.f,
288.f, 289.f, 290.f, 291.f, 292.f, 293.f, 294.f, 295.f,
296.f, 297.f, 298.f, 299.f, 300.f, 301.f, 302.f, 303.f,
304.f, 305.f, 306.f, 307.f, 308.f, 309.f, 310.f, 311.f,
312.f, 313.f, 314.f, 315.f, 316.f, 317.f, 318.f, 319.f,
320.f, 321.f, 322.f, 323.f, 324.f, 325.f, 326.f, 327.f,
328.f, 329.f, 330.f, 331.f, 332.f, 333.f, 334.f, 335.f,
336.f, 337.f, 338.f, 339.f, 340.f, 341.f, 342.f, 343.f,
344.f, 345.f, 346.f, 347.f, 348.f, 349.f, 350.f, 351.f,
352.f, 353.f, 354.f, 355.f, 356.f, 357.f, 358.f, 359.f,
360.f, 361.f, 362.f, 363.f, 364.f, 365.f, 366.f, 367.f,
368.f, 369.f, 370.f, 371.f, 372.f, 373.f, 374.f, 375.f,
376.f, 377.f, 378.f, 379.f, 380.f, 381.f, 382.f, 383.f,
384.f, 385.f, 386.f, 387.f, 388.f, 389.f, 390.f, 391.f,
392.f, 393.f, 394.f, 395.f, 396.f, 397.f, 398.f, 399.f,
400.f, 401.f, 402.f, 403.f, 404.f, 405.f, 406.f, 407.f,
408.f, 409.f, 410.f, 411.f, 412.f, 413.f, 414.f, 415.f,
416.f, 417.f, 418.f, 419.f, 420.f, 421.f, 422.f, 423.f,
424.f, 425.f, 426.f, 427.f, 428.f, 429.f, 430.f, 431.f,
432.f, 433.f, 434.f, 435.f, 436.f, 437.f, 438.f, 439.f,
440.f, 441.f, 442.f, 443.f, 444.f, 445.f, 446.f, 447.f,
448.f, 449.f, 450.f, 451.f, 452.f, 453.f, 454.f, 455.f,
456.f, 457.f, 458.f, 459.f, 460.f, 461.f, 462.f, 463.f,
464.f, 465.f, 466.f, 467.f, 468.f, 469.f, 470.f, 471.f,
472.f, 473.f, 474.f, 475.f, 476.f, 477.f, 478.f, 479.f,
480.f, 481.f, 482.f, 483.f, 484.f, 485.f, 486.f, 487.f,
488.f, 489.f, 490.f, 491.f, 492.f, 493.f, 494.f, 495.f,
496.f, 497.f, 498.f, 499.f, 500.f, 501.f, 502.f, 503.f,
504.f, 505.f, 506.f, 507.f, 508.f, 509.f, 510.f, 511.f,
};
const float icv8x32fSqrTab[] =
{
16384.f, 16129.f, 15876.f, 15625.f, 15376.f, 15129.f, 14884.f, 14641.f,
14400.f, 14161.f, 13924.f, 13689.f, 13456.f, 13225.f, 12996.f, 12769.f,
12544.f, 12321.f, 12100.f, 11881.f, 11664.f, 11449.f, 11236.f, 11025.f,
10816.f, 10609.f, 10404.f, 10201.f, 10000.f, 9801.f, 9604.f, 9409.f,
9216.f, 9025.f, 8836.f, 8649.f, 8464.f, 8281.f, 8100.f, 7921.f,
7744.f, 7569.f, 7396.f, 7225.f, 7056.f, 6889.f, 6724.f, 6561.f,
6400.f, 6241.f, 6084.f, 5929.f, 5776.f, 5625.f, 5476.f, 5329.f,
5184.f, 5041.f, 4900.f, 4761.f, 4624.f, 4489.f, 4356.f, 4225.f,
4096.f, 3969.f, 3844.f, 3721.f, 3600.f, 3481.f, 3364.f, 3249.f,
3136.f, 3025.f, 2916.f, 2809.f, 2704.f, 2601.f, 2500.f, 2401.f,
2304.f, 2209.f, 2116.f, 2025.f, 1936.f, 1849.f, 1764.f, 1681.f,
1600.f, 1521.f, 1444.f, 1369.f, 1296.f, 1225.f, 1156.f, 1089.f,
1024.f, 961.f, 900.f, 841.f, 784.f, 729.f, 676.f, 625.f,
576.f, 529.f, 484.f, 441.f, 400.f, 361.f, 324.f, 289.f,
256.f, 225.f, 196.f, 169.f, 144.f, 121.f, 100.f, 81.f,
64.f, 49.f, 36.f, 25.f, 16.f, 9.f, 4.f, 1.f,
0.f, 1.f, 4.f, 9.f, 16.f, 25.f, 36.f, 49.f,
64.f, 81.f, 100.f, 121.f, 144.f, 169.f, 196.f, 225.f,
256.f, 289.f, 324.f, 361.f, 400.f, 441.f, 484.f, 529.f,
576.f, 625.f, 676.f, 729.f, 784.f, 841.f, 900.f, 961.f,
1024.f, 1089.f, 1156.f, 1225.f, 1296.f, 1369.f, 1444.f, 1521.f,
1600.f, 1681.f, 1764.f, 1849.f, 1936.f, 2025.f, 2116.f, 2209.f,
2304.f, 2401.f, 2500.f, 2601.f, 2704.f, 2809.f, 2916.f, 3025.f,
3136.f, 3249.f, 3364.f, 3481.f, 3600.f, 3721.f, 3844.f, 3969.f,
4096.f, 4225.f, 4356.f, 4489.f, 4624.f, 4761.f, 4900.f, 5041.f,
5184.f, 5329.f, 5476.f, 5625.f, 5776.f, 5929.f, 6084.f, 6241.f,
6400.f, 6561.f, 6724.f, 6889.f, 7056.f, 7225.f, 7396.f, 7569.f,
7744.f, 7921.f, 8100.f, 8281.f, 8464.f, 8649.f, 8836.f, 9025.f,
9216.f, 9409.f, 9604.f, 9801.f, 10000.f, 10201.f, 10404.f, 10609.f,
10816.f, 11025.f, 11236.f, 11449.f, 11664.f, 11881.f, 12100.f, 12321.f,
12544.f, 12769.f, 12996.f, 13225.f, 13456.f, 13689.f, 13924.f, 14161.f,
14400.f, 14641.f, 14884.f, 15129.f, 15376.f, 15625.f, 15876.f, 16129.f,
16384.f, 16641.f, 16900.f, 17161.f, 17424.f, 17689.f, 17956.f, 18225.f,
18496.f, 18769.f, 19044.f, 19321.f, 19600.f, 19881.f, 20164.f, 20449.f,
20736.f, 21025.f, 21316.f, 21609.f, 21904.f, 22201.f, 22500.f, 22801.f,
23104.f, 23409.f, 23716.f, 24025.f, 24336.f, 24649.f, 24964.f, 25281.f,
25600.f, 25921.f, 26244.f, 26569.f, 26896.f, 27225.f, 27556.f, 27889.f,
28224.f, 28561.f, 28900.f, 29241.f, 29584.f, 29929.f, 30276.f, 30625.f,
30976.f, 31329.f, 31684.f, 32041.f, 32400.f, 32761.f, 33124.f, 33489.f,
33856.f, 34225.f, 34596.f, 34969.f, 35344.f, 35721.f, 36100.f, 36481.f,
36864.f, 37249.f, 37636.f, 38025.f, 38416.f, 38809.f, 39204.f, 39601.f,
40000.f, 40401.f, 40804.f, 41209.f, 41616.f, 42025.f, 42436.f, 42849.f,
43264.f, 43681.f, 44100.f, 44521.f, 44944.f, 45369.f, 45796.f, 46225.f,
46656.f, 47089.f, 47524.f, 47961.f, 48400.f, 48841.f, 49284.f, 49729.f,
50176.f, 50625.f, 51076.f, 51529.f, 51984.f, 52441.f, 52900.f, 53361.f,
53824.f, 54289.f, 54756.f, 55225.f, 55696.f, 56169.f, 56644.f, 57121.f,
57600.f, 58081.f, 58564.f, 59049.f, 59536.f, 60025.f, 60516.f, 61009.f,
61504.f, 62001.f, 62500.f, 63001.f, 63504.f, 64009.f, 64516.f, 65025.f
};
const uchar icvSaturate8u_cv[] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255
};
/* End of file. */

View File

@@ -0,0 +1,506 @@
/*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*/
#include "_cv.h"
void
icvCrossCorr( const CvArr* _img, const CvArr* _templ, CvArr* _corr, CvPoint anchor )
{
const double block_scale = 4.5;
const int min_block_size = 256;
CvMat* dft_img = 0;
CvMat* dft_templ = 0;
void* buf = 0;
CV_FUNCNAME( "icvCrossCorr" );
__BEGIN__;
CvMat istub, *img = (CvMat*)_img;
CvMat tstub, *templ = (CvMat*)_templ;
CvMat cstub, *corr = (CvMat*)_corr;
CvMat sstub, dstub, *src, *dst, temp;
CvSize dftsize, blocksize;
CvMat* planes[] = { 0, 0, 0, 0 };
int x, y, i, yofs, buf_size = 0;
int depth, templ_depth, corr_depth, max_depth = CV_32F, cn, templ_cn, corr_cn;
CV_CALL( img = cvGetMat( img, &istub ));
CV_CALL( templ = cvGetMat( templ, &tstub ));
CV_CALL( corr = cvGetMat( corr, &cstub ));
if( CV_MAT_DEPTH( img->type ) != CV_8U &&
CV_MAT_DEPTH( img->type ) != CV_16U &&
CV_MAT_DEPTH( img->type ) != CV_32F )
CV_ERROR( CV_StsUnsupportedFormat,
"The function supports only 8u, 16u and 32f data types" );
if( !CV_ARE_DEPTHS_EQ( img, templ ) && CV_MAT_DEPTH( templ->type ) != CV_32F )
CV_ERROR( CV_StsUnsupportedFormat,
"Template (kernel) must be of the same depth as the input image, or be 32f" );
if( !CV_ARE_DEPTHS_EQ( img, corr ) && CV_MAT_DEPTH( corr->type ) != CV_32F &&
CV_MAT_DEPTH( corr->type ) != CV_64F )
CV_ERROR( CV_StsUnsupportedFormat,
"The output image must have the same depth as the input image, or be 32f/64f" );
if( (!CV_ARE_CNS_EQ( img, corr ) || CV_MAT_CN(templ->type) > 1) &&
(CV_MAT_CN( corr->type ) > 1 || !CV_ARE_CNS_EQ( img, templ)) )
CV_ERROR( CV_StsUnsupportedFormat,
"The output must have the same number of channels as the input (when the template has 1 channel), "
"or the output must have 1 channel when the input and the template have the same number of channels" );
depth = CV_MAT_DEPTH(img->type);
cn = CV_MAT_CN(img->type);
templ_depth = CV_MAT_DEPTH(templ->type);
templ_cn = CV_MAT_CN(templ->type);
corr_depth = CV_MAT_DEPTH(corr->type);
corr_cn = CV_MAT_CN(corr->type);
max_depth = MAX( max_depth, templ_depth );
max_depth = MAX( max_depth, depth );
max_depth = MAX( max_depth, corr_depth );
if( depth > CV_8U )
max_depth = CV_64F;
if( img->cols < templ->cols || img->rows < templ->rows )
CV_ERROR( CV_StsUnmatchedSizes,
"Such a combination of image and template/filter size is not supported" );
if( corr->rows > img->rows + templ->rows - 1 ||
corr->cols > img->cols + templ->cols - 1 )
CV_ERROR( CV_StsUnmatchedSizes,
"output image should not be greater than (W + w - 1)x(H + h - 1)" );
blocksize.width = cvRound(templ->cols*block_scale);
blocksize.width = MAX( blocksize.width, min_block_size - templ->cols + 1 );
blocksize.width = MIN( blocksize.width, corr->cols );
blocksize.height = cvRound(templ->rows*block_scale);
blocksize.height = MAX( blocksize.height, min_block_size - templ->rows + 1 );
blocksize.height = MIN( blocksize.height, corr->rows );
dftsize.width = cvGetOptimalDFTSize(blocksize.width + templ->cols - 1);
if( dftsize.width == 1 )
dftsize.width = 2;
dftsize.height = cvGetOptimalDFTSize(blocksize.height + templ->rows - 1);
if( dftsize.width <= 0 || dftsize.height <= 0 )
CV_ERROR( CV_StsOutOfRange, "the input arrays are too big" );
// recompute block size
blocksize.width = dftsize.width - templ->cols + 1;
blocksize.width = MIN( blocksize.width, corr->cols );
blocksize.height = dftsize.height - templ->rows + 1;
blocksize.height = MIN( blocksize.height, corr->rows );
CV_CALL( dft_img = cvCreateMat( dftsize.height, dftsize.width, max_depth ));
CV_CALL( dft_templ = cvCreateMat( dftsize.height*templ_cn, dftsize.width, max_depth ));
if( templ_cn > 1 && templ_depth != max_depth )
buf_size = templ->cols*templ->rows*CV_ELEM_SIZE(templ_depth);
if( cn > 1 && depth != max_depth )
buf_size = MAX( buf_size, (blocksize.width + templ->cols - 1)*
(blocksize.height + templ->rows - 1)*CV_ELEM_SIZE(depth));
if( (corr_cn > 1 || cn > 1) && corr_depth != max_depth )
buf_size = MAX( buf_size, blocksize.width*blocksize.height*CV_ELEM_SIZE(corr_depth));
if( buf_size > 0 )
CV_CALL( buf = cvAlloc(buf_size) );
// compute DFT of each template plane
for( i = 0; i < templ_cn; i++ )
{
yofs = i*dftsize.height;
src = templ;
dst = cvGetSubRect( dft_templ, &dstub, cvRect(0,yofs,templ->cols,templ->rows));
if( templ_cn > 1 )
{
planes[i] = templ_depth == max_depth ? dst :
cvInitMatHeader( &temp, templ->rows, templ->cols, templ_depth, buf );
cvSplit( templ, planes[0], planes[1], planes[2], planes[3] );
src = planes[i];
planes[i] = 0;
}
if( dst != src )
cvConvert( src, dst );
if( dft_templ->cols > templ->cols )
{
cvGetSubRect( dft_templ, dst, cvRect(templ->cols, yofs,
dft_templ->cols - templ->cols, templ->rows) );
cvZero( dst );
}
cvGetSubRect( dft_templ, dst, cvRect(0,yofs,dftsize.width,dftsize.height) );
cvDFT( dst, dst, CV_DXT_FORWARD + CV_DXT_SCALE, templ->rows );
}
// calculate correlation by blocks
for( y = 0; y < corr->rows; y += blocksize.height )
{
for( x = 0; x < corr->cols; x += blocksize.width )
{
CvSize csz = { blocksize.width, blocksize.height }, isz;
int x0 = x - anchor.x, y0 = y - anchor.y;
int x1 = MAX( 0, x0 ), y1 = MAX( 0, y0 ), x2, y2;
csz.width = MIN( csz.width, corr->cols - x );
csz.height = MIN( csz.height, corr->rows - y );
isz.width = csz.width + templ->cols - 1;
isz.height = csz.height + templ->rows - 1;
x2 = MIN( img->cols, x0 + isz.width );
y2 = MIN( img->rows, y0 + isz.height );
for( i = 0; i < cn; i++ )
{
CvMat dstub1, *dst1;
yofs = i*dftsize.height;
src = cvGetSubRect( img, &sstub, cvRect(x1,y1,x2-x1,y2-y1) );
dst = cvGetSubRect( dft_img, &dstub, cvRect(0,0,isz.width,isz.height) );
dst1 = dst;
if( x2 - x1 < isz.width || y2 - y1 < isz.height )
dst1 = cvGetSubRect( dft_img, &dstub1,
cvRect( x1 - x0, y1 - y0, x2 - x1, y2 - y1 ));
if( cn > 1 )
{
planes[i] = dst1;
if( depth != max_depth )
planes[i] = cvInitMatHeader( &temp, y2 - y1, x2 - x1, depth, buf );
cvSplit( src, planes[0], planes[1], planes[2], planes[3] );
src = planes[i];
planes[i] = 0;
}
if( dst1 != src )
cvConvert( src, dst1 );
if( dst != dst1 )
cvCopyMakeBorder( dst1, dst, cvPoint(x1 - x0, y1 - y0), IPL_BORDER_REPLICATE );
if( dftsize.width > isz.width )
{
cvGetSubRect( dft_img, dst, cvRect(isz.width, 0,
dftsize.width - isz.width,dftsize.height) );
cvZero( dst );
}
cvDFT( dft_img, dft_img, CV_DXT_FORWARD, isz.height );
cvGetSubRect( dft_templ, dst,
cvRect(0,(templ_cn>1?yofs:0),dftsize.width,dftsize.height) );
cvMulSpectrums( dft_img, dst, dft_img, CV_DXT_MUL_CONJ );
cvDFT( dft_img, dft_img, CV_DXT_INVERSE, csz.height );
src = cvGetSubRect( dft_img, &sstub, cvRect(0,0,csz.width,csz.height) );
dst = cvGetSubRect( corr, &dstub, cvRect(x,y,csz.width,csz.height) );
if( corr_cn > 1 )
{
planes[i] = src;
if( corr_depth != max_depth )
{
planes[i] = cvInitMatHeader( &temp, csz.height, csz.width, corr_depth, buf );
cvConvert( src, planes[i] );
}
cvMerge( planes[0], planes[1], planes[2], planes[3], dst );
planes[i] = 0;
}
else
{
if( i == 0 )
cvConvert( src, dst );
else
{
if( max_depth > corr_depth )
{
cvInitMatHeader( &temp, csz.height, csz.width, corr_depth, buf );
cvConvert( src, &temp );
src = &temp;
}
cvAcc( src, dst );
}
}
}
}
}
__END__;
cvReleaseMat( &dft_img );
cvReleaseMat( &dft_templ );
cvFree( &buf );
}
/***************************** IPP Match Template Functions ******************************/
icvCrossCorrValid_Norm_8u32f_C1R_t icvCrossCorrValid_Norm_8u32f_C1R_p = 0;
icvCrossCorrValid_NormLevel_8u32f_C1R_t icvCrossCorrValid_NormLevel_8u32f_C1R_p = 0;
icvSqrDistanceValid_Norm_8u32f_C1R_t icvSqrDistanceValid_Norm_8u32f_C1R_p = 0;
icvCrossCorrValid_Norm_32f_C1R_t icvCrossCorrValid_Norm_32f_C1R_p = 0;
icvCrossCorrValid_NormLevel_32f_C1R_t icvCrossCorrValid_NormLevel_32f_C1R_p = 0;
icvSqrDistanceValid_Norm_32f_C1R_t icvSqrDistanceValid_Norm_32f_C1R_p = 0;
typedef CvStatus (CV_STDCALL * CvTemplMatchIPPFunc)
( const void* img, int imgstep, CvSize imgsize,
const void* templ, int templstep, CvSize templsize,
void* result, int rstep );
/*****************************************************************************************/
CV_IMPL void
cvMatchTemplate( const CvArr* _img, const CvArr* _templ, CvArr* _result, int method )
{
CvMat* sum = 0;
CvMat* sqsum = 0;
CV_FUNCNAME( "cvMatchTemplate" );
__BEGIN__;
int coi1 = 0, coi2 = 0;
int depth, cn;
int i, j, k;
CvMat stub, *img = (CvMat*)_img;
CvMat tstub, *templ = (CvMat*)_templ;
CvMat rstub, *result = (CvMat*)_result;
CvScalar templ_mean = cvScalarAll(0);
double templ_norm = 0, templ_sum2 = 0;
int idx = 0, idx2 = 0;
double *p0, *p1, *p2, *p3;
double *q0, *q1, *q2, *q3;
double inv_area;
int sum_step, sqsum_step;
int num_type = method == CV_TM_CCORR || method == CV_TM_CCORR_NORMED ? 0 :
method == CV_TM_CCOEFF || method == CV_TM_CCOEFF_NORMED ? 1 : 2;
int is_normed = method == CV_TM_CCORR_NORMED ||
method == CV_TM_SQDIFF_NORMED ||
method == CV_TM_CCOEFF_NORMED;
CV_CALL( img = cvGetMat( img, &stub, &coi1 ));
CV_CALL( templ = cvGetMat( templ, &tstub, &coi2 ));
CV_CALL( result = cvGetMat( result, &rstub ));
if( CV_MAT_DEPTH( img->type ) != CV_8U &&
CV_MAT_DEPTH( img->type ) != CV_32F )
CV_ERROR( CV_StsUnsupportedFormat,
"The function supports only 8u and 32f data types" );
if( !CV_ARE_TYPES_EQ( img, templ ))
CV_ERROR( CV_StsUnmatchedSizes, "image and template should have the same type" );
if( CV_MAT_TYPE( result->type ) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "output image should have 32f type" );
if( img->rows < templ->rows || img->cols < templ->cols )
{
CvMat* t;
CV_SWAP( img, templ, t );
}
if( result->rows != img->rows - templ->rows + 1 ||
result->cols != img->cols - templ->cols + 1 )
CV_ERROR( CV_StsUnmatchedSizes, "output image should be (W - w + 1)x(H - h + 1)" );
if( method < CV_TM_SQDIFF || method > CV_TM_CCOEFF_NORMED )
CV_ERROR( CV_StsBadArg, "unknown comparison method" );
depth = CV_MAT_DEPTH(img->type);
cn = CV_MAT_CN(img->type);
if( is_normed && cn == 1 && templ->rows > 8 && templ->cols > 8 &&
img->rows > templ->cols && img->cols > templ->cols )
{
CvTemplMatchIPPFunc ipp_func =
depth == CV_8U ?
(method == CV_TM_SQDIFF_NORMED ? (CvTemplMatchIPPFunc)icvSqrDistanceValid_Norm_8u32f_C1R_p :
method == CV_TM_CCORR_NORMED ? (CvTemplMatchIPPFunc)icvCrossCorrValid_Norm_8u32f_C1R_p :
(CvTemplMatchIPPFunc)icvCrossCorrValid_NormLevel_8u32f_C1R_p) :
(method == CV_TM_SQDIFF_NORMED ? (CvTemplMatchIPPFunc)icvSqrDistanceValid_Norm_32f_C1R_p :
method == CV_TM_CCORR_NORMED ? (CvTemplMatchIPPFunc)icvCrossCorrValid_Norm_32f_C1R_p :
(CvTemplMatchIPPFunc)icvCrossCorrValid_NormLevel_32f_C1R_p);
if( ipp_func )
{
CvSize img_size = cvGetMatSize(img), templ_size = cvGetMatSize(templ);
IPPI_CALL( ipp_func( img->data.ptr, img->step ? img->step : CV_STUB_STEP,
img_size, templ->data.ptr,
templ->step ? templ->step : CV_STUB_STEP,
templ_size, result->data.ptr,
result->step ? result->step : CV_STUB_STEP ));
for( i = 0; i < result->rows; i++ )
{
float* rrow = (float*)(result->data.ptr + i*result->step);
for( j = 0; j < result->cols; j++ )
{
if( fabs(rrow[j]) > 1. )
rrow[j] = rrow[j] < 0 ? -1.f : 1.f;
}
}
EXIT;
}
}
CV_CALL( icvCrossCorr( img, templ, result ));
if( method == CV_TM_CCORR )
EXIT;
inv_area = 1./((double)templ->rows * templ->cols);
CV_CALL( sum = cvCreateMat( img->rows + 1, img->cols + 1,
CV_MAKETYPE( CV_64F, cn )));
if( method == CV_TM_CCOEFF )
{
CV_CALL( cvIntegral( img, sum, 0, 0 ));
CV_CALL( templ_mean = cvAvg( templ ));
q0 = q1 = q2 = q3 = 0;
}
else
{
CvScalar _templ_sdv = cvScalarAll(0);
CV_CALL( sqsum = cvCreateMat( img->rows + 1, img->cols + 1,
CV_MAKETYPE( CV_64F, cn )));
CV_CALL( cvIntegral( img, sum, sqsum, 0 ));
CV_CALL( cvAvgSdv( templ, &templ_mean, &_templ_sdv ));
templ_norm = CV_SQR(_templ_sdv.val[0]) + CV_SQR(_templ_sdv.val[1]) +
CV_SQR(_templ_sdv.val[2]) + CV_SQR(_templ_sdv.val[3]);
if( templ_norm < DBL_EPSILON && method == CV_TM_CCOEFF_NORMED )
{
cvSet( result, cvScalarAll(1.) );
EXIT;
}
templ_sum2 = templ_norm +
CV_SQR(templ_mean.val[0]) + CV_SQR(templ_mean.val[1]) +
CV_SQR(templ_mean.val[2]) + CV_SQR(templ_mean.val[3]);
if( num_type != 1 )
{
templ_mean = cvScalarAll(0);
templ_norm = templ_sum2;
}
templ_sum2 /= inv_area;
templ_norm = sqrt(templ_norm);
templ_norm /= sqrt(inv_area); // care of accuracy here
q0 = (double*)sqsum->data.ptr;
q1 = q0 + templ->cols*cn;
q2 = (double*)(sqsum->data.ptr + templ->rows*sqsum->step);
q3 = q2 + templ->cols*cn;
}
p0 = (double*)sum->data.ptr;
p1 = p0 + templ->cols*cn;
p2 = (double*)(sum->data.ptr + templ->rows*sum->step);
p3 = p2 + templ->cols*cn;
sum_step = sum ? sum->step / sizeof(double) : 0;
sqsum_step = sqsum ? sqsum->step / sizeof(double) : 0;
for( i = 0; i < result->rows; i++ )
{
float* rrow = (float*)(result->data.ptr + i*result->step);
idx = i * sum_step;
idx2 = i * sqsum_step;
for( j = 0; j < result->cols; j++, idx += cn, idx2 += cn )
{
double num = rrow[j], t;
double wnd_mean2 = 0, wnd_sum2 = 0;
if( num_type == 1 )
{
for( k = 0; k < cn; k++ )
{
t = p0[idx+k] - p1[idx+k] - p2[idx+k] + p3[idx+k];
wnd_mean2 += CV_SQR(t);
num -= t*templ_mean.val[k];
}
wnd_mean2 *= inv_area;
}
if( is_normed || num_type == 2 )
{
for( k = 0; k < cn; k++ )
{
t = q0[idx2+k] - q1[idx2+k] - q2[idx2+k] + q3[idx2+k];
wnd_sum2 += t;
}
if( num_type == 2 )
num = wnd_sum2 - 2*num + templ_sum2;
}
if( is_normed )
{
t = sqrt(MAX(wnd_sum2 - wnd_mean2,0))*templ_norm;
if( t > DBL_EPSILON )
{
num /= t;
if( fabs(num) > 1. )
num = num > 0 ? 1 : -1;
}
else
num = method != CV_TM_SQDIFF_NORMED || num < DBL_EPSILON ? 0 : 1;
}
rrow[j] = (float)num;
}
}
__END__;
cvReleaseMat( &sum );
cvReleaseMat( &sqsum );
}
/* End of file. */

View File

@@ -0,0 +1,493 @@
/*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*/
#include "_cv.h"
static CvStatus CV_STDCALL
icvThresh_8u_C1R( const uchar* src, int src_step, uchar* dst, int dst_step,
CvSize roi, uchar thresh, uchar maxval, int type )
{
int i, j;
uchar tab[256];
switch( type )
{
case CV_THRESH_BINARY:
for( i = 0; i <= thresh; i++ )
tab[i] = 0;
for( ; i < 256; i++ )
tab[i] = maxval;
break;
case CV_THRESH_BINARY_INV:
for( i = 0; i <= thresh; i++ )
tab[i] = maxval;
for( ; i < 256; i++ )
tab[i] = 0;
break;
case CV_THRESH_TRUNC:
for( i = 0; i <= thresh; i++ )
tab[i] = (uchar)i;
for( ; i < 256; i++ )
tab[i] = thresh;
break;
case CV_THRESH_TOZERO:
for( i = 0; i <= thresh; i++ )
tab[i] = 0;
for( ; i < 256; i++ )
tab[i] = (uchar)i;
break;
case CV_THRESH_TOZERO_INV:
for( i = 0; i <= thresh; i++ )
tab[i] = (uchar)i;
for( ; i < 256; i++ )
tab[i] = 0;
break;
default:
return CV_BADFLAG_ERR;
}
for( i = 0; i < roi.height; i++, src += src_step, dst += dst_step )
{
for( j = 0; j <= roi.width - 4; j += 4 )
{
uchar t0 = tab[src[j]];
uchar t1 = tab[src[j+1]];
dst[j] = t0;
dst[j+1] = t1;
t0 = tab[src[j+2]];
t1 = tab[src[j+3]];
dst[j+2] = t0;
dst[j+3] = t1;
}
for( ; j < roi.width; j++ )
dst[j] = tab[src[j]];
}
return CV_NO_ERR;
}
static CvStatus CV_STDCALL
icvThresh_32f_C1R( const float *src, int src_step, float *dst, int dst_step,
CvSize roi, float thresh, float maxval, int type )
{
int i, j;
const int* isrc = (const int*)src;
int* idst = (int*)dst;
Cv32suf v;
int iThresh, iMax;
v.f = thresh; iThresh = CV_TOGGLE_FLT(v.i);
v.f = maxval; iMax = v.i;
src_step /= sizeof(src[0]);
dst_step /= sizeof(dst[0]);
switch( type )
{
case CV_THRESH_BINARY:
for( i = 0; i < roi.height; i++, isrc += src_step, idst += dst_step )
{
for( j = 0; j < roi.width; j++ )
{
int temp = isrc[j];
idst[j] = ((CV_TOGGLE_FLT(temp) <= iThresh) - 1) & iMax;
}
}
break;
case CV_THRESH_BINARY_INV:
for( i = 0; i < roi.height; i++, isrc += src_step, idst += dst_step )
{
for( j = 0; j < roi.width; j++ )
{
int temp = isrc[j];
idst[j] = ((CV_TOGGLE_FLT(temp) > iThresh) - 1) & iMax;
}
}
break;
case CV_THRESH_TRUNC:
for( i = 0; i < roi.height; i++, src += src_step, dst += dst_step )
{
for( j = 0; j < roi.width; j++ )
{
float temp = src[j];
if( temp > thresh )
temp = thresh;
dst[j] = temp;
}
}
break;
case CV_THRESH_TOZERO:
for( i = 0; i < roi.height; i++, isrc += src_step, idst += dst_step )
{
for( j = 0; j < roi.width; j++ )
{
int temp = isrc[j];
idst[j] = ((CV_TOGGLE_FLT( temp ) <= iThresh) - 1) & temp;
}
}
break;
case CV_THRESH_TOZERO_INV:
for( i = 0; i < roi.height; i++, isrc += src_step, idst += dst_step )
{
for( j = 0; j < roi.width; j++ )
{
int temp = isrc[j];
idst[j] = ((CV_TOGGLE_FLT( temp ) > iThresh) - 1) & temp;
}
}
break;
default:
return CV_BADFLAG_ERR;
}
return CV_OK;
}
static double
icvGetThreshVal_Otsu( const CvHistogram* hist )
{
double max_val = 0;
CV_FUNCNAME( "icvGetThreshVal_Otsu" );
__BEGIN__;
int i, count;
const float* h;
double sum = 0, mu = 0;
bool uniform = false;
double low = 0, high = 0, delta = 0;
float* nu_thresh = 0;
double mu1 = 0, q1 = 0;
double max_sigma = 0;
if( !CV_IS_HIST(hist) || CV_IS_SPARSE_HIST(hist) || hist->mat.dims != 1 )
CV_ERROR( CV_StsBadArg,
"The histogram in Otsu method must be a valid dense 1D histogram" );
count = hist->mat.dim[0].size;
h = (float*)cvPtr1D( hist->bins, 0 );
if( !CV_HIST_HAS_RANGES(hist) || CV_IS_UNIFORM_HIST(hist) )
{
if( CV_HIST_HAS_RANGES(hist) )
{
low = hist->thresh[0][0];
high = hist->thresh[0][1];
}
else
{
low = 0;
high = count;
}
delta = (high-low)/count;
low += delta*0.5;
uniform = true;
}
else
nu_thresh = hist->thresh2[0];
for( i = 0; i < count; i++ )
{
sum += h[i];
if( uniform )
mu += (i*delta + low)*h[i];
else
mu += (nu_thresh[i*2] + nu_thresh[i*2+1])*0.5*h[i];
}
sum = fabs(sum) > FLT_EPSILON ? 1./sum : 0;
mu *= sum;
mu1 = 0;
q1 = 0;
for( i = 0; i < count; i++ )
{
double p_i, q2, mu2, val_i, sigma;
p_i = h[i]*sum;
mu1 *= q1;
q1 += p_i;
q2 = 1. - q1;
if( MIN(q1,q2) < FLT_EPSILON || MAX(q1,q2) > 1. - FLT_EPSILON )
continue;
if( uniform )
val_i = i*delta + low;
else
val_i = (nu_thresh[i*2] + nu_thresh[i*2+1])*0.5;
mu1 = (mu1 + val_i*p_i)/q1;
mu2 = (mu - q1*mu1)/q2;
sigma = q1*q2*(mu1 - mu2)*(mu1 - mu2);
if( sigma > max_sigma )
{
max_sigma = sigma;
max_val = val_i;
}
}
__END__;
return max_val;
}
icvAndC_8u_C1R_t icvAndC_8u_C1R_p = 0;
icvCompareC_8u_C1R_cv_t icvCompareC_8u_C1R_cv_p = 0;
icvThreshold_GTVal_8u_C1R_t icvThreshold_GTVal_8u_C1R_p = 0;
icvThreshold_GTVal_32f_C1R_t icvThreshold_GTVal_32f_C1R_p = 0;
icvThreshold_LTVal_8u_C1R_t icvThreshold_LTVal_8u_C1R_p = 0;
icvThreshold_LTVal_32f_C1R_t icvThreshold_LTVal_32f_C1R_p = 0;
CV_IMPL void
cvThreshold( const void* srcarr, void* dstarr, double thresh, double maxval, int type )
{
CvHistogram* hist = 0;
CV_FUNCNAME( "cvThreshold" );
__BEGIN__;
CvSize roi;
int src_step, dst_step;
CvMat src_stub, *src = (CvMat*)srcarr;
CvMat dst_stub, *dst = (CvMat*)dstarr;
CvMat src0, dst0;
int coi1 = 0, coi2 = 0;
int ithresh, imaxval, cn;
bool use_otsu;
CV_CALL( src = cvGetMat( src, &src_stub, &coi1 ));
CV_CALL( dst = cvGetMat( dst, &dst_stub, &coi2 ));
if( coi1 + coi2 )
CV_ERROR( CV_BadCOI, "COI is not supported by the function" );
if( !CV_ARE_CNS_EQ( src, dst ) )
CV_ERROR( CV_StsUnmatchedFormats, "Both arrays must have equal number of channels" );
cn = CV_MAT_CN(src->type);
if( cn > 1 )
{
src = cvReshape( src, &src0, 1 );
dst = cvReshape( dst, &dst0, 1 );
}
use_otsu = (type & ~CV_THRESH_MASK) == CV_THRESH_OTSU;
type &= CV_THRESH_MASK;
if( use_otsu )
{
float _ranges[] = { 0, 256 };
float* ranges = _ranges;
int hist_size = 256;
void* srcarr0 = src;
if( CV_MAT_TYPE(src->type) != CV_8UC1 )
CV_ERROR( CV_StsNotImplemented, "Otsu method can only be used with 8uC1 images" );
CV_CALL( hist = cvCreateHist( 1, &hist_size, CV_HIST_ARRAY, &ranges ));
cvCalcArrHist( &srcarr0, hist );
thresh = cvFloor(icvGetThreshVal_Otsu( hist ));
}
if( !CV_ARE_DEPTHS_EQ( src, dst ) )
{
if( CV_MAT_TYPE(dst->type) != CV_8UC1 )
CV_ERROR( CV_StsUnsupportedFormat, "In case of different types destination should be 8uC1" );
if( type != CV_THRESH_BINARY && type != CV_THRESH_BINARY_INV )
CV_ERROR( CV_StsBadArg,
"In case of different types only CV_THRESH_BINARY "
"and CV_THRESH_BINARY_INV thresholding types are supported" );
if( maxval < 0 )
{
CV_CALL( cvSetZero( dst ));
}
else
{
CV_CALL( cvCmpS( src, thresh, dst, type == CV_THRESH_BINARY ? CV_CMP_GT : CV_CMP_LE ));
if( maxval < 255 )
CV_CALL( cvAndS( dst, cvScalarAll( maxval ), dst ));
}
EXIT;
}
if( !CV_ARE_SIZES_EQ( src, dst ) )
CV_ERROR( CV_StsUnmatchedSizes, "" );
roi = cvGetMatSize( src );
if( CV_IS_MAT_CONT( src->type & dst->type ))
{
roi.width *= roi.height;
roi.height = 1;
src_step = dst_step = CV_STUB_STEP;
}
else
{
src_step = src->step;
dst_step = dst->step;
}
switch( CV_MAT_DEPTH(src->type) )
{
case CV_8U:
ithresh = cvFloor(thresh);
imaxval = cvRound(maxval);
if( type == CV_THRESH_TRUNC )
imaxval = ithresh;
imaxval = CV_CAST_8U(imaxval);
if( ithresh < 0 || ithresh >= 255 )
{
if( type == CV_THRESH_BINARY || type == CV_THRESH_BINARY_INV ||
(type == CV_THRESH_TRUNC || type == CV_THRESH_TOZERO_INV) && ithresh < 0 ||
type == CV_THRESH_TOZERO && ithresh >= 255 )
{
int v = type == CV_THRESH_BINARY ? (ithresh >= 255 ? 0 : imaxval) :
type == CV_THRESH_BINARY_INV ? (ithresh >= 255 ? imaxval : 0) :
type == CV_THRESH_TRUNC ? imaxval : 0;
cvSet( dst, cvScalarAll(v) );
EXIT;
}
else
{
cvCopy( src, dst );
EXIT;
}
}
if( type == CV_THRESH_BINARY || type == CV_THRESH_BINARY_INV )
{
if( icvCompareC_8u_C1R_cv_p && icvAndC_8u_C1R_p )
{
IPPI_CALL( icvCompareC_8u_C1R_cv_p( src->data.ptr, src_step,
(uchar)ithresh, dst->data.ptr, dst_step, roi,
type == CV_THRESH_BINARY ? cvCmpGreater : cvCmpLessEq ));
if( imaxval < 255 )
IPPI_CALL( icvAndC_8u_C1R_p( dst->data.ptr, dst_step,
(uchar)imaxval, dst->data.ptr, dst_step, roi ));
EXIT;
}
}
else if( type == CV_THRESH_TRUNC || type == CV_THRESH_TOZERO_INV )
{
if( icvThreshold_GTVal_8u_C1R_p )
{
IPPI_CALL( icvThreshold_GTVal_8u_C1R_p( src->data.ptr, src_step,
dst->data.ptr, dst_step, roi, (uchar)ithresh,
(uchar)(type == CV_THRESH_TRUNC ? ithresh : 0) ));
EXIT;
}
}
else
{
assert( type == CV_THRESH_TOZERO );
if( icvThreshold_LTVal_8u_C1R_p )
{
ithresh = cvFloor(thresh+1.);
ithresh = CV_CAST_8U(ithresh);
IPPI_CALL( icvThreshold_LTVal_8u_C1R_p( src->data.ptr, src_step,
dst->data.ptr, dst_step, roi, (uchar)ithresh, 0 ));
EXIT;
}
}
icvThresh_8u_C1R( src->data.ptr, src_step,
dst->data.ptr, dst_step, roi,
(uchar)ithresh, (uchar)imaxval, type );
break;
case CV_32F:
if( type == CV_THRESH_TRUNC || type == CV_THRESH_TOZERO_INV )
{
if( icvThreshold_GTVal_32f_C1R_p )
{
IPPI_CALL( icvThreshold_GTVal_32f_C1R_p( src->data.fl, src_step,
dst->data.fl, dst_step, roi, (float)thresh,
type == CV_THRESH_TRUNC ? (float)thresh : 0 ));
EXIT;
}
}
else if( type == CV_THRESH_TOZERO )
{
if( icvThreshold_LTVal_32f_C1R_p )
{
IPPI_CALL( icvThreshold_LTVal_32f_C1R_p( src->data.fl, src_step,
dst->data.fl, dst_step, roi, (float)(thresh*(1 + FLT_EPSILON)), 0 ));
EXIT;
}
}
icvThresh_32f_C1R( src->data.fl, src_step, dst->data.fl, dst_step, roi,
(float)thresh, (float)maxval, type );
break;
default:
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
}
__END__;
if( hist )
cvReleaseHist( &hist );
}
/* End of file. */

View File

@@ -0,0 +1,319 @@
/*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*/
#include "_cv.h"
static CvStatus
icvUnDistort_8u_CnR( const uchar* src, int srcstep,
uchar* dst, int dststep, CvSize size,
const float* intrinsic_matrix,
const float* dist_coeffs, int cn )
{
int u, v, i;
float u0 = intrinsic_matrix[2], v0 = intrinsic_matrix[5];
float fx = intrinsic_matrix[0], fy = intrinsic_matrix[4];
float _fx = 1.f/fx, _fy = 1.f/fy;
float k1 = dist_coeffs[0], k2 = dist_coeffs[1];
float p1 = dist_coeffs[2], p2 = dist_coeffs[3];
srcstep /= sizeof(src[0]);
dststep /= sizeof(dst[0]);
for( v = 0; v < size.height; v++, dst += dststep )
{
float y = (v - v0)*_fy;
float y2 = y*y;
float ky = 1 + (k1 + k2*y2)*y2;
float k2y = 2*k2*y2;
float _2p1y = 2*p1*y;
float _3p1y2 = 3*p1*y2;
float p2y2 = p2*y2;
for( u = 0; u < size.width; u++ )
{
float x = (u - u0)*_fx;
float x2 = x*x;
float kx = (k1 + k2*x2)*x2;
float d = kx + ky + k2y*x2;
float _u = fx*(x*(d + _2p1y) + p2y2 + (3*p2)*x2) + u0;
float _v = fy*(y*(d + (2*p2)*x) + _3p1y2 + p1*x2) + v0;
int iu = cvRound(_u*(1 << ICV_WARP_SHIFT));
int iv = cvRound(_v*(1 << ICV_WARP_SHIFT));
int ifx = iu & ICV_WARP_MASK;
int ify = iv & ICV_WARP_MASK;
iu >>= ICV_WARP_SHIFT;
iv >>= ICV_WARP_SHIFT;
float a0 = icvLinearCoeffs[ifx*2];
float a1 = icvLinearCoeffs[ifx*2 + 1];
float b0 = icvLinearCoeffs[ify*2];
float b1 = icvLinearCoeffs[ify*2 + 1];
if( (unsigned)iv < (unsigned)(size.height - 1) &&
(unsigned)iu < (unsigned)(size.width - 1) )
{
const uchar* ptr = src + iv*srcstep + iu*cn;
for( i = 0; i < cn; i++ )
{
float t0 = a1*CV_8TO32F(ptr[i]) + a0*CV_8TO32F(ptr[i+cn]);
float t1 = a1*CV_8TO32F(ptr[i+srcstep]) + a0*CV_8TO32F(ptr[i + srcstep + cn]);
dst[u*cn + i] = (uchar)cvRound(b1*t0 + b0*t1);
}
}
else
{
for( i = 0; i < cn; i++ )
dst[u*cn + i] = 0;
}
}
}
return CV_OK;
}
icvUndistortGetSize_t icvUndistortGetSize_p = 0;
icvCreateMapCameraUndistort_32f_C1R_t icvCreateMapCameraUndistort_32f_C1R_p = 0;
icvUndistortRadial_8u_C1R_t icvUndistortRadial_8u_C1R_p = 0;
icvUndistortRadial_8u_C3R_t icvUndistortRadial_8u_C3R_p = 0;
typedef CvStatus (CV_STDCALL * CvUndistortRadialIPPFunc)
( const void* pSrc, int srcStep, void* pDst, int dstStep, CvSize roiSize,
float fx, float fy, float cx, float cy, float k1, float k2, uchar *pBuffer );
CV_IMPL void
cvUndistort2( const CvArr* _src, CvArr* _dst, const CvMat* A, const CvMat* dist_coeffs )
{
static int inittab = 0;
uchar* buffer = 0;
CV_FUNCNAME( "cvUndistort2" );
__BEGIN__;
float a[9], k[4];
int coi1 = 0, coi2 = 0;
CvMat srcstub, *src = (CvMat*)_src;
CvMat dststub, *dst = (CvMat*)_dst;
CvMat _a = cvMat( 3, 3, CV_32F, a ), _k;
int cn, src_step, dst_step;
CvSize size;
if( !inittab )
{
icvInitLinearCoeffTab();
icvInitCubicCoeffTab();
inittab = 1;
}
CV_CALL( src = cvGetMat( src, &srcstub, &coi1 ));
CV_CALL( dst = cvGetMat( dst, &dststub, &coi2 ));
if( coi1 != 0 || coi2 != 0 )
CV_ERROR( CV_BadCOI, "The function does not support COI" );
if( CV_MAT_DEPTH(src->type) != CV_8U )
CV_ERROR( CV_StsUnsupportedFormat, "Only 8-bit images are supported" );
if( src->data.ptr == dst->data.ptr )
CV_ERROR( CV_StsNotImplemented, "In-place undistortion is not implemented" );
if( !CV_ARE_TYPES_EQ( src, dst ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( !CV_ARE_SIZES_EQ( src, dst ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( !CV_IS_MAT(A) || A->rows != 3 || A->cols != 3 ||
CV_MAT_TYPE(A->type) != CV_32FC1 && CV_MAT_TYPE(A->type) != CV_64FC1 )
CV_ERROR( CV_StsBadArg, "Intrinsic matrix must be a valid 3x3 floating-point matrix" );
if( !CV_IS_MAT(dist_coeffs) || dist_coeffs->rows != 1 && dist_coeffs->cols != 1 ||
dist_coeffs->rows*dist_coeffs->cols*CV_MAT_CN(dist_coeffs->type) != 4 ||
CV_MAT_DEPTH(dist_coeffs->type) != CV_64F &&
CV_MAT_DEPTH(dist_coeffs->type) != CV_32F )
CV_ERROR( CV_StsBadArg,
"Distortion coefficients must be 1x4 or 4x1 floating-point vector" );
cvConvert( A, &_a );
_k = cvMat( dist_coeffs->rows, dist_coeffs->cols,
CV_MAKETYPE(CV_32F, CV_MAT_CN(dist_coeffs->type)), k );
cvConvert( dist_coeffs, &_k );
cn = CV_MAT_CN(src->type);
size = cvGetMatSize(src);
src_step = src->step ? src->step : CV_STUB_STEP;
dst_step = dst->step ? dst->step : CV_STUB_STEP;
if( fabs((double)k[2]) < 1e-5 && fabs((double)k[3]) < 1e-5 && icvUndistortGetSize_p )
{
int buf_size = 0;
CvUndistortRadialIPPFunc func =
cn == 1 ? (CvUndistortRadialIPPFunc)icvUndistortRadial_8u_C1R_p :
(CvUndistortRadialIPPFunc)icvUndistortRadial_8u_C3R_p;
if( func && icvUndistortGetSize_p( size, &buf_size ) >= 0 && buf_size > 0 )
{
CV_CALL( buffer = (uchar*)cvAlloc( buf_size ));
if( func( src->data.ptr, src_step, dst->data.ptr,
dst_step, size, a[0], a[4],
a[2], a[5], k[0], k[1], buffer ) >= 0 )
EXIT;
}
}
icvUnDistort_8u_CnR( src->data.ptr, src_step,
dst->data.ptr, dst_step, size, a, k, cn );
__END__;
cvFree( &buffer );
}
CV_IMPL void
cvInitUndistortMap( const CvMat* A, const CvMat* dist_coeffs,
CvArr* mapxarr, CvArr* mapyarr )
{
uchar* buffer = 0;
CV_FUNCNAME( "cvInitUndistortMap" );
__BEGIN__;
float a[9], k[4];
int coi1 = 0, coi2 = 0;
CvMat mapxstub, *_mapx = (CvMat*)mapxarr;
CvMat mapystub, *_mapy = (CvMat*)mapyarr;
float *mapx, *mapy;
CvMat _a = cvMat( 3, 3, CV_32F, a ), _k;
int mapxstep, mapystep;
int u, v;
float u0, v0, fx, fy, _fx, _fy, k1, k2, p1, p2;
CvSize size;
CV_CALL( _mapx = cvGetMat( _mapx, &mapxstub, &coi1 ));
CV_CALL( _mapy = cvGetMat( _mapy, &mapystub, &coi2 ));
if( coi1 != 0 || coi2 != 0 )
CV_ERROR( CV_BadCOI, "The function does not support COI" );
if( CV_MAT_TYPE(_mapx->type) != CV_32FC1 )
CV_ERROR( CV_StsUnsupportedFormat, "Both maps must have 32fC1 type" );
if( !CV_ARE_TYPES_EQ( _mapx, _mapy ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
if( !CV_ARE_SIZES_EQ( _mapx, _mapy ))
CV_ERROR( CV_StsUnmatchedSizes, "" );
if( !CV_IS_MAT(A) || A->rows != 3 || A->cols != 3 ||
CV_MAT_TYPE(A->type) != CV_32FC1 && CV_MAT_TYPE(A->type) != CV_64FC1 )
CV_ERROR( CV_StsBadArg, "Intrinsic matrix must be a valid 3x3 floating-point matrix" );
if( !CV_IS_MAT(dist_coeffs) || dist_coeffs->rows != 1 && dist_coeffs->cols != 1 ||
dist_coeffs->rows*dist_coeffs->cols*CV_MAT_CN(dist_coeffs->type) != 4 ||
CV_MAT_DEPTH(dist_coeffs->type) != CV_64F &&
CV_MAT_DEPTH(dist_coeffs->type) != CV_32F )
CV_ERROR( CV_StsBadArg,
"Distortion coefficients must be 1x4 or 4x1 floating-point vector" );
cvConvert( A, &_a );
_k = cvMat( dist_coeffs->rows, dist_coeffs->cols,
CV_MAKETYPE(CV_32F, CV_MAT_CN(dist_coeffs->type)), k );
cvConvert( dist_coeffs, &_k );
u0 = a[2]; v0 = a[5];
fx = a[0]; fy = a[4];
_fx = 1.f/fx; _fy = 1.f/fy;
k1 = k[0]; k2 = k[1];
p1 = k[2]; p2 = k[3];
mapxstep = _mapx->step ? _mapx->step : CV_STUB_STEP;
mapystep = _mapy->step ? _mapy->step : CV_STUB_STEP;
mapx = _mapx->data.fl;
mapy = _mapy->data.fl;
size = cvGetMatSize(_mapx);
/*if( icvUndistortGetSize_p && icvCreateMapCameraUndistort_32f_C1R_p )
{
int buf_size = 0;
if( icvUndistortGetSize_p( size, &buf_size ) && buf_size > 0 )
{
CV_CALL( buffer = (uchar*)cvAlloc( buf_size ));
if( icvCreateMapCameraUndistort_32f_C1R_p(
mapx, mapxstep, mapy, mapystep, size,
a[0], a[4], a[2], a[5], k[0], k[1], k[2], k[3], buffer ) >= 0 )
EXIT;
}
}*/
mapxstep /= sizeof(mapx[0]);
mapystep /= sizeof(mapy[0]);
for( v = 0; v < size.height; v++, mapx += mapxstep, mapy += mapystep )
{
float y = (v - v0)*_fy;
float y2 = y*y;
float _2p1y = 2*p1*y;
float _3p1y2 = 3*p1*y2;
float p2y2 = p2*y2;
for( u = 0; u < size.width; u++ )
{
float x = (u - u0)*_fx;
float x2 = x*x;
float r2 = x2 + y2;
float d = 1 + (k1 + k2*r2)*r2;
float _u = fx*(x*(d + _2p1y) + p2y2 + (3*p2)*x2) + u0;
float _v = fy*(y*(d + (2*p2)*x) + _3p1y2 + p1*x2) + v0;
mapx[u] = _u;
mapy[u] = _v;
}
}
__END__;
cvFree( &buffer );
}
/* End of file */

View File

@@ -0,0 +1,540 @@
/*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*/
#include "_cv.h"
CV_IMPL CvSeq* cvPointSeqFromMat( int seq_kind, const CvArr* arr,
CvContour* contour_header, CvSeqBlock* block )
{
CvSeq* contour = 0;
CV_FUNCNAME( "cvPointSeqFromMat" );
assert( arr != 0 && contour_header != 0 && block != 0 );
__BEGIN__;
int eltype;
CvMat* mat = (CvMat*)arr;
if( !CV_IS_MAT( mat ))
CV_ERROR( CV_StsBadArg, "Input array is not a valid matrix" );
eltype = CV_MAT_TYPE( mat->type );
if( eltype != CV_32SC2 && eltype != CV_32FC2 )
CV_ERROR( CV_StsUnsupportedFormat,
"The matrix can not be converted to point sequence because of "
"inappropriate element type" );
if( mat->width != 1 && mat->height != 1 || !CV_IS_MAT_CONT(mat->type))
CV_ERROR( CV_StsBadArg,
"The matrix converted to point sequence must be "
"1-dimensional and continuous" );
CV_CALL( cvMakeSeqHeaderForArray(
(seq_kind & (CV_SEQ_KIND_MASK|CV_SEQ_FLAG_CLOSED)) | eltype,
sizeof(CvContour), CV_ELEM_SIZE(eltype), mat->data.ptr,
mat->width*mat->height, (CvSeq*)contour_header, block ));
contour = (CvSeq*)contour_header;
__END__;
return contour;
}
typedef CvStatus (CV_STDCALL * CvCopyNonConstBorderFunc)(
const void*, int, CvSize, void*, int, CvSize, int, int );
typedef CvStatus (CV_STDCALL * CvCopyNonConstBorderFuncI)(
const void*, int, CvSize, CvSize, int, int );
icvCopyReplicateBorder_8u_C1R_t icvCopyReplicateBorder_8u_C1R_p = 0;
icvCopyReplicateBorder_16s_C1R_t icvCopyReplicateBorder_16s_C1R_p = 0;
icvCopyReplicateBorder_8u_C3R_t icvCopyReplicateBorder_8u_C3R_p = 0;
icvCopyReplicateBorder_32s_C1R_t icvCopyReplicateBorder_32s_C1R_p = 0;
icvCopyReplicateBorder_16s_C3R_t icvCopyReplicateBorder_16s_C3R_p = 0;
icvCopyReplicateBorder_16s_C4R_t icvCopyReplicateBorder_16s_C4R_p = 0;
icvCopyReplicateBorder_32s_C3R_t icvCopyReplicateBorder_32s_C3R_p = 0;
icvCopyReplicateBorder_32s_C4R_t icvCopyReplicateBorder_32s_C4R_p = 0;
icvCopyReplicateBorder_8u_C1IR_t icvCopyReplicateBorder_8u_C1IR_p = 0;
icvCopyReplicateBorder_16s_C1IR_t icvCopyReplicateBorder_16s_C1IR_p = 0;
icvCopyReplicateBorder_8u_C3IR_t icvCopyReplicateBorder_8u_C3IR_p = 0;
icvCopyReplicateBorder_32s_C1IR_t icvCopyReplicateBorder_32s_C1IR_p = 0;
icvCopyReplicateBorder_16s_C3IR_t icvCopyReplicateBorder_16s_C3IR_p = 0;
icvCopyReplicateBorder_16s_C4IR_t icvCopyReplicateBorder_16s_C4IR_p = 0;
icvCopyReplicateBorder_32s_C3IR_t icvCopyReplicateBorder_32s_C3IR_p = 0;
icvCopyReplicateBorder_32s_C4IR_t icvCopyReplicateBorder_32s_C4IR_p = 0;
CvStatus CV_STDCALL
icvCopyReplicateBorder_8u( const uchar* src, int srcstep, CvSize srcroi,
uchar* dst, int dststep, CvSize dstroi,
int top, int left, int cn, const uchar* )
{
const int isz = (int)sizeof(int);
int i, j;
if( srcstep == dststep && dst + dststep*top + left*cn == src &&
icvCopyReplicateBorder_8u_C1IR_p )
{
CvCopyNonConstBorderFuncI ifunc =
cn == 1 ? icvCopyReplicateBorder_8u_C1IR_p :
cn == 2 ? icvCopyReplicateBorder_16s_C1IR_p :
cn == 3 ? icvCopyReplicateBorder_8u_C3IR_p :
cn == 4 ? icvCopyReplicateBorder_32s_C1IR_p :
cn == 6 ? icvCopyReplicateBorder_16s_C3IR_p :
cn == 8 ? icvCopyReplicateBorder_16s_C4IR_p :
cn == 12 ? icvCopyReplicateBorder_32s_C3IR_p :
cn == 16 ? icvCopyReplicateBorder_32s_C4IR_p : 0;
if( ifunc )
return ifunc( src, srcstep, srcroi, dstroi, top, left );
}
else if( icvCopyReplicateBorder_8u_C1R_p )
{
CvCopyNonConstBorderFunc func =
cn == 1 ? icvCopyReplicateBorder_8u_C1R_p :
cn == 2 ? icvCopyReplicateBorder_16s_C1R_p :
cn == 3 ? icvCopyReplicateBorder_8u_C3R_p :
cn == 4 ? icvCopyReplicateBorder_32s_C1R_p :
cn == 6 ? icvCopyReplicateBorder_16s_C3R_p :
cn == 8 ? icvCopyReplicateBorder_16s_C4R_p :
cn == 12 ? icvCopyReplicateBorder_32s_C3R_p :
cn == 16 ? icvCopyReplicateBorder_32s_C4R_p : 0;
if( func )
return func( src, srcstep, srcroi, dst, dststep, dstroi, top, left );
}
if( (cn | srcstep | dststep | (size_t)src | (size_t)dst) % isz == 0 )
{
const int* isrc = (const int*)src;
int* idst = (int*)dst;
cn /= isz;
srcstep /= isz;
dststep /= isz;
srcroi.width *= cn;
dstroi.width *= cn;
left *= cn;
for( i = 0; i < dstroi.height; i++, idst += dststep )
{
if( idst + left != isrc )
for( j = 0; j < srcroi.width; j++ )
idst[j + left] = isrc[j];
for( j = left - 1; j >= 0; j-- )
idst[j] = idst[j + cn];
for( j = left+srcroi.width; j < dstroi.width; j++ )
idst[j] = idst[j - cn];
if( i >= top && i < top + srcroi.height - 1 )
isrc += srcstep;
}
}
else
{
srcroi.width *= cn;
dstroi.width *= cn;
left *= cn;
for( i = 0; i < dstroi.height; i++, dst += dststep )
{
if( dst + left != src )
for( j = 0; j < srcroi.width; j++ )
dst[j + left] = src[j];
for( j = left - 1; j >= 0; j-- )
dst[j] = dst[j + cn];
for( j = left+srcroi.width; j < dstroi.width; j++ )
dst[j] = dst[j - cn];
if( i >= top && i < top + srcroi.height - 1 )
src += srcstep;
}
}
return CV_OK;
}
static CvStatus CV_STDCALL
icvCopyReflect101Border_8u( const uchar* src, int srcstep, CvSize srcroi,
uchar* dst, int dststep, CvSize dstroi,
int top, int left, int cn )
{
const int isz = (int)sizeof(int);
int i, j, k, t, dj, tab_size, int_mode = 0;
const int* isrc = (const int*)src;
int* idst = (int*)dst, *tab;
if( (cn | srcstep | dststep | (size_t)src | (size_t)dst) % isz == 0 )
{
cn /= isz;
srcstep /= isz;
dststep /= isz;
int_mode = 1;
}
srcroi.width *= cn;
dstroi.width *= cn;
left *= cn;
tab_size = dstroi.width - srcroi.width;
tab = (int*)cvStackAlloc( tab_size*sizeof(tab[0]) );
if( srcroi.width == 1 )
{
for( k = 0; k < cn; k++ )
for( i = 0; i < tab_size; i += cn )
tab[i + k] = k + left;
}
else
{
j = dj = cn;
for( i = left - cn; i >= 0; i -= cn )
{
for( k = 0; k < cn; k++ )
tab[i + k] = j + k + left;
if( (unsigned)(j += dj) >= (unsigned)srcroi.width )
j -= 2*dj, dj = -dj;
}
j = srcroi.width - cn*2;
dj = -cn;
for( i = left; i < tab_size; j += cn )
{
for( k = 0; k < cn; k++ )
tab[i + k] = j + k + left;
if( (unsigned)(j += dj) >= (unsigned)srcroi.width )
j -= 2*dj, dj = -dj;
}
}
if( int_mode )
{
idst += top*dststep;
for( i = 0; i < srcroi.height; i++, isrc += srcstep, idst += dststep )
{
if( idst + left != isrc )
for( j = 0; j < srcroi.width; j++ )
idst[j + left] = isrc[j];
for( j = 0; i < left; j++ )
{
k = tab[j];
idst[j] = idst[k];
}
for( ; j < tab_size; j++ )
{
k = tab[j];
idst[j + srcroi.width] = idst[k];
}
}
isrc -= srcroi.height*srcstep;
idst -= (top - srcroi.height)*dststep;
}
else
{
dst += top*dststep;
for( i = 0; i < srcroi.height; i++, src += srcstep, dst += dststep )
{
if( dst + left != src )
for( j = 0; j < srcroi.width; j++ )
dst[j + left] = src[j];
for( j = 0; i < left; j++ )
{
k = tab[j];
dst[j] = dst[k];
}
for( ; j < tab_size; j++ )
{
k = tab[j];
dst[j + srcroi.width] = dst[k];
}
}
src -= srcroi.height*srcstep;
dst -= (top - srcroi.height)*dststep;
}
for( t = 0; t < 2; t++ )
{
int i1, i2, di;
if( t == 0 )
i1 = top-1, i2 = 0, di = -1, j = 1, dj = 1;
else
i1 = top+srcroi.height, i2=dstroi.height, di = 1, j = srcroi.height-2, dj = -1;
for( i = i1; i != i2; i += di )
{
if( int_mode )
{
const int* s = idst + i*dststep;
int* d = idst + (j+top)*dststep;
for( k = 0; k < dstroi.width; k++ )
d[k] = s[k];
}
else
{
const uchar* s = dst + i*dststep;
uchar* d = dst + (j+top)*dststep;
for( k = 0; k < dstroi.width; k++ )
d[k] = s[k];
}
if( (unsigned)(j += dj) >= (unsigned)srcroi.height )
j -= 2*dj, dj = -dj;
}
}
return CV_OK;
}
static CvStatus CV_STDCALL
icvCopyConstBorder_8u( const uchar* src, int srcstep, CvSize srcroi,
uchar* dst, int dststep, CvSize dstroi,
int top, int left, int cn, const uchar* value )
{
const int isz = (int)sizeof(int);
int i, j, k;
if( (cn | srcstep | dststep | (size_t)src | (size_t)dst | (size_t)value) % isz == 0 )
{
const int* isrc = (const int*)src;
int* idst = (int*)dst;
const int* ivalue = (const int*)value;
int v0 = ivalue[0];
cn /= isz;
srcstep /= isz;
dststep /= isz;
srcroi.width *= cn;
dstroi.width *= cn;
left *= cn;
for( j = 1; j < cn; j++ )
if( ivalue[j] != ivalue[0] )
break;
if( j == cn )
cn = 1;
if( dstroi.width <= 0 )
return CV_OK;
for( i = 0; i < dstroi.height; i++, idst += dststep )
{
if( i < top || i >= top + srcroi.height )
{
if( cn == 1 )
{
for( j = 0; j < dstroi.width; j++ )
idst[j] = v0;
}
else
{
for( j = 0; j < cn; j++ )
idst[j] = ivalue[j];
for( ; j < dstroi.width; j++ )
idst[j] = idst[j - cn];
}
continue;
}
if( cn == 1 )
{
for( j = 0; j < left; j++ )
idst[j] = v0;
for( j = srcroi.width + left; j < dstroi.width; j++ )
idst[j] = v0;
}
else
{
for( k = 0; k < cn; k++ )
{
for( j = 0; j < left; j += cn )
idst[j+k] = ivalue[k];
for( j = srcroi.width + left; j < dstroi.width; j += cn )
idst[j+k] = ivalue[k];
}
}
if( idst + left != isrc )
for( j = 0; j < srcroi.width; j++ )
idst[j + left] = isrc[j];
isrc += srcstep;
}
}
else
{
uchar v0 = value[0];
srcroi.width *= cn;
dstroi.width *= cn;
left *= cn;
for( j = 1; j < cn; j++ )
if( value[j] != value[0] )
break;
if( j == cn )
cn = 1;
if( dstroi.width <= 0 )
return CV_OK;
for( i = 0; i < dstroi.height; i++, dst += dststep )
{
if( i < top || i >= top + srcroi.height )
{
if( cn == 1 )
{
for( j = 0; j < dstroi.width; j++ )
dst[j] = v0;
}
else
{
for( j = 0; j < cn; j++ )
dst[j] = value[j];
for( ; j < dstroi.width; j++ )
dst[j] = dst[j - cn];
}
continue;
}
if( cn == 1 )
{
for( j = 0; j < left; j++ )
dst[j] = v0;
for( j = srcroi.width + left; j < dstroi.width; j++ )
dst[j] = v0;
}
else
{
for( k = 0; k < cn; k++ )
{
for( j = 0; j < left; j += cn )
dst[j+k] = value[k];
for( j = srcroi.width + left; j < dstroi.width; j += cn )
dst[j+k] = value[k];
}
}
if( dst + left != src )
for( j = 0; j < srcroi.width; j++ )
dst[j + left] = src[j];
src += srcstep;
}
}
return CV_OK;
}
CV_IMPL void
cvCopyMakeBorder( const CvArr* srcarr, CvArr* dstarr, CvPoint offset,
int bordertype, CvScalar value )
{
CV_FUNCNAME( "cvCopyMakeBorder" );
__BEGIN__;
CvMat srcstub, *src = (CvMat*)srcarr;
CvMat dststub, *dst = (CvMat*)dstarr;
CvSize srcsize, dstsize;
int srcstep, dststep;
int pix_size, type;
if( !CV_IS_MAT(src) )
CV_CALL( src = cvGetMat( src, &srcstub ));
if( !CV_IS_MAT(dst) )
CV_CALL( dst = cvGetMat( dst, &dststub ));
if( offset.x < 0 || offset.y < 0 )
CV_ERROR( CV_StsOutOfRange, "Offset (left/top border width) is negative" );
if( src->rows + offset.y > dst->rows || src->cols + offset.x > dst->cols )
CV_ERROR( CV_StsBadSize, "Source array is too big or destination array is too small" );
if( !CV_ARE_TYPES_EQ( src, dst ))
CV_ERROR( CV_StsUnmatchedFormats, "" );
type = CV_MAT_TYPE(src->type);
pix_size = CV_ELEM_SIZE(type);
srcsize = cvGetMatSize(src);
dstsize = cvGetMatSize(dst);
srcstep = src->step;
dststep = dst->step;
if( srcstep == 0 )
srcstep = CV_STUB_STEP;
if( dststep == 0 )
dststep = CV_STUB_STEP;
if( bordertype == IPL_BORDER_REPLICATE )
{
icvCopyReplicateBorder_8u( src->data.ptr, srcstep, srcsize,
dst->data.ptr, dststep, dstsize,
offset.y, offset.x, pix_size );
}
else if( bordertype == IPL_BORDER_REFLECT_101 )
{
icvCopyReflect101Border_8u( src->data.ptr, srcstep, srcsize,
dst->data.ptr, dststep, dstsize,
offset.y, offset.x, pix_size );
}
else if( bordertype == IPL_BORDER_CONSTANT )
{
double buf[4];
cvScalarToRawData( &value, buf, src->type, 0 );
icvCopyConstBorder_8u( src->data.ptr, srcstep, srcsize,
dst->data.ptr, dststep, dstsize,
offset.y, offset.x, pix_size, (uchar*)buf );
}
else
CV_ERROR( CV_StsBadFlag, "Unknown/unsupported border type" );
__END__;
}
/* End of file. */

View File

@@ -0,0 +1 @@
// this file is empty but needed for libtool

View File

@@ -0,0 +1,16 @@
TARGET := cv
BINTYPE := DLL
SRC_ROOT := ../../cv/src
INC_ROOT := ../../cv/include
CXCORE_INC := ../../cxcore/include
SRC_DIRS := . ../include ../../cxcore/include
CXXFLAGS := -D"CVAPI_EXPORTS" -I"$(INC_ROOT)" -I"$(SRC_ROOT)" -I"$(CXCORE_INC)"
INCS := cv.h cv.hpp cvcompat.h cvtypes.h \
_cv.h _cvgeom.h _cvimgproc.h _cvipp.h _cvlist.h _cvmatrix.h \
cxcore.h cxcore.hpp cxerror.h cxmisc.h cxtypes.h cvver.h
LIBS := -lcxcore$(DBG)
include ../../_make/make_module_gnu.mak

View File

@@ -0,0 +1,47 @@
TARGET = cv
BINTYPE = DLL
ROOT = ..\..
PCH = _cv.h
PCH_STARTER = cvprecomp
OBJS = $(OBJPATH)/cvaccum.obj $(OBJPATH)/cvadapthresh.obj \
$(OBJPATH)/cvapprox.obj $(OBJPATH)/cvcalccontrasthistogram.obj \
$(OBJPATH)/cvcalcimagehomography.obj $(OBJPATH)/cvcalibinit.obj \
$(OBJPATH)/cvcalibration.obj $(OBJPATH)/cvcamshift.obj \
$(OBJPATH)/cvcanny.obj $(OBJPATH)/cvcolor.obj \
$(OBJPATH)/cvcondens.obj $(OBJPATH)/cvcontours.obj \
$(OBJPATH)/cvcontourtree.obj $(OBJPATH)/cvconvhull.obj \
$(OBJPATH)/cvconvolve.obj $(OBJPATH)/cvcorner.obj \
$(OBJPATH)/cvcornersubpix.obj $(OBJPATH)/cvderiv.obj \
$(OBJPATH)/cvdistransform.obj $(OBJPATH)/cvdominants.obj \
$(OBJPATH)/cvemd.obj $(OBJPATH)/cvfeatureselect.obj \
$(OBJPATH)/cvfilter.obj $(OBJPATH)/cvfloodfill.obj \
$(OBJPATH)/cvfundam.obj $(OBJPATH)/cvgeometry.obj \
$(OBJPATH)/cvhaar.obj $(OBJPATH)/cvhistogram.obj \
$(OBJPATH)/cvhough.obj $(OBJPATH)/cvimgwarp.obj $(OBJPATH)/cvinpaint.obj \
$(OBJPATH)/cvkalman.obj $(OBJPATH)/cvlinefit.obj \
$(OBJPATH)/cvlkpyramid.obj $(OBJPATH)/cvmatchcontours.obj \
$(OBJPATH)/cvmoments.obj $(OBJPATH)/cvmorph.obj \
$(OBJPATH)/cvmotempl.obj $(OBJPATH)/cvoptflowbm.obj \
$(OBJPATH)/cvoptflowhs.obj $(OBJPATH)/cvoptflowlk.obj \
$(OBJPATH)/cvpgh.obj $(OBJPATH)/cvposit.obj \
$(OBJPATH)/cvpyramids.obj \
$(OBJPATH)/cvpyrsegmentation.obj $(OBJPATH)/cvrotcalipers.obj \
$(OBJPATH)/cvsamplers.obj $(OBJPATH)/cvsegmentation.obj \
$(OBJPATH)/cvshapedescr.obj $(OBJPATH)/cvsmooth.obj \
$(OBJPATH)/cvsnakes.obj $(OBJPATH)/cvsubdivision2d.obj \
$(OBJPATH)/cvsumpixels.obj $(OBJPATH)/cvswitcher.obj \
$(OBJPATH)/cvtables.obj $(OBJPATH)/cvtemplmatch.obj \
$(OBJPATH)/cvthresh.obj $(OBJPATH)/cvundistort.obj \
$(OBJPATH)/cvutils.obj
INCS = ../include/cv.h ../include/cv.hpp ../include/cvcompat.h ../include/cvtypes.h \
./_cv.h ./_cvgeom.h ./_cvimgproc.h ./_cvipp.h ./_cvlist.h ./_cvmatrix.h \
$(ROOT)/cxcore/include/cxcore.h $(ROOT)/cxcore/include/cxcore.hpp \
$(ROOT)/cxcore/include/cxerror.h $(ROOT)/cxcore/include/cxmisc.h \
$(ROOT)/cxcore/include/cxtypes.h $(ROOT)/cxcore/include/cvver.h
CXXFLAGS_PROJ = /I"." /I"../include" /I"$(ROOT)/cxcore/include"
LIBS_PROJ = $(LIBPATH)"$(ROOT)/lib" cxcore$(DBG)$(OUT_P_SUFFIX).lib
!include $(ROOT)/_make/make_module_$(MS).mak

View File

@@ -0,0 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by cv.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,538 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = cvaux
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/autotools/aclocal/az_python.m4 \
$(top_srcdir)/autotools/aclocal/pkg.m4 \
$(top_srcdir)/autotools/aclocal/swig_complete.m4 \
$(top_srcdir)/autotools/aclocal/version_at_least.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/autotools/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/cvconfig.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_APPS_FALSE = @BUILD_APPS_FALSE@
BUILD_APPS_TRUE = @BUILD_APPS_TRUE@
BUILD_CARBON_FALSE = @BUILD_CARBON_FALSE@
BUILD_CARBON_TRUE = @BUILD_CARBON_TRUE@
BUILD_DC1394_FALSE = @BUILD_DC1394_FALSE@
BUILD_DC1394_TRUE = @BUILD_DC1394_TRUE@
BUILD_FFMPEG_FALSE = @BUILD_FFMPEG_FALSE@
BUILD_FFMPEG_TRUE = @BUILD_FFMPEG_TRUE@
BUILD_GTK_FALSE = @BUILD_GTK_FALSE@
BUILD_GTK_TRUE = @BUILD_GTK_TRUE@
BUILD_PYTHON_WRAPPERS_FALSE = @BUILD_PYTHON_WRAPPERS_FALSE@
BUILD_PYTHON_WRAPPERS_TRUE = @BUILD_PYTHON_WRAPPERS_TRUE@
BUILD_QUICKTIME_FALSE = @BUILD_QUICKTIME_FALSE@
BUILD_QUICKTIME_TRUE = @BUILD_QUICKTIME_TRUE@
BUILD_V4L_FALSE = @BUILD_V4L_FALSE@
BUILD_V4L_TRUE = @BUILD_V4L_TRUE@
BUILD_XINE_FALSE = @BUILD_XINE_FALSE@
BUILD_XINE_TRUE = @BUILD_XINE_TRUE@
CARBON_CFLAGS = @CARBON_CFLAGS@
CARBON_LIBS = @CARBON_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEBUG = @DEBUG@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
FFMPEGLIBS = @FFMPEGLIBS@
GREP = @GREP@
GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
GTHREAD_LIBS = @GTHREAD_LIBS@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_LIBS = @GTK_LIBS@
IEEE1394LIBS = @IEEE1394LIBS@
IMAGELIBS = @IMAGELIBS@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_VERSION = @LT_VERSION@
MAKEINFO = @MAKEINFO@
MMAJOR = @MMAJOR@
MMINOR = @MMINOR@
MSUBMINOR = @MSUBMINOR@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PYTHON = @PYTHON@
PYTHON_CSPEC = @PYTHON_CSPEC@
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
PYTHON_LSPEC = @PYTHON_LSPEC@
PYTHON_PLATFORM = @PYTHON_PLATFORM@
PYTHON_PREFIX = @PYTHON_PREFIX@
PYTHON_VERSION = @PYTHON_VERSION@
QUICKTIME_CFLAGS = @QUICKTIME_CFLAGS@
QUICKTIME_LIBS = @QUICKTIME_LIBS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
SWIG = @SWIG@
SWIG_PYTHON_LIBS = @SWIG_PYTHON_LIBS@
SWIG_PYTHON_OPT = @SWIG_PYTHON_OPT@
SWIG_RUNTIME_LIBS_DIR = @SWIG_RUNTIME_LIBS_DIR@
SWIG_VERSION = @SWIG_VERSION@
UPDATE_SWIG_WRAPPERS_FALSE = @UPDATE_SWIG_WRAPPERS_FALSE@
UPDATE_SWIG_WRAPPERS_TRUE = @UPDATE_SWIG_WRAPPERS_TRUE@
VERSION = @VERSION@
XINE_LIBS = @XINE_LIBS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgpyexecdir = @pkgpyexecdir@
pkgpythondir = @pkgpythondir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
pyexecdir = @pyexecdir@
pythondir = @pythondir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
SUBDIRS = src include
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cvaux/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu cvaux/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(mkdir_p) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-libtool clean-recursive ctags \
ctags-recursive distclean distclean-generic distclean-libtool \
distclean-recursive distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-generic mostlyclean-libtool \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,5 @@
# The directory where the include files will be installed
libcvauxincludedir = $(includedir)/opencv
# Which header files to install
libcvauxinclude_HEADERS = cvaux.h cvmat.hpp cvaux.hpp cvvidsurv.hpp

View File

@@ -0,0 +1,464 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = cvaux/include
DIST_COMMON = $(libcvauxinclude_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/autotools/aclocal/az_python.m4 \
$(top_srcdir)/autotools/aclocal/pkg.m4 \
$(top_srcdir)/autotools/aclocal/swig_complete.m4 \
$(top_srcdir)/autotools/aclocal/version_at_least.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/autotools/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/cvconfig.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libcvauxincludedir)"
libcvauxincludeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(libcvauxinclude_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_APPS_FALSE = @BUILD_APPS_FALSE@
BUILD_APPS_TRUE = @BUILD_APPS_TRUE@
BUILD_CARBON_FALSE = @BUILD_CARBON_FALSE@
BUILD_CARBON_TRUE = @BUILD_CARBON_TRUE@
BUILD_DC1394_FALSE = @BUILD_DC1394_FALSE@
BUILD_DC1394_TRUE = @BUILD_DC1394_TRUE@
BUILD_FFMPEG_FALSE = @BUILD_FFMPEG_FALSE@
BUILD_FFMPEG_TRUE = @BUILD_FFMPEG_TRUE@
BUILD_GTK_FALSE = @BUILD_GTK_FALSE@
BUILD_GTK_TRUE = @BUILD_GTK_TRUE@
BUILD_PYTHON_WRAPPERS_FALSE = @BUILD_PYTHON_WRAPPERS_FALSE@
BUILD_PYTHON_WRAPPERS_TRUE = @BUILD_PYTHON_WRAPPERS_TRUE@
BUILD_QUICKTIME_FALSE = @BUILD_QUICKTIME_FALSE@
BUILD_QUICKTIME_TRUE = @BUILD_QUICKTIME_TRUE@
BUILD_V4L_FALSE = @BUILD_V4L_FALSE@
BUILD_V4L_TRUE = @BUILD_V4L_TRUE@
BUILD_XINE_FALSE = @BUILD_XINE_FALSE@
BUILD_XINE_TRUE = @BUILD_XINE_TRUE@
CARBON_CFLAGS = @CARBON_CFLAGS@
CARBON_LIBS = @CARBON_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEBUG = @DEBUG@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
FFMPEGLIBS = @FFMPEGLIBS@
GREP = @GREP@
GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
GTHREAD_LIBS = @GTHREAD_LIBS@
GTK_CFLAGS = @GTK_CFLAGS@
GTK_LIBS = @GTK_LIBS@
IEEE1394LIBS = @IEEE1394LIBS@
IMAGELIBS = @IMAGELIBS@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_VERSION = @LT_VERSION@
MAKEINFO = @MAKEINFO@
MMAJOR = @MMAJOR@
MMINOR = @MMINOR@
MSUBMINOR = @MSUBMINOR@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PYTHON = @PYTHON@
PYTHON_CSPEC = @PYTHON_CSPEC@
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
PYTHON_LSPEC = @PYTHON_LSPEC@
PYTHON_PLATFORM = @PYTHON_PLATFORM@
PYTHON_PREFIX = @PYTHON_PREFIX@
PYTHON_VERSION = @PYTHON_VERSION@
QUICKTIME_CFLAGS = @QUICKTIME_CFLAGS@
QUICKTIME_LIBS = @QUICKTIME_LIBS@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
SWIG = @SWIG@
SWIG_PYTHON_LIBS = @SWIG_PYTHON_LIBS@
SWIG_PYTHON_OPT = @SWIG_PYTHON_OPT@
SWIG_RUNTIME_LIBS_DIR = @SWIG_RUNTIME_LIBS_DIR@
SWIG_VERSION = @SWIG_VERSION@
UPDATE_SWIG_WRAPPERS_FALSE = @UPDATE_SWIG_WRAPPERS_FALSE@
UPDATE_SWIG_WRAPPERS_TRUE = @UPDATE_SWIG_WRAPPERS_TRUE@
VERSION = @VERSION@
XINE_LIBS = @XINE_LIBS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgpyexecdir = @pkgpyexecdir@
pkgpythondir = @pkgpythondir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
pyexecdir = @pyexecdir@
pythondir = @pythondir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
# The directory where the include files will be installed
libcvauxincludedir = $(includedir)/opencv
# Which header files to install
libcvauxinclude_HEADERS = cvaux.h cvmat.hpp cvaux.hpp cvvidsurv.hpp
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu cvaux/include/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu cvaux/include/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-libcvauxincludeHEADERS: $(libcvauxinclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(libcvauxincludedir)" || $(mkdir_p) "$(DESTDIR)$(libcvauxincludedir)"
@list='$(libcvauxinclude_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(libcvauxincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(libcvauxincludedir)/$$f'"; \
$(libcvauxincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(libcvauxincludedir)/$$f"; \
done
uninstall-libcvauxincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(libcvauxinclude_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(libcvauxincludedir)/$$f'"; \
rm -f "$(DESTDIR)$(libcvauxincludedir)/$$f"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(libcvauxincludedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-libcvauxincludeHEADERS
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libcvauxincludeHEADERS
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool ctags distclean distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-libcvauxincludeHEADERS install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libcvauxincludeHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

Some files were not shown because too many files have changed in this diff Show More