//--------------------------------------【程序说明】-------------------------------------------
// 程序说明:《OpenCV3编程入门》OpenCV2版书本配套示例程序55
// 程序描述:OpenCV基本阈值操作
// 开发测试所用操作系统: Windows 7 64bit
// 开发测试所用IDE版本:Visual Studio 2010
// 开发测试所用OpenCV版本: 2.4.9
// 2014年06月 Created by @浅墨_毛星云
// 2014年11月 Revised by @浅墨_毛星云
//------------------------------------------------------------------------------------------------
//---------------------------------【头文件、命名空间包含部分】----------------------------
// 描述:包含程序所使用的头文件和命名空间
//------------------------------------------------------------------------------------------------
//#include "opencv2/core.hpp"
///#include <opencv2/core/utility.hpp>
//#include "opencv2/imgproc.hpp"
#include "opencv2/calib3d.hpp"
//#include "opencv2/imgcodecs.hpp"
//#include "opencv2/videoio.hpp"
//#include "opencv2/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <opencv2/features2d/features2d.hpp>
#include <iostream>
#include <fstream>
#include <vector>
using namespace cv;
using namespace std;
//#include "D:/work/ImageDetectionDll/ImageDetectionDll/imagedetection/common.h"
//#pragma comment(lib, "D:/work/testEdge001/x64/Debug/ImageDetectionDll.lib")
//-----------------------------------【宏定义部分】--------------------------------------------
// 描述:定义一些辅助宏
//------------------------------------------------------------------------------------------------
#define WINDOW_NAME "【程序窗口】" //为窗口标题定义的宏
//#define ThresholdBetween
//-----------------------------------【全局变量声明部分】--------------------------------------
// 描述:全局变量的声明
//-----------------------------------------------------------------------------------------------
int g_nThresholdValue = 87;
int g_nThresholdValue2 = 100;
int g_nThresholdType = 0;
int g_nThresholdOffset = 1;
Mat g_srcImage, g_grayImage, g_dstImage, g_grayImage1, g_grayImage2, g_grayImage3, g_grayImage4, g_grayImage5, g_grayImage6;
//-----------------------------------【全局函数声明部分】--------------------------------------
// 描述:全局函数的声明
//-----------------------------------------------------------------------------------------------
static void ShowHelpText();//输出帮助文字
void on_Threshold(int, void*);//回调函数
//-----------------------------------【main( )函数】--------------------------------------------
// 描述:控制台应用程序的入口函数,我们的程序从这里开始执行
//-----------------------------------------------------------------------------------------------
//void Tsai_HandEye(Mat Hcg, vector<Mat> Hgij, vector<Mat> Hcij)
//{
// CV_Assert(Hgij.size() == Hcij.size());
// int nStatus = Hgij.size();
//
// Mat Rgij(3, 3, CV_64FC1);
// Mat Rcij(3, 3, CV_64FC1);
//
// Mat rgij(3, 1, CV_64FC1);
// Mat rcij(3, 1, CV_64FC1);
//
// double theta_gij;
// double theta_cij;
//
// Mat rngij(3, 1, CV_64FC1);
// Mat rncij(3, 1, CV_64FC1);
//
// Mat Pgij(3, 1, CV_64FC1);
// Mat Pcij(3, 1, CV_64FC1);
//
// Mat tempA(3, 3, CV_64FC1);
// Mat tempb(3, 1, CV_64FC1);
//
// Mat A;
// Mat b;
// Mat pinA;
//
// Mat Pcg_prime(3, 1, CV_64FC1);
// Mat Pcg(3, 1, CV_64FC1);
// Mat PcgTrs(1, 3, CV_64FC1);
//
// Mat Rcg(3, 3, CV_64FC1);
// Mat eyeM = Mat::eye(3, 3, CV_64FC1);
//
// Mat Tgij(3, 1, CV_64FC1);
// Mat Tcij(3, 1, CV_64FC1);
//
// Mat tempAA(3, 3, CV_64FC1);
// Mat tempbb(3, 1, CV_64FC1);
//
// Mat AA;
// Mat bb;
// Mat pinAA;
//
// Mat Tcg(3, 1, CV_64FC1);
//
// for (int i = 0; i < nStatus; i++)
// {
// Hgij[i](Rect(0, 0, 3, 3)).copyTo(Rgij);
// Hcij[i](Rect(0, 0, 3, 3)).copyTo(Rcij);
//
// Rodrigues(Rgij, rgij);
// Rodrigues(Rcij, rcij);
//
// theta_gij = norm(rgij);
// theta_cij = norm(rcij);
//
// rngij = rgij / theta_gij;
// rncij = rcij / theta_cij;
//
// Pgij = 2 * sin(theta_gij / 2)*rngij;
// Pcij = 2 * sin(theta_cij / 2)*rncij;
//
// tempA = skew(Pgij + Pcij);
// tempb = Pcij - Pgij;
//
// A.push_back(tempA);
// b.push_back(tempb);
// }
//
// //Compute rotation
// invert(A, pinA, DECOMP_SVD);
//
// Pcg_prime = pinA * b;
// Pcg = 2 * Pcg_prime / sqrt(1 + norm(Pcg_prime) * norm(Pcg_prime));
// PcgTrs = Pcg.t();
// Rcg = (1 - norm(Pcg) * norm(Pcg) / 2) * eyeM + 0.5 * (Pcg * PcgTrs + sqrt(4 - norm(Pcg)*norm(Pcg))*skew(Pcg));
//
// //Computer Translation
// for (int i = 0; i < nStatus; i++)
// {
// Hgij[i](Rect(0, 0, 3, 3)).copyTo(Rgij);
// Hcij[i](Rect(0, 0, 3, 3)).copyTo(Rcij);
// Hgij[i](Rect(3, 0, 1, 3)).copyTo(Tgij);
// Hcij[i](Rect(3, 0, 1, 3)).copyTo(Tcij);
//
//
// tempAA = Rgij - eyeM;
// tempbb = Rcg * Tcij - Tgij;
//
// AA.push_back(tempAA);
// bb.push_back(tempbb);
// }
//
// invert(AA, pinAA, DECOMP_SVD);
// Tcg = pinAA * bb;
//
// Rcg.copyTo(Hcg(Rect(0, 0, 3, 3)));
// Tcg.copyTo(Hcg(Rect(3, 0, 1, 3)));
// Hcg.at<double>(3, 0) = 0.0;
// Hcg.at<double>(3, 1) = 0.0;
// Hcg.at<double>(3, 2) = 0.0;
// Hcg.at<double>(3, 3) = 1.0;
//
//}
void ky_thinY(const Mat &src, Mat &dst, const int nYLength=1, int nType=0)
{
const int height = src.rows;
const int width = src.cols;
//拷贝一个数组给另一个数组
if (src.data != dst.data)
{
src.copyTo(dst);
}
for (int i = 0; i < width; i++)
{
int iLength = 0;
for (int j = 0; j < height; j++)
{
if (j == height - 1)
{
//test 下方不处理,便于寻找标签位置
//continue;
if (0 == nType)
{
if (dst.ptr<uchar>(j)[i] > 0)
{
iLength++;
}
}
else
{
if (dst.ptr<uchar>(j)[i] == 0)
{
iLength++;
}
}
if (iLength>0)
{
if (iLength >= nYLength)
{
for (int m = 0; m < iLength; m++)
{
int iLeave = iLength - nYLength;
if (iLeave == 0)
{
continue;
}
iLeave = iLeave / 2;
if (m < iLeave || m >= iLength - iLeave - 1)
{
if (0 == nType)
{
if (j - m <= height)
{
dst.ptr<uchar>(j - m)[i] = 0;
}
}
else
{
if (j - m <= height)
{
dst.ptr<uchar>(j - m)[i] = 255;
}
}
}
}
}
else
{
for (int m = 0; m < iLength; m++)
{
if (0 == nType)
{
if (j - 1 - m <= height)
{
dst.ptr<uchar>(j - m)[i] = 0;
}
}
else
{
if (j - 1 - m <= height)
{
dst.ptr<uchar>(j - m)[i] = 255;
}
}
}
}
iLength = 0;
}
}
if (0 == nType)
{
if (dst.ptr<uchar>(j)[i] > 0)
{
iLength++;
continue;
}
}
else
{
if (dst.ptr<uchar>(j)[i] == 0)
{
iLength++;
continue;
}
}
if (iLength>0)
{
if (iLength >= nYLength)
{
for (int m = 0; m < iLength; m++)
{
int iLeave = iLength - nYLength;
if (iLeave == 0)
{
continue;
}
iLeave = iLeave / 2;
if (m < iLeave || m >= iLength - iLeave - 1)
{
if (0 == nType)
{
if (j - 1 - m <= height)
{
dst.ptr<uchar>(j - 1 - m)[i] = 0;
}
}
else
{
if (j - 1 - m <= height)
{
dst.ptr<uchar>(j - 1 - m)[i] = 255;
}
}
}
}
}
else
{
for (int m = 0; m < iLength; m++)
{
if (0 == nType)
{
if (j - 1 - m <= height)
{
dst.ptr<uchar>(j - 1 - m)[i] = 0;
}
}
else
{
if (j - 1 - m <= height)
{
dst.ptr<uchar>(j - 1 - m)[i] = 255;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于C++的opencv自动标定案例.zip (70个子文件)
标定案例
testEdge018.v12.suo 19KB
testEdge001
testEdge001.vcxproj 7KB
15.bmp 1.17MB
17.bmp 1.17MB
11.bmp 1.17MB
33.bmp 1.17MB
32.bmp 1.17MB
4.bmp 1.17MB
16.bmp 1.17MB
27.bmp 1.17MB
13.bmp 1.17MB
24.bmp 1.17MB
blobs.cpp 6KB
29.bmp 1.17MB
31.bmp 1.17MB
18.bmp 1.17MB
testEdge001.vcxproj.user 165B
1.bmp 1.17MB
22.bmp 1.17MB
7.bmp 1.17MB
5.bmp 1.17MB
x64
Debug
vc120.pdb 988KB
main.obj 1.54MB
testEdge019.tlog
cl.command.1.tlog 1KB
CL.read.1.tlog 36KB
link.read.1.tlog 6KB
link.write.1.tlog 962B
CL.write.1.tlog 990B
link.command.1.tlog 3KB
testEdge019.lastbuildstate 174B
vc120.idb 851KB
testEdge001.log 6KB
main.cpp 39KB
14.bmp 1.17MB
testEdge001.vcxproj.filters 945B
12.bmp 1.17MB
30.bmp 1.17MB
19.bmp 1.17MB
2.bmp 1.17MB
6.bmp 1.17MB
10.bmp 1.17MB
36.bmp 1.17MB
26.bmp 1.17MB
3.bmp 1.17MB
34.bmp 1.17MB
8.bmp 1.17MB
9.bmp 1.17MB
21.bmp 1.17MB
20.bmp 1.17MB
28.bmp 1.17MB
25.bmp 1.17MB
35.bmp 1.17MB
23.bmp 1.17MB
testEdge009.opensdf 20B
testEdge019.v12.suo 42KB
testEdge015.v12.suo 24KB
x64
Debug
testEdge019.exe 288KB
testEdge019.pdb 2.66MB
testEdge019.ilk 1.16MB
testEdge006.suo 19KB
testEdge009.v12.suo 23KB
testEdge005.suo 45KB
testEdge002.suo 64KB
testEdge013.suo 25KB
testEdge019.sln 1KB
testEdge008.suo 15KB
testEdge009.suo 15KB
testEdge019.sdf 13.31MB
testEdge007.suo 21KB
testEdge013.v12.suo 21KB
共 70 条
- 1
资源评论
- 瓜言先生2018-11-20书上的例题!
- BURUCE7352023-03-06下载出错,,,,,
天高海阔lvn
- 粉丝: 3
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功