Commit bebc2453 张士柳

整理

1 个父辈 04c03c6d
......@@ -305,7 +305,7 @@ namespace eyemLib_Sharp
[StructLayout(LayoutKind.Sequential)]
public struct EyemImage
{
public IntPtr vpImage; // 地址
public IntPtr vpImage; // 地址
public int iWidth; // 图像内存 x 方向大小
public int iHeight; // 图像内存 y 方向大小
public int iDepth; // 图像位深度(详见说明)
......@@ -600,15 +600,18 @@ namespace eyemLib_Sharp
//图像数据格式转换
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemCvtImageType(EyemImage tpImage, int rType, double alpha, double beta, ref EyemImage tpDstImg);
//显示图像
//图像相加
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemImageDisplay(string ccWinName, EyemImage tpImage);
//创建窗口
private static extern int eyemImageAdd(EyemImage tpImage1, EyemImage tpImage2, ref EyemImage tpDstImg);
//图像相减
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemOpenWindow(string ccWinName);
//关闭窗口
private static extern int eyemImageSub(EyemImage tpImageMinuend, EyemImage tpImageSubtrahend, ref EyemImage tpDstImg);
//图像相除
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemCloseWindow(string ccWinName);
private static extern int eyemImageDiv(EyemImage tpImage1, EyemImage tpImage2, ref EyemImage tpDstImg);
//图像取绝对值
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemImageAbs(EyemImage tpImage, ref EyemImage tpDstImg);
//释放图像资源
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern void eyemImageFree(IntPtr ipImage);
......@@ -701,25 +704,32 @@ namespace eyemLib_Sharp
public static void eyemReadImageTool(string fileName)
{
EyemImage ucpImage;
EyemImage image;
EyemImage tpDstImg = new EyemImage();
//int flag = eyemImageRead("D:\\图片及统计结果\\图片及统计结果\\data\\6D551\\6D551-R014212020040601587-20200624140637.png", 0, out ucpImage);
//int flag = eyemImageReadRaw(fileName, 3072, 3072, 2, out ucpImage);
int flag = eyemImageRead(fileName, -1, out ucpImage);
int flag = eyemImageRead(fileName, -1, out image);
if (flag != 0)
{
Console.WriteLine("读图失败!");
return;
}
eyemOpenWindow("eyemLib");
EyemImage image1 = new EyemImage();
EyemImage image2 = new EyemImage();
flag = eyemImageMalloc(image.iWidth, image.iHeight, 1, "int8_t", out image1);
//flag = eyemImageMalloc(image.iWidth, image.iHeight, 1, "int8_t", out image2);
//flag = eyemImageAdd(image1, image2, ref tpDstImg);
eyemImageDisplay("eyemLib", ucpImage);
//flag = eyemImageSub(image1, image2, ref tpDstImg)
//flag = eyemImageMalloc(ucpImage.iWidth, ucpImage.iHeight, 1, "uint8_t", out tpDstImg);
//flag = eyemImageAbs(image1, ref tpDstImg);
//flag = eyemCvtImageColor(ucpImage, (int)ColorConversionCodes.COLOR_BGR2RGB, ref tpDstImg);
//Bitmap bmp = new Bitmap(ucpImage.iWidth, ucpImage.iHeight, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
//ColorPalette color_palette_gray_ = bmp.Palette;
//for (int i = 0; i < 256; i++)
......@@ -878,8 +888,8 @@ namespace eyemLib_Sharp
EyemRect tpRoi = new EyemRect();
tpRoi.iXs = tpRoi.iYs = 0;
tpRoi.iWidth = ucpImage.iWidth;
tpRoi.iHeight = ucpImage.iHeight;
tpRoi.iWidth = image.iWidth;
tpRoi.iHeight = image.iHeight;
//
string pNumObj = "";
string file = fileName.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries)[2];
......@@ -899,53 +909,9 @@ namespace eyemLib_Sharp
//Console.WriteLine("耗时:" + sw.ElapsedMilliseconds.ToString() + ",结果:" + pNumObj);
//free image
eyemImageFree(tpDstImg.vpImage);
eyemImageFree(ucpImage.vpImage);
}
//计算最佳参数
public static void eyemReadImageToolTest(string fileName)
{
EyemImage ucpImage;
int flag = eyemImageRead(fileName, -1, out ucpImage);
if (flag != 0)
{
Console.WriteLine("读图失败!");
return;
}
EyemRect tpRoi = new EyemRect();
tpRoi.iXs = tpRoi.iYs = 0;
tpRoi.iWidth = ucpImage.iWidth;
tpRoi.iHeight = ucpImage.iHeight;
//
System.Collections.Generic.Dictionary<int, int> dictPara = new System.Collections.Generic.Dictionary<int, int>();
string file = fileName.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries)[2];
for (int ii = 5; ii < 27; ii += 2)
{
int ipNum; EyemBarCode* tpResults;
DataCodeHandle hObject;
int iRes = eyemDetectAndDecode(ucpImage, tpRoi, file.Replace(".png", ""), "QR_CODE|DATA_MATRIX|CODE_128", out hObject, out tpResults, out ipNum, false, ii, 5, 128, 215, 1d);
dictPara.Add(ii, ipNum);
hObject.Dispose();
//Console.WriteLine("数量:" + ipNum + ";" + "参数:" + ii.ToString());
}
var sortResult = from dic in dictPara orderby dic.Value descending select dic;
foreach (KeyValuePair<int, int> kvp in sortResult)
{
int ipNum; EyemBarCode* tpResults;
DataCodeHandle hObject;
int iRes = eyemDetectAndDecode(ucpImage, tpRoi, file.Replace(".png", ""), "QR_CODE|DATA_MATRIX|CODE_128", out hObject, out tpResults, out ipNum, false, kvp.Key, 5, 128, 215, 1d);
hObject.Dispose();
Console.WriteLine("最佳参数:" + kvp.Key);
break;
}
//free image
eyemImageFree(ucpImage.vpImage);
return;
eyemImageFree(image.vpImage);
}
#region 结构转内存指针
public static IntPtr teStructArray2IntPtr(EyemOcsDXY[] tpPoints, int iLength)
{
......
using Microsoft.Win32.SafeHandles;
using System;
using System.Runtime.InteropServices;
namespace eyemLib_Sharp
{
//public unsafe class EyemSamples
//{
// #region 通用
// // Win32 memory copy function
// [DllImport("ntdll.dll", CallingConvention = CallingConvention.Cdecl)]
// private static extern byte* memcpy(byte* dst, byte* src, int count);
// //读取图像
// [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
// private static extern int eyemImageRead(string filename, int iFalgs, out EyemImage ucpImage);
// //保存图像
// [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
// private static extern int eyemImageWrite(string filename, EyemImage ipImage);
// //释放图像资源
// [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
// private static extern void eyemImageFree(IntPtr ipImage);
// #endregion
// //读码程序
// [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
// private static extern int eyemDetectAndDecode(EyemImage tpImage, EyemRect tpRoi, string fileName, string strCodeType, out DataCodeHandle hObject, out EyemBarCode* tpResults, out int ipNum, bool bUseNiBlack, int iBlockSize, int iRangeC, int iSymbolMin, int iSymbolMax, double dToleErr = 0.5, double dMinorStep = 1.0);
// //释放工具
// [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
// private static extern bool eyemDetectAndDecodeFree(IntPtr hObject);
// public static void eyemReadImageTool(string fileName)
// {
// EyemImage ucpImage;
// int flag = eyemImageRead(fileName, -1, out ucpImage);
// if (flag != 0)
// {
// Console.WriteLine("读图失败!");
// return;
// }
// EyemRect tpRoi = new EyemRect();
// tpRoi.iXs = tpRoi.iYs = 0;
// tpRoi.iWidth = ucpImage.iWidth;
// tpRoi.iHeight = ucpImage.iHeight;
// string file = fileName.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries)[2];
// int ipNum; EyemBarCode* tpResults;
// DataCodeHandle hObject;
// eyemDetectAndDecode(ucpImage, tpRoi, file.Replace(".png", ""), "QRCode", out hObject, out tpResults, out ipNum, false, 11, 5, 128, 215);
// for (int i = 0; i < ipNum; i++)
// {
// Console.WriteLine("类型:" + Marshal.PtrToStringAnsi(tpResults[i].hType) + ";坐标" + "[" + tpResults[i].iCenterX.ToString() + "," + tpResults[i].iCenterY.ToString() + "]" + ";内容:" + Marshal.PtrToStringAnsi(tpResults[i].hText) + "");
// }
// //释放
// hObject.Dispose();
// //释放图像
// eyemImageFree(ucpImage.ucpImage);
// }
// //释放解码句柄
// public class DataCodeHandle : SafeHandleZeroOrMinusOneIsInvalid
// {
// public DataCodeHandle() : base(true) { }
// protected override bool ReleaseHandle()
// {
// return eyemDetectAndDecodeFree(handle);
// }
// }
//}
}
......@@ -48,7 +48,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EyemSamples.cs" />
<Compile Include="EyemLib.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
......
......@@ -51,6 +51,7 @@ static cv::Mat getQRRegion(cv::Mat src, cv::RotatedRect rect, double angle)
return image(RoiRect);
}
static void split(const std::string &cStrText, const std::string &cStrDelim, std::vector<std::string> &vStrs)
{
char *cpStr = new char[strlen(cStrText.c_str()) + 1];
......@@ -67,6 +68,7 @@ static void split(const std::string &cStrText, const std::string &cStrDelim, std
cpStr = NULL;
}
static void filterByApriltag(cv::Mat &binary, cv::Mat &labels, std::vector<tMap> &vPts, std::vector<uchar> &colors, int nccomps, double dToleErr = 0.5)
{
//图像尺寸
......@@ -257,12 +259,14 @@ static void filterByApriltag(cv::Mat &binary, cv::Mat &labels, std::vector<tMap>
});
}
static inline bool isContainsTwoDCode()
{
return false;
}
static double getThreshVal_Otsu_8u(const cv::Mat& _src)
{
cv::Size size = _src.size();
......@@ -339,6 +343,7 @@ static double getThreshVal_Otsu_8u(const cv::Mat& _src)
return max_val;
}
static void decodeMul(std::vector<WaitArea> &waitAreas, std::vector<std::string> &hints, cv::Mat &showMat, std::vector<DecodeResult> &decodeResults, int iBlockSize, const int iRangeC, double dMinorStep)
{
//进入线程锁
......@@ -564,6 +569,7 @@ static void decodeMul(std::vector<WaitArea> &waitAreas, std::vector<std::string>
mtx.unlock();
}
static int calcHist(cv::Mat src)
{
const int histSize = 256;
......@@ -578,6 +584,7 @@ static int calcHist(cv::Mat src)
return maxIdx[0];
}
int eyemDetectAndDecode(EyemImage tpImage, EyemRect tpRoi, const char *ccFileName, const char *ccCodeType, IntPtr *hObject, EyemBarCode **hResults, int *ipNum, bool bUseNiBlack, int iBlockSize, const int iRangeC, int iSymbolMin, int iSymbolMax, double dScaleUpAndDown, double dToleErr, double dMinorStep)
{
cv::Mat src = cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage);
......@@ -1496,6 +1503,7 @@ int eyemDetectAndDecode(EyemImage tpImage, EyemRect tpRoi, const char *ccFileNam
return FUNC_OK;
}
int eyemCalcDetectParameter(EyemImage tpImage, EyemRect tpRoi, const char *ccFileName, bool bTrainOneD, int iBlockSize, int *ipNum, int *iSymbolMin, int *iSymbolMax)
{
cv::Mat src = cv::Mat(tpImage.iHeight, tpImage.iWidth, tpImage.iDepth, tpImage.vpImage);
......@@ -1783,6 +1791,7 @@ int eyemCalcDetectParameter(EyemImage tpImage, EyemRect tpRoi, const char *ccFil
return FUNC_OK;
}
bool eyemDetectAndDecodeFree(IntPtr hObject)
{
std::vector<EyemBarCode> *tpResults = reinterpret_cast<std::vector<EyemBarCode>*>(hObject);
......
#include "eyemEDLinesDetector.h"
void detectE(cv::InputArray _image, cv::OutputArray _lines)
{
cv::Mat image = _image.getMat();
CV_Assert(!image.empty() && image.type() == CV_8UC1);
std::vector<cv::Vec4f> lines;
std::vector<SEGMENT> segments;
lineDetectionE(image, segments);
for (size_t i = 0; i < segments.size(); ++i)
{
const SEGMENT seg = segments[i];
cv::Vec4f line(seg.x1, seg.y1, seg.x2, seg.y2);
lines.push_back(line);
}
cv::Mat(lines).copyTo(_lines);
}
void drawSegmentsE(cv::InputOutputArray _image, cv::InputArray lines, bool draw_arrow)
{
CV_Assert(!_image.empty() && (_image.channels() == 1 || _image.channels() == 3));
Mat gray;
if (_image.channels() == 1)
{
gray = _image.getMatRef();
}
else if (_image.channels() == 3)
{
cvtColor(_image, gray, COLOR_BGR2GRAY);
}
// Create a 3 channel image in order to draw colored lines
std::vector<Mat> planes;
planes.push_back(gray);
planes.push_back(gray);
planes.push_back(gray);
merge(planes, _image);
double gap = 10.0;
double arrow_angle = 30.0;
Mat _lines;
_lines = lines.getMat();
int N = _lines.checkVector(4);
// Draw segments
for (int i = 0; i < N; ++i)
{
const Vec4f& v = _lines.at<Vec4f>(i);
Point2f b(v[0], v[1]);
Point2f e(v[2], v[3]);
line(_image.getMatRef(), b, e, Scalar(0, 0, 255), 1);
if (draw_arrow)
{
SEGMENT seg;
seg.x1 = b.x;
seg.y1 = b.y;
seg.x2 = e.x;
seg.y2 = e.y;
getAngleE(seg);
double ang = (double)seg.angle;
Point2i p1;
p1.x = cvRound(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang));
p1.y = cvRound(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang));
pointInboardTestE(_image.getMatRef(), p1);
line(_image.getMatRef(), Point(cvRound(seg.x2), cvRound(seg.y2)), p1, Scalar(0, 0, 255), 1);
}
}
}
void mergeLinesE(const SEGMENT& seg1, const SEGMENT& seg2, SEGMENT& seg_merged)
{
double xg = 0.0, yg = 0.0;
double delta1x = 0.0, delta1y = 0.0, delta2x = 0.0, delta2y = 0.0;
float ax = 0, bx = 0, cx = 0, dx = 0;
float ay = 0, by = 0, cy = 0, dy = 0;
double li = 0.0, lj = 0.0;
double thi = 0.0, thj = 0.0, thr = 0.0;
double axg = 0.0, bxg = 0.0, cxg = 0.0, dxg = 0.0, delta1xg = 0.0, delta2xg = 0.0;
ax = seg1.x1;
ay = seg1.y1;
bx = seg1.x2;
by = seg1.y2;
cx = seg2.x1;
cy = seg2.y1;
dx = seg2.x2;
dy = seg2.y2;
float dlix = (bx - ax);
float dliy = (by - ay);
float dljx = (dx - cx);
float dljy = (dy - cy);
li = sqrt((double)(dlix * dlix) + (double)(dliy * dliy));
lj = sqrt((double)(dljx * dljx) + (double)(dljy * dljy));
xg = (li * (double)(ax + bx) + lj * (double)(cx + dx))
/ (double)(2.0 * (li + lj));
yg = (li * (double)(ay + by) + lj * (double)(cy + dy))
/ (double)(2.0 * (li + lj));
if (dlix == 0.0f) thi = CV_PI / 2.0;
else thi = atan(dliy / dlix);
if (dljx == 0.0f) thj = CV_PI / 2.0;
else thj = atan(dljy / dljx);
if (fabs(thi - thj) <= CV_PI / 2.0)
{
thr = (li * thi + lj * thj) / (li + lj);
}
else
{
double tmp = thj - CV_PI * (thj / fabs(thj));
thr = li * thi + lj * tmp;
thr /= (li + lj);
}
axg = ((double)ay - yg) * sin(thr) + ((double)ax - xg) * cos(thr);
bxg = ((double)by - yg) * sin(thr) + ((double)bx - xg) * cos(thr);
cxg = ((double)cy - yg) * sin(thr) + ((double)cx - xg) * cos(thr);
dxg = ((double)dy - yg) * sin(thr) + ((double)dx - xg) * cos(thr);
delta1xg = min(axg, min(bxg, min(cxg, dxg)));
delta2xg = max(axg, max(bxg, max(cxg, dxg)));
delta1x = delta1xg * cos(thr) + xg;
delta1y = delta1xg * sin(thr) + yg;
delta2x = delta2xg * cos(thr) + xg;
delta2y = delta2xg * sin(thr) + yg;
seg_merged.x1 = (float)delta1x;
seg_merged.y1 = (float)delta1y;
seg_merged.x2 = (float)delta2x;
seg_merged.y2 = (float)delta2y;
}
double distPointLineE(const Mat& p, Mat& l)
{
double x = l.at<double>(0, 0);
double y = l.at<double>(1, 0);
double w = sqrt(x*x + y*y);
l.at<double>(0, 0) = x / w;
l.at<double>(1, 0) = y / w;
l.at<double>(2, 0) = l.at<double>(2, 0) / w;
return l.dot(p);
}
bool mergeSegmentsE(const SEGMENT& seg1, const SEGMENT& seg2, SEGMENT& seg_merged)
{
double o[] = { 0.0, 0.0, 1.0 };
double a[] = { 0.0, 0.0, 1.0 };
double b[] = { 0.0, 0.0, 1.0 };
double c[3];
o[0] = (seg2.x1 + seg2.x2) / 2.0;
o[1] = (seg2.y1 + seg2.y2) / 2.0;
a[0] = seg1.x1;
a[1] = seg1.y1;
b[0] = seg1.x2;
b[1] = seg1.y2;
Mat ori = Mat(3, 1, CV_64FC1, o).clone();
Mat p1 = Mat(3, 1, CV_64FC1, a).clone();
Mat p2 = Mat(3, 1, CV_64FC1, b).clone();
Mat l1 = Mat(3, 1, CV_64FC1, c).clone();
l1 = p1.cross(p2);
Point2f seg1mid, seg2mid;
seg1mid.x = (seg1.x1 + seg1.x2) / 2.0f;
seg1mid.y = (seg1.y1 + seg1.y2) / 2.0f;
seg2mid.x = (seg2.x1 + seg2.x2) / 2.0f;
seg2mid.y = (seg2.y1 + seg2.y2) / 2.0f;
float seg1len = sqrt((seg1.x1 - seg1.x2)*(seg1.x1 - seg1.x2) + (seg1.y1 - seg1.y2)*(seg1.y1 - seg1.y2));
float seg2len = sqrt((seg2.x1 - seg2.x2)*(seg2.x1 - seg2.x2) + (seg2.y1 - seg2.y2)*(seg2.y1 - seg2.y2));
float middist = sqrt((seg1mid.x - seg2mid.x)*(seg1mid.x - seg2mid.x) + (seg1mid.y - seg2mid.y)*(seg1mid.y - seg2mid.y));
float angdiff = fabs(seg1.angle - seg2.angle);
float dist = (float)distPointLineE(ori, l1);
if (fabs(dist) <= threshold_dist * 2.0f && middist <= seg1len / 2.0f + seg2len / 2.0f + 20.0f
&& angdiff <= CV_PI / 180.0f * 5.0f)
{
mergeLinesE(seg1, seg2, seg_merged);
return true;
}
else
{
return false;
}
}
template<class T>
void incidentPointE(const Mat& l, T& pt)
{
double a[] = { (double)pt.x, (double)pt.y, 1.0 };
double b[] = { l.at<double>(0,0), l.at<double>(1,0), 0.0 };
double c[3];
Mat xk = Mat(3, 1, CV_64FC1, a).clone();
Mat lh = Mat(3, 1, CV_64FC1, b).clone();
Mat lk = Mat(3, 1, CV_64FC1, c).clone();
lk = xk.cross(lh);
xk = lk.cross(l);
xk.convertTo(xk, -1, 1.0 / xk.at<double>(2, 0));
Point2f pt_tmp;
pt_tmp.x = (float)xk.at<double>(0, 0) < 0.0f ? 0.0f : (float)xk.at<double>(0, 0)
>= (imagewidth - 1.0f) ? (imagewidth - 1.0f) : (float)xk.at<double>(0, 0);
pt_tmp.y = (float)xk.at<double>(1, 0) < 0.0f ? 0.0f : (float)xk.at<double>(1, 0)
>= (imageheight - 1.0f) ? (imageheight - 1.0f) : (float)xk.at<double>(1, 0);
pt = T(pt_tmp);
}
void extractSegmentsE(const std::vector<Point2i>& points, std::vector<SEGMENT>& segments)
{
bool is_line;
int i, j;
SEGMENT seg;
Point2i ps, pe, pt;
std::vector<Point2i> l_points;
int total = (int)points.size();
for (i = 0; i + threshold_length < total; i++)
{
ps = points[i];
pe = points[i + threshold_length];
double a[] = { (double)ps.x, (double)ps.y, 1 };
double b[] = { (double)pe.x, (double)pe.y, 1 };
double c[3], d[3];
Mat p1 = Mat(3, 1, CV_64FC1, a).clone();
Mat p2 = Mat(3, 1, CV_64FC1, b).clone();
Mat p = Mat(3, 1, CV_64FC1, c).clone();
Mat l = Mat(3, 1, CV_64FC1, d).clone();
l = p1.cross(p2);
is_line = true;
l_points.clear();
l_points.push_back(ps);
for (j = 1; j < threshold_length; j++)
{
pt.x = points[i + j].x;
pt.y = points[i + j].y;
p.at<double>(0, 0) = (double)pt.x;
p.at<double>(1, 0) = (double)pt.y;
p.at<double>(2, 0) = 1.0;
double dist = distPointLineE(p, l);
if (fabs(dist) > threshold_dist)
{
is_line = false;
break;
}
l_points.push_back(pt);
}
// Line check fail, test next point
if (is_line == false)
continue;
l_points.push_back(pe);
Vec4f line;
fitLine(Mat(l_points), line, DIST_L2, 0, 0.01, 0.01);
a[0] = line[2];
a[1] = line[3];
b[0] = line[2] + line[0];
b[1] = line[3] + line[1];
p1 = Mat(3, 1, CV_64FC1, a).clone();
p2 = Mat(3, 1, CV_64FC1, b).clone();
l = p1.cross(p2);
incidentPointE(l, ps);
// Extending line
for (j = threshold_length + 1; i + j < total; j++)
{
pt.x = points[i + j].x;
pt.y = points[i + j].y;
p.at<double>(0, 0) = (double)pt.x;
p.at<double>(1, 0) = (double)pt.y;
p.at<double>(2, 0) = 1.0;
double dist = distPointLineE(p, l);
if (fabs(dist) > threshold_dist)
{
fitLine(Mat(l_points), line, DIST_L2, 0, 0.01, 0.01);
a[0] = line[2];
a[1] = line[3];
b[0] = line[2] + line[0];
b[1] = line[3] + line[1];
p1 = Mat(3, 1, CV_64FC1, a).clone();
p2 = Mat(3, 1, CV_64FC1, b).clone();
l = p1.cross(p2);
dist = distPointLineE(p, l);
if (fabs(dist) > threshold_dist) {
j--;
break;
}
}
pe = pt;
l_points.push_back(pt);
}
fitLine(Mat(l_points), line, DIST_L2, 0, 0.01, 0.01);
a[0] = line[2];
a[1] = line[3];
b[0] = line[2] + line[0];
b[1] = line[3] + line[1];
p1 = Mat(3, 1, CV_64FC1, a).clone();
p2 = Mat(3, 1, CV_64FC1, b).clone();
l = p1.cross(p2);
Point2f e1, e2;
e1.x = (float)ps.x;
e1.y = (float)ps.y;
e2.x = (float)pe.x;
e2.y = (float)pe.y;
incidentPointE(l, e1);
incidentPointE(l, e2);
seg.x1 = e1.x;
seg.y1 = e1.y;
seg.x2 = e2.x;
seg.y2 = e2.y;
segments.push_back(seg);
i = i + j;
}
}
void pointInboardTestE(const Mat& src, Point2i& pt)
{
pt.x = pt.x <= 5 ? 5 : pt.x >= src.cols - 5 ? src.cols - 5 : pt.x;
pt.y = pt.y <= 5 ? 5 : pt.y >= src.rows - 5 ? src.rows - 5 : pt.y;
}
bool getPointChainE(const Mat& img, Point pt,
Point& chained_pt, float& direction, int step)
{
int ri, ci;
int indices[8][2] = { { 1,1 },{ 1,0 },{ 1,-1 },{ 0,-1 },
{ -1,-1 },{ -1,0 },{ -1,1 },{ 0,1 } };
float min_dir_diff = 7.0f;
Point consistent_pt;
int consistent_direction = 0;
for (int i = 0; i < 8; i++)
{
ci = pt.x + indices[i][1];
ri = pt.y + indices[i][0];
if (ri < 0 || ri == img.rows || ci < 0 || ci == img.cols)
continue;
if (img.at<unsigned char>(ri, ci) == 0)
continue;
if (step == 0)
{
chained_pt.x = ci;
chained_pt.y = ri;
// direction = (float)i;
direction = i > 4 ? (float)(i - 8) : (float)i;
return true;
}
else
{
float curr_dir = i > 4 ? (float)(i - 8) : (float)i;
float dir_diff = abs(curr_dir - direction);
dir_diff = dir_diff > 4.0f ? 8.0f - dir_diff : dir_diff;
if (dir_diff <= min_dir_diff)
{
min_dir_diff = dir_diff;
consistent_pt.x = ci;
consistent_pt.y = ri;
consistent_direction = i > 4 ? i - 8 : i;
}
}
}
if (min_dir_diff < 2.0f)
{
chained_pt.x = consistent_pt.x;
chained_pt.y = consistent_pt.y;
direction = (direction * (float)step + (float)consistent_direction)
/ (float)(step + 1);
return true;
}
return false;
}
void lineDetectionE(const Mat& src, std::vector<SEGMENT>& segments_all)
{
int r, c;
imageheight = src.rows; imagewidth = src.cols;
std::vector<Point2i> points;
std::vector<SEGMENT> segments, segments_tmp;
Mat canny;
if (canny_aperture_size == 0)
{
canny = src;
}
else
{
Canny(src, canny, canny_th1, canny_th2, canny_aperture_size);
}
canny.colRange(0, 6).rowRange(0, 6) = 0;
canny.colRange(src.cols - 5, src.cols).rowRange(src.rows - 5, src.rows) = 0;
SEGMENT seg, seg1, seg2;
for (r = 0; r < imageheight; r++)
{
for (c = 0; c < imagewidth; c++)
{
// Find seeds - skip for non-seeds
if (canny.at<unsigned char>(r, c) == 0)
continue;
// Found seeds
Point2i pt = Point2i(c, r);
points.push_back(pt);
canny.at<unsigned char>(pt.y, pt.x) = 0;
float direction = 0.0f;
int step = 0;
while (getPointChainE(canny, pt, pt, direction, step))
{
points.push_back(pt);
step++;
canny.at<unsigned char>(pt.y, pt.x) = 0;
}
if (points.size() < (unsigned int)threshold_length + 1)
{
points.clear();
continue;
}
extractSegmentsE(points, segments);
if (segments.size() == 0)
{
points.clear();
continue;
}
for (int i = 0; i < (int)segments.size(); i++)
{
seg = segments[i];
float length = sqrt((seg.x1 - seg.x2)*(seg.x1 - seg.x2) +
(seg.y1 - seg.y2)*(seg.y1 - seg.y2));
if (length < threshold_length)
continue;
if ((seg.x1 <= 5.0f && seg.x2 <= 5.0f) ||
(seg.y1 <= 5.0f && seg.y2 <= 5.0f) ||
(seg.x1 >= imagewidth - 5.0f && seg.x2 >= imagewidth - 5.0f) ||
(seg.y1 >= imageheight - 5.0f && seg.y2 >= imageheight - 5.0f))
continue;
additionalOperationsOnSegmentE(src, seg);
if (!do_merge)
segments_all.push_back(seg);
segments_tmp.push_back(seg);
}
points.clear();
segments.clear();
}
}
if (!do_merge)
return;
bool is_merged = false;
int ith = (int)segments_tmp.size() - 1;
int jth = ith - 1;
while (ith > 1 || jth > 0)
{
seg1 = segments_tmp[ith];
seg2 = segments_tmp[jth];
SEGMENT seg_merged;
is_merged = mergeSegmentsE(seg1, seg2, seg_merged);
if (is_merged == true)
{
seg2 = seg_merged;
additionalOperationsOnSegmentE(src, seg2);
std::vector<SEGMENT>::iterator it = segments_tmp.begin() + ith;
*it = seg2;
segments_tmp.erase(segments_tmp.begin() + jth);
ith--;
jth = ith - 1;
}
else
{
jth--;
}
if (jth < 0) {
ith--;
jth = ith - 1;
}
}
segments_all = segments_tmp;
}
static inline void getAngleE(SEGMENT& seg)
{
seg.angle = (float)(fastAtan2(seg.y2 - seg.y1, seg.x2 - seg.x1) / 180.0f * CV_PI);
}
static void additionalOperationsOnSegmentE(const Mat& src, SEGMENT& seg)
{
if (seg.x1 == 0.0f && seg.x2 == 0.0f && seg.y1 == 0.0f && seg.y2 == 0.0f)
return;
getAngleE(seg);
double ang = (double)seg.angle;
Point2f start = Point2f(seg.x1, seg.y1);
Point2f end = Point2f(seg.x2, seg.y2);
double dx = 0.0, dy = 0.0;
dx = (double)end.x - (double)start.x;
dy = (double)end.y - (double)start.y;
int num_points = 10;
Point2f *points = new Point2f[num_points];
points[0] = start;
points[num_points - 1] = end;
for (int i = 0; i < num_points; i++)
{
if (i == 0 || i == num_points - 1)
continue;
points[i].x = points[0].x + ((float)dx / float(num_points - 1) * (float)i);
points[i].y = points[0].y + ((float)dy / float(num_points - 1) * (float)i);
}
Point2i *points_right = new Point2i[num_points];
Point2i *points_left = new Point2i[num_points];
double gap = 1.0;
for (int i = 0; i < num_points; i++)
{
points_right[i].x = cvRound(points[i].x + gap*cos(90.0 * CV_PI / 180.0 + ang));
points_right[i].y = cvRound(points[i].y + gap*sin(90.0 * CV_PI / 180.0 + ang));
points_left[i].x = cvRound(points[i].x - gap*cos(90.0 * CV_PI / 180.0 + ang));
points_left[i].y = cvRound(points[i].y - gap*sin(90.0 * CV_PI / 180.0 + ang));
pointInboardTestE(src, points_right[i]);
pointInboardTestE(src, points_left[i]);
}
int iR = 0, iL = 0;
for (int i = 0; i < num_points; i++)
{
iR += src.at<unsigned char>(points_right[i].y, points_right[i].x);
iL += src.at<unsigned char>(points_left[i].y, points_left[i].x);
}
if (iR > iL)
{
std::swap(seg.x1, seg.x2);
std::swap(seg.y1, seg.y2);
getAngleE(seg);
}
delete[] points;
delete[] points_right;
delete[] points_left;
return;
}
void drawSegmentE(Mat& mat, const SEGMENT& seg, Scalar bgr, int thickness, bool directed)
{
double gap = 10.0;
double ang = (double)seg.angle;
double arrow_angle = 30.0;
Point2i p1;
p1.x = cvRound(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang));
p1.y = cvRound(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang));
pointInboardTestE(mat, p1);
line(mat, Point(cvRound(seg.x1), cvRound(seg.y1)),
Point(cvRound(seg.x2), cvRound(seg.y2)), bgr, thickness, 1);
if (directed)
line(mat, Point(cvRound(seg.x2), cvRound(seg.y2)), p1, bgr, thickness, 1);
}
int eyemEDLinesDetector(EyemImage tpImage, int _gradThresh, int _anchorThresh, int _scanInterval, int _minPathLen, double _sigma, bool _sumFlag, double _line_error, int _min_line_len, double _max_distance_between_two_lines, double _max_error, EyemImage *tpDstImg)
{
cv::Mat src = cv::Mat(tpImage.iHeight, tpImage.iWidth, tpImage.iDepth, tpImage.vpImage);
if (src.empty()) {
return FUNC_IMAGE_NOT_EXIST;
}
std::vector<cv::Vec4f> lines;
detectE(src, lines);
return FUNC_OK;
}
\ No newline at end of file
#pragma once
//
// eyemSmooth¡¤±êÍ·
//
#ifndef __EYEM_EDLINES_H
#define __EYEM_EDLINES_H
#include "eyemLib.h"
#include <algorithm>
#include <map>
using namespace cv;
struct SEGMENT
{
float x1, y1, x2, y2, angle;
};
/**
* Detect lines in the input image.
*
* @param _image A grayscale(CV_8UC1) input image.
* If only a roi needs to be selected, use
* lsd_ptr->detect(image(roi), ..., lines);
* lines += Scalar(roi.x, roi.y, roi.x, roi.y);
* @param _lines Return: A vector of Vec4f elements specifying the beginning and ending point of
* a line. Where Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 is the end.
* Returned lines are directed so that the brighter side is placed on left.
*/
void detectE(cv::InputArray _image, cv::OutputArray _lines);
/**
* Draw lines on the given canvas.
*
* @param image The image, where lines will be drawn
* Should have the size of the image, where the lines were found
* @param lines The lines that need to be drawn
* @param draw_arrow If true, arrow heads will be drawn
*/
void drawSegmentsE(cv::InputOutputArray _image, cv::InputArray lines, bool draw_arrow = false);
int imagewidth, imageheight, threshold_length;
float threshold_dist;
double canny_th1, canny_th2;
int canny_aperture_size;
bool do_merge;
//template<class T>
//void incidentPoint(const Mat& l, T& pt);
void mergeLinesE(const SEGMENT& seg1, const SEGMENT& seg2, SEGMENT& seg_merged);
bool mergeSegmentsE(const SEGMENT& seg1, const SEGMENT& seg2, SEGMENT& seg_merged);
bool getPointChainE(const cv::Mat& img, cv::Point pt, cv::Point& chained_pt, float& direction, int step);
double distPointLineE(const cv::Mat& p, cv::Mat& l);
void extractSegmentsE(const std::vector<cv::Point2i>& points, std::vector<SEGMENT>& segments);
void lineDetectionE(const cv::Mat& src, std::vector<SEGMENT>& segments_all);
void pointInboardTestE(const cv::Mat& src, cv::Point2i& pt);
inline void getAngleE(SEGMENT& seg);
void additionalOperationsOnSegmentE(const cv::Mat& src, SEGMENT& seg);
void drawSegmentE(cv::Mat& mat, const SEGMENT& seg, cv::Scalar bgr = cv::Scalar(0, 255, 0),
int thickness = 1, bool directed = true);
#endif/* __EYEM_EDLINES_H */
\ No newline at end of file
......@@ -448,11 +448,11 @@ int eyemEdge1dFitCircle(IntPtr hObject, int iClippingEndPoints, int iMaxIteratio
return FUNC_OK;
}
//int eyemEdge1dGenArc(EyemImage tpImage, EyemOcsDXY tpLineSt, EyemOcsDXY tpLineEd, int iWhRoi, int iEdgeDirec, EyemOcsDXY *tpEdge)
//{
//
// return FUNC_OK;
//}
int eyemEdge1dGenArc(EyemImage tpImage, EyemOcsDXY tpLineSt, EyemOcsDXY tpLineEd, int iWhRoi, int iEdgeDirec, EyemOcsDXY *tpEdge)
{
return FUNC_OK;
}
bool eyemEdge1dGenMeasureFree(IntPtr hObject)
{
......
......@@ -75,7 +75,6 @@ int eyemImageRead(const char *filename, int iFlag, EyemImage *tpImage)
return FUNC_OK;
}
int eyemImageMalloc(int iWidth, int iHeight, int iChannels, const char *ccSubType, EyemImage *tpImage)
{
//图像信息
......@@ -148,7 +147,6 @@ int eyemImageMalloc(int iWidth, int iHeight, int iChannels, const char *ccSubTyp
return FUNC_OK;
}
int eyemImageReadRaw(const char *filename, int iWidth, int iHeight, int iDepth, EyemImage *tpImage)
{
if (std::strlen(filename) == 0)
......@@ -185,7 +183,6 @@ int eyemImageReadRaw(const char *filename, int iWidth, int iHeight, int iDepth,
return FUNC_OK;
}
int eyemCvtImageType(EyemImage tpImage, int rType, double alpha, double beta, EyemImage &tpDstImg)
{
CV_Assert(NULL != tpImage.vpImage);
......@@ -198,7 +195,6 @@ int eyemCvtImageType(EyemImage tpImage, int rType, double alpha, double beta, Ey
return FUNC_OK;
}
int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg)
{
CV_Assert(NULL != tpImage.vpImage);
......@@ -208,7 +204,7 @@ int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg)
cv::cvtColor(cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage), \
_dst, iCCodes);
//如果预先分配了内存,则判断基本信息是否符合
//如果预先分配了内存,则判断是否符合结果类型
if (NULL != tpDstImg.vpImage)
CV_Assert(_dst.cols == tpDstImg.iWidth && _dst.rows == tpDstImg.iHeight && _dst.depth() == tpDstImg.iDepth && _dst.channels() == tpDstImg.iChannels);
......@@ -282,16 +278,17 @@ int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg)
return FUNC_OK;
}
int eyemImageAdd(EyemImage tpImageA, EyemImage tpImageB, EyemImage &tpDstImg)
int eyemImageAdd(EyemImage tpImage1, EyemImage tpImage2, EyemImage &tpDstImg)
{
CV_Assert((NULL != tpImageA.vpImage) && (NULL != tpImageB.vpImage));
CV_Assert((NULL != tpImage1.vpImage) && (NULL != tpImage2.vpImage));
CV_Assert(tpImageA.iWidth == tpImageB.iWidth&&tpImageA.iHeight == tpImageB.iHeight&&tpImageA.iDepth == tpImageB.iDepth&&tpImageA.iChannels == tpImageB.iChannels);
//必须具有相同类型
CV_Assert(tpImage1.iWidth == tpImage2.iWidth&&tpImage1.iHeight == tpImage2.iHeight&&tpImage1.iDepth == tpImage2.iDepth&&tpImage1.iChannels == \
tpImage2.iChannels);
cv::Mat _dst;
cv::add(cv::Mat(tpImageA.iHeight, tpImageA.iWidth, MAKETYPE(tpImageA.iDepth, tpImageA.iChannels), tpImageA.vpImage), \
cv::Mat(tpImageB.iHeight, tpImageB.iWidth, MAKETYPE(tpImageB.iDepth, tpImageB.iChannels), tpImageB.vpImage), _dst);
cv::add(cv::Mat(tpImage1.iHeight, tpImage1.iWidth, MAKETYPE(tpImage1.iDepth, tpImage1.iChannels), tpImage1.vpImage), \
cv::Mat(tpImage2.iHeight, tpImage2.iWidth, MAKETYPE(tpImage2.iDepth, tpImage2.iChannels), tpImage2.vpImage), _dst);
//如果预先分配了内存,则判断基本信息是否符合
if (NULL != tpDstImg.vpImage)
......@@ -367,16 +364,17 @@ int eyemImageAdd(EyemImage tpImageA, EyemImage tpImageB, EyemImage &tpDstImg)
return FUNC_OK;
}
int eyemImageSub(EyemImage tpImageA, EyemImage tpImageB, EyemImage &tpDstImg)
int eyemImageSub(EyemImage tpImageMinuend, EyemImage tpImageSubtrahend, EyemImage &tpDstImg)
{
CV_Assert((NULL != tpImageA.vpImage) && (NULL != tpImageB.vpImage));
CV_Assert((NULL != tpImageMinuend.vpImage) && (NULL != tpImageSubtrahend.vpImage));
CV_Assert(tpImageA.iWidth == tpImageB.iWidth&&tpImageA.iHeight == tpImageB.iHeight&&tpImageA.iDepth == tpImageB.iDepth&&tpImageA.iChannels == tpImageB.iChannels);
//必须具有相同类型
CV_Assert(tpImageMinuend.iWidth == tpImageSubtrahend.iWidth&&tpImageMinuend.iHeight == tpImageSubtrahend.iHeight&&tpImageMinuend.iDepth == tpImageSubtrahend\
.iDepth&&tpImageMinuend.iChannels == tpImageSubtrahend.iChannels);
cv::Mat _dst;
cv::subtract(cv::Mat(tpImageA.iHeight, tpImageA.iWidth, MAKETYPE(tpImageA.iDepth, tpImageA.iChannels), tpImageA.vpImage), \
cv::Mat(tpImageB.iHeight, tpImageB.iWidth, MAKETYPE(tpImageB.iDepth, tpImageB.iChannels), tpImageB.vpImage), _dst);
cv::subtract(cv::Mat(tpImageMinuend.iHeight, tpImageMinuend.iWidth, MAKETYPE(tpImageMinuend.iDepth, tpImageMinuend.iChannels), tpImageMinuend.vpImage), \
cv::Mat(tpImageSubtrahend.iHeight, tpImageSubtrahend.iWidth, MAKETYPE(tpImageSubtrahend.iDepth, tpImageSubtrahend.iChannels), tpImageSubtrahend.vpImage), _dst);
//如果预先分配了内存,则判断基本信息是否符合
if (NULL != tpDstImg.vpImage)
......@@ -452,12 +450,17 @@ int eyemImageSub(EyemImage tpImageA, EyemImage tpImageB, EyemImage &tpDstImg)
return FUNC_OK;
}
int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg)
int eyemImageDiv(EyemImage tpImage1, EyemImage tpImage2, EyemImage &tpDstImg)
{
CV_Assert((NULL != tpImage.vpImage));
CV_Assert((NULL != tpImage1.vpImage) && (NULL != tpImage2.vpImage));
cv::Mat _dst = cv::abs(cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage));
//必须具有相同类型
CV_Assert(tpImage1.iWidth == tpImage2.iWidth&&tpImage1.iHeight == tpImage2.iHeight&&tpImage1.iDepth == tpImage2.iDepth&&tpImage1.iChannels == \
tpImage2.iChannels);
cv::Mat _dst;
cv::divide(cv::Mat(tpImage1.iHeight, tpImage1.iWidth, MAKETYPE(tpImage1.iDepth, tpImage1.iChannels), tpImage1.vpImage), \
cv::Mat(tpImage2.iHeight, tpImage2.iWidth, MAKETYPE(tpImage2.iDepth, tpImage2.iChannels), tpImage2.vpImage), _dst);
//如果预先分配了内存,则判断基本信息是否符合
if (NULL != tpDstImg.vpImage)
......@@ -533,31 +536,86 @@ int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg)
return FUNC_OK;
}
void eyemImageDisplay(const char *ccWinName, EyemImage tpImage)
int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg)
{
CV_Assert(NULL != tpImage.vpImage);
cv::Mat src = cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage);
CV_Assert((NULL != tpImage.vpImage));
cv::imshow(ccWinName, src);
cv::Mat _dst = cv::abs(cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage));
cv::waitKey(1);
}
//如果预先分配了内存,则判断基本信息是否符合
if (NULL != tpDstImg.vpImage)
CV_Assert(_dst.cols == tpDstImg.iWidth && _dst.rows == tpDstImg.iHeight && _dst.depth() == tpDstImg.iDepth && _dst.channels() == tpDstImg.iChannels);
//内存尺寸
int _Size = _dst.cols *_dst.rows *_dst.channels();
void eyemOpenWindow(const char *ccWinName)
{
cv::namedWindow(ccWinName, cv::WINDOW_AUTOSIZE);
}
//不存在则创建
if (NULL == tpDstImg.vpImage) {
//目标图像信息
tpDstImg.iWidth = _dst.cols, tpDstImg.iHeight = _dst.rows, tpDstImg.iDepth = _dst.depth(), tpDstImg.iChannels = _dst.channels();
switch (tpDstImg.iDepth)
{
case CV_8U:
_Size *= sizeof(uint8_t);
tpDstImg.vpImage = (uint8_t *)malloc(_Size);
if (NULL == tpDstImg.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpDstImg.vpImage, 0, _Size);
break;
case CV_8S:
_Size *= sizeof(int8_t);
tpDstImg.vpImage = (int8_t *)malloc(_Size);
if (NULL == tpDstImg.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpDstImg.vpImage, 0, _Size);
break;
case CV_16U:
_Size *= sizeof(uint16_t);
tpDstImg.vpImage = (uint16_t *)malloc(_Size);
if (NULL == tpDstImg.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpDstImg.vpImage, 0, _Size);
break;
case CV_16S:
_Size *= sizeof(int16_t);
tpDstImg.vpImage = (int16_t *)malloc(_Size);
if (NULL == tpDstImg.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpDstImg.vpImage, 0, _Size);
break;
case CV_32S:
_Size *= sizeof(int32_t);
tpDstImg.vpImage = (int32_t *)malloc(_Size);
if (NULL == tpDstImg.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpDstImg.vpImage, 0, _Size);
break;
case CV_32F:
_Size *= sizeof(float_t);
tpDstImg.vpImage = (float_t *)malloc(_Size);
if (NULL == tpDstImg.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpDstImg.vpImage, 0, _Size);
break;
case CV_64F:
_Size *= sizeof(double_t);
tpDstImg.vpImage = (double_t *)malloc(_Size);
if (NULL == tpDstImg.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpDstImg.vpImage, 0, _Size);
break;
default:
//no support format
return FUNC_CANNOT_USE;
}
}
//拷贝数据
memcpy(tpDstImg.vpImage, _dst.data, _Size);
void eyemCloseWindow(const char *ccWinName)
{
cv::destroyWindow(ccWinName);
return FUNC_OK;
}
void eyemImageFree(void *vpImage)
{
//must be free 空指针也没关系
......
......@@ -8,5 +8,4 @@
#include "eyemLib.h"
#endif/* __EYEM_GENERIC_H */
\ No newline at end of file
......@@ -7,7 +7,6 @@
#include <Windows.h>
#include <opencv.hpp>
#include <opencv2\opencv.hpp>
#ifndef EXPORTS
......@@ -786,12 +785,10 @@ extern "C" {
EXPORTS int eyemImageMalloc(int iWidth, int iHeight, int iChannels, const char *ccSubType, EyemImage *tpImage);
EXPORTS int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg);
EXPORTS int eyemCvtImageType(EyemImage tpImage, int rType, double alpha, double beta, EyemImage &tpDstImg);
EXPORTS int eyemImageAdd(EyemImage tpImageA, EyemImage tpImageB, EyemImage &tpImage);
EXPORTS int eyemImageSub(EyemImage tpImageA, EyemImage tpImageB, EyemImage &tpImage);
EXPORTS int eyemImageAbs(EyemImage tpImageA, EyemImage tpImageB, EyemImage &tpImage);
EXPORTS void eyemImageDisplay(const char *ccWinName, EyemImage tpImage);
EXPORTS void eyemOpenWindow(const char *ccWinName);
EXPORTS void eyemCloseWindow(const char *ccWinName);
EXPORTS int eyemImageAdd(EyemImage tpImage1, EyemImage tpImage2, EyemImage &tpDstImg);
EXPORTS int eyemImageSub(EyemImage tpImageMinuend, EyemImage tpImageSubtrahend, EyemImage &tpDstImg);
EXPORTS int eyemImageDiv(EyemImage tpImage1, EyemImage tpImage2, EyemImage &tpDstImg);
EXPORTS int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg);
EXPORTS void eyemImageFree(void *ipImage);
#ifdef __cplusplus
......
......@@ -166,7 +166,6 @@
<ClInclude Include="eyemClp2d.h" />
<ClInclude Include="eyemEdge.h" />
<ClInclude Include="eyemEdge1d.h" />
<ClInclude Include="eyemEDLinesDetector.h" />
<ClInclude Include="eyemFit.h" />
<ClInclude Include="eyemGeneric.h" />
<ClInclude Include="eyemLib.h" />
......@@ -185,7 +184,6 @@
<ClCompile Include="eyemClp3d.cpp" />
<ClCompile Include="eyemEdge.cpp" />
<ClCompile Include="eyemEdge1d.cpp" />
<ClCompile Include="eyemEDLinesDetector.cpp" />
<ClCompile Include="eyemFit.cpp" />
<ClCompile Include="eyemGeneric.cpp" />
<ClCompile Include="eyemLib.cpp" />
......
......@@ -57,9 +57,6 @@
<ClInclude Include="eyemBarCode.h">
<Filter>源文件</Filter>
</ClInclude>
<ClInclude Include="eyemEDLinesDetector.h">
<Filter>源文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="eyemLib.cpp">
......@@ -113,9 +110,6 @@
<ClCompile Include="eyemBarCode.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="eyemEDLinesDetector.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="eyemLib.rc">
......
#include "eyemMath.h"
double eyemMathCalcInnerProduct(int, double[], double[]);
void eyemMathCalcOuterProduct(double[], double[], double[]);
int eyemMathCalcAngle(int, double[], double[], double *);
double eyemMathCalcNorm(int, double[]);
double eyemMathCalcArgument(double[]);
int eyemMathNormalization(int, double[]);
int eyemMathStat(int, double[], double *, double *, double *);
double eyemMathMedianI(int, int *);
double eyemMathMedianD(int, double *);
int eyemMathOtsuThreshold1d(int, double[], double *);
double eyemMathAreaTriangle(double, double, double, double, double, double);
double eyemMathSignAreaTriangle(double, double, double, double, double, double);
void eyemMathRotatePoint(double, double, double, double, double, double *, double *);
void eyemMathCreateTransParam(int, double, double, double, double, double *, double *, double *);
void eyemMathTransCoordOfPoint(double, double, double, double, double, double *, double *);
void eyemMathInvTransCoordOfPoint(double, double, double, double, double, double *, double *);
void eyemMathComposeCoord(double, double, double, double, double, double, double *, double *, double *);
double eyemMathInvMatrixOfSyn3X3(double[][3], double[][3]);
void eyemMathInvCoord(double, double, double, double *, double *, double *);
double eyemMathGetDistFromPointToPoint(double, double, double, double);
double eyemMathGetDistFromPointToLine(double, double, double, double, double);
double eyemMathGetDistAndCrossPointFromPointToLine(double, double, double, double, double, double *, double *);
double eyemMathGetDistFromPointToCircle(double, double, double, double, double, double *, double *);
int eyemMathGetDistFromPointToEllipse(double, double, double, double, double, double, double, double *, double *, double *);
int eyemMathCrossPoint(double, double, double, double, double, double, double *, double *);
void eyemMathTransAbcToRq(double, double, double, double *, double *);
double eyemMathCrossAngle(double, double, double, double, double, double);
int eyemMathGetLineFrom2Points(double, double, double, double, double *, double *, double *);
void eyemMathGetOrthogonalLineFromLineAndPoint(double, double, double, double, double *, double *, double *);
int eyemMathCheckAngle(double, double, double);
double eyemMathAddAngle(int, int, double, double);
double eyemMathPrimeAngle(int, int, double);
double eyemMathExtremumOfQuadraticCurves(double, double, double, double *);
double eyemMathExtremumOfQuadraticSurface(double, double, double, double, double, double, double *, double *);
double eyemMathCrossCorrelation(int, double[], double[]);
int eyemMathAutoCorrelation(int, double[], int, double[]);
double eyemMathNormCorrelation(int, double[], double[]);
int eyemMathNormAutoCorrelation(int, double[], int, double[]);
int eyemMathSearchOf1DWithNormCorrelation(int, double[], int, double[], int *, double *);
int eyemMathQuadraticRoots(double[], double[]);
int eyemMathCubicRoots(double[], double[]);
int eyemMathQuarticRoots(double[], double[]);
double eyemMathHorner(int, double[], double);
void eyemMathTransCoord(double, double, double, double, double, double *, double *);
\ No newline at end of file
1>------ 已启动生成: 项目: eyemLib, 配置: Debug x64 ------
1> eyemSmooth.cpp
1> eyemMath.cpp
1> eyemMat.cpp
1> eyemGeneric.cpp
1> eyemFit.cpp
1> eyemEdge1d.cpp
1> eyemEdge.cpp
1> eyemClp2d.cpp
1> eyemBin.cpp
1> eyemBarCode.cpp
1> 正在生成代码...
1> 正在跳过...(未检测到相关更改)
1> eyemMisc.cpp
1> eyemLib.cpp
1> eyemCalib.cpp
1> 正在创建库 C:\Users\张士柳\OneDrive\程序\VSProject\eyemLib\x64\Debug\eyemLib.lib 和对象 C:\Users\张士柳\OneDrive\程序\VSProject\eyemLib\x64\Debug\eyemLib.exp
1> eyemLib.vcxproj -> C:\Users\张士柳\OneDrive\程序\VSProject\eyemLib\x64\Debug\eyemLib.dll
1> eyemLib.vcxproj -> C:\Users\张士柳\OneDrive\程序\VSProject\eyemLib\x64\Debug\eyemLib.pdb (Full PDB)
2>------ 已启动生成: 项目: eyemLib-Sharp, 配置: Debug Any CPU ------
2>C:\Users\张士柳\OneDrive\程序\VSProject\eyemLib\eyemLib-Sharp\EyemLib.cs(719,23,719,29): warning CS0219: The variable 'image2' is assigned but its value is never used
2>C:\Users\张士柳\OneDrive\程序\VSProject\eyemLib\eyemLib-Sharp\EyemLib.cs(894,20,894,27): warning CS0219: The variable 'pNumObj' is assigned but its value is never used
2> eyemLib-Sharp -> C:\Users\张士柳\OneDrive\程序\VSProject\eyemLib\x64\Debug\eyemLib-Sharp.exe
========== 生成: 成功 2 个,失败 0 个,最新 0 个,跳过 0 个 ==========
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!