/* This is AGAST and OAST, an optimal and accelerated corner detector
based on the accelerated segment tests
Below is the original copyright and the references */
/*
Copyright (C) 2010 Elmar Mair
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
*Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
*Redistributions 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.
*Neither the name of the University of Cambridge nor the names of
its contributors may 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 COPYRIGHT OWNER 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.
*/
/*
The references are:
* Adaptive and Generic Corner Detection Based on the Accelerated Segment Test,
Elmar Mair and Gregory D. Hager and Darius Burschka
and Michael Suppa and Gerhard Hirzinger ECCV 2010
URL: http://www6.in.tum.de/Main/ResearchAgast
*/
#include "agast_score.hpp"
#ifdef _MSC_VER
#pragma warning( disable : 4127 )
#endif
namespace cv
{
void makeAgastOffsets(int pixel[16], int rowStride, int type)
{
static const int offsets16[][2] =
{
{-3, 0}, {-3, -1}, {-2, -2}, {-1, -3}, {0, -3}, { 1, -3}, { 2, -2}, { 3, -1},
{ 3, 0}, { 3, 1}, { 2, 2}, { 1, 3}, {0, 3}, {-1, 3}, {-2, 2}, {-3, 1}
};
static const int offsets12d[][2] =
{
{-3, 0}, {-2, -1}, {-1, -2}, {0, -3}, { 1, -2}, { 2, -1},
{ 3, 0}, { 2, 1}, { 1, 2}, {0, 3}, {-1, 2}, {-2, 1}
};
static const int offsets12s[][2] =
{
{-2, 0}, {-2, -1}, {-1, -2}, {0, -2}, { 1, -2}, { 2, -1},
{ 2, 0}, { 2, 1}, { 1, 2}, {0, 2}, {-1, 2}, {-2, 1}
};
static const int offsets8[][2] =
{
{-1, 0}, {-1, -1}, {0, -1}, { 1, -1},
{ 1, 0}, { 1, 1}, {0, 1}, {-1, 1}
};
const int (*offsets)[2] = type == AgastFeatureDetector::OAST_9_16 ? offsets16 :
type == AgastFeatureDetector::AGAST_7_12d ? offsets12d :
type == AgastFeatureDetector::AGAST_7_12s ? offsets12s :
type == AgastFeatureDetector::AGAST_5_8 ? offsets8 : 0;
CV_Assert(pixel && offsets);
int k = 0;
for( ; k < 16; k++ )
pixel[k] = offsets[k][0] + offsets[k][1] * rowStride;
}
// 16 pixel mask
template<>
int agast_cornerScore<AgastFeatureDetector::OAST_9_16>(const uchar* ptr, const int pixel[], int threshold)
{
int bmin = threshold;
int bmax = 255;
int b_test = (bmax + bmin) / 2;
short offset0 = (short) pixel[0];
short offset1 = (short) pixel[1];
short offset2 = (short) pixel[2];
short offset3 = (short) pixel[3];
short offset4 = (short) pixel[4];
short offset5 = (short) pixel[5];
short offset6 = (short) pixel[6];
short offset7 = (short) pixel[7];
short offset8 = (short) pixel[8];
short offset9 = (short) pixel[9];
short offset10 = (short) pixel[10];
short offset11 = (short) pixel[11];
short offset12 = (short) pixel[12];
short offset13 = (short) pixel[13];
short offset14 = (short) pixel[14];
short offset15 = (short) pixel[15];
while(true)
{
const int cb = *ptr + b_test;
const int c_b = *ptr - b_test;
if(ptr[offset0] > cb)
if(ptr[offset2] > cb)
if(ptr[offset4] > cb)
if(ptr[offset5] > cb)
if(ptr[offset7] > cb)
if(ptr[offset3] > cb)
if(ptr[offset1] > cb)
if(ptr[offset6] > cb)
if(ptr[offset8] > cb)
goto is_a_corner;
else
if(ptr[offset15] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
if(ptr[offset13] > cb)
if(ptr[offset14] > cb)
if(ptr[offset15] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if(ptr[offset8] > cb)
if(ptr[offset9] > cb)
if(ptr[offset10] > cb)
if(ptr[offset6] > cb)
goto is_a_corner;
else
if(ptr[offset11] > cb)
if(ptr[offset12] > cb)
if(ptr[offset13] > cb)
if(ptr[offset14] > cb)
if(ptr[offset15] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if(ptr[offset10] > cb)
if(ptr[offset11] > cb)
if(ptr[offset12] > cb)
if(ptr[offset8] > cb)
if(ptr[offset9] > cb)
if(ptr[offset6] > cb)
goto is_a_corner;
else
if(ptr[offset13] > cb)
if(ptr[offset14] > cb)
if(ptr[offset15] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if(ptr[offset1] > cb)
if(ptr[offset13] > cb)
if(ptr[offset14] > cb)
if(ptr[offset15] > cb)
goto is_a_corner;
else
Opencv-4.5.5 Linux 安装包

OpenCV(开源计算机视觉库)是一个强大的跨平台计算机视觉库,它包含了众多图像处理和计算机视觉的算法,广泛应用于机器学习、深度学习、人工智能以及计算机视觉相关领域。本指南将详细讲解如何在Linux系统上安装OpenCV 4.5.5版本。
你需要下载OpenCV的源代码压缩包,这里已经提供了名为"opencv-4.5.5"的文件。这个压缩包包含了OpenCV的所有源代码,你可以通过以下步骤进行解压:
1. 打开终端:在Linux环境下,你可以使用快捷键`Ctrl + Alt + T`来快速启动终端。
2. 导航到下载文件所在的目录,例如,如果你的文件位于下载目录`~/Downloads`,可以输入`cd ~/Downloads`。
3. 使用`tar`命令解压文件,输入`tar -zxvf opencv-4.5.5.tar.gz`。这会创建一个名为`opencv-4.5.5`的文件夹。
接下来,我们需要构建并安装OpenCV。在这个过程里,我们将使用CMake来配置构建环境,然后通过`make`命令编译代码,最后用`sudo make install`命令进行安装。具体步骤如下:
1. 进入到解压后的源代码目录,输入`cd opencv-4.5.5`。
2. 创建一个名为`build`的目录,用于存放构建过程中产生的文件,输入`mkdir build`。
3. 进入`build`目录,输入`cd build`。
4. 运行CMake来配置构建过程。在运行之前,确保你的系统已安装了必要的依赖,如`cmake`, `gcc/g++`, `libopencv-dev`, `pkg-config`等。如果没有,请使用包管理器(如`apt-get`或`yum`)进行安装。然后在终端输入`cmake ..`。这一步骤会检测你的系统环境,并根据配置设置生成Makefile。
5. 开始编译源代码,输入`make`。这个过程可能需要一段时间,取决于你的硬件性能。
6. 当编译完成后,使用管理员权限安装OpenCV到系统路径,输入`sudo make install`。这会将编译好的库文件和头文件安装到系统的相应位置,使得其他程序可以方便地调用OpenCV的功能。
安装完成后,你可以在你的项目中链接OpenCV库,使用其丰富的API进行图像处理和计算机视觉任务。例如,你可以使用`#include <opencv2/opencv.hpp>`来包含OpenCV的头文件,然后调用如`cv::imread()`、`cv::imshow()`等函数来读取和显示图像。
值得注意的是,OpenCV 4.5.5版本引入了许多新特性和优化,包括对深度学习框架的支持,增强的图像处理功能,以及对最新硬件加速的优化。此外,它还支持多种编程语言,如C++, Python, Java等,使得开发者可以根据需求选择合适的编程接口。
安装OpenCV是一个涉及多个步骤的过程,需要耐心和对Linux环境有一定了解。但一旦成功安装,OpenCV将成为你在计算机视觉和人工智能领域的重要工具,帮助你实现各种复杂的视觉任务。

karlorful
- 粉丝: 23
最新资源
- 基于知识库的多级软件重用技术研究与实现的开题报告.docx
- 邯郸营销型网站建设外包分析营销型网站的互动性如何表现-诺亚商舟.doc
- 关于医院财务档案信息化管理的完善措施研究.docx
- 互联网商业合作协议.docx
- 网站开发制作合同.doc
- 大连理工大学2021年9月《电气制图与CAD》作业考核试题及答案参考11.docx
- 关于农业的互联网大赛计划书.docx
- 信息化建设的步骤(1).doc
- 详解MySQL下InnoDB引擎中的Memcached插件.doc
- 基于以就业为导向的中职计算机课堂教学实践认识.docx
- 历史学专业实践教学探索的论文-计算机理论论文.docx
- 互联网+辅导员工作方式新策略.docx
- 基于通信业务系统的测试用例最小集的研究的开题报告.docx
- GIS高校主要课程.doc
- 山东专升本公共课计算机92分自我总结必背知识点(我当时背的滚瓜....doc
- 幼儿园大班英语教案《spring-is-coming》.docx