Commit 8aec1e0d 张士柳

1 个父辈 54bd2585
...@@ -594,9 +594,12 @@ namespace eyemLib_Sharp ...@@ -594,9 +594,12 @@ namespace eyemLib_Sharp
//创建图像(uint8_t、int8_t、uint16_t、int16_t、int32_t、float_t、double_t) //创建图像(uint8_t、int8_t、uint16_t、int16_t、int32_t、float_t、double_t)
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)] [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemImageMalloc(int iWidth, int iHeight, int iChannels, string ccSubType, out EyemImage tpImage); private static extern int eyemImageMalloc(int iWidth, int iHeight, int iChannels, string ccSubType, out EyemImage tpImage);
//拷贝图像(必须预分配空间)
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemImageCopy(EyemImage tpImage, ref EyemImage tpDstImg);
//图像颜色空间转换 //图像颜色空间转换
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)] [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemCvtImageColor(EyemImage tpImage, int iCCodes, ref EyemImage tpDstImg); private static extern int eyemCvtImageColor(EyemImage tpImage, ColorConversionCodes iCCodes, ref EyemImage tpDstImg);
//图像数据格式转换(uint8_t、int8_t、uint16_t、int16_t、int32_t、float_t、double_t) //图像数据格式转换(uint8_t、int8_t、uint16_t、int16_t、int32_t、float_t、double_t)
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)] [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemCvtImageType(EyemImage tpImage, string ccSubType, double alpha, double beta, ref EyemImage tpDstImg); private static extern int eyemCvtImageType(EyemImage tpImage, string ccSubType, double alpha, double beta, ref EyemImage tpDstImg);
...@@ -614,7 +617,7 @@ namespace eyemLib_Sharp ...@@ -614,7 +617,7 @@ namespace eyemLib_Sharp
private static extern int eyemImageAbs(EyemImage tpImage, ref EyemImage tpDstImg); private static extern int eyemImageAbs(EyemImage tpImage, ref EyemImage tpDstImg);
//释放图像资源 //释放图像资源
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)] [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern void eyemImageFree(IntPtr ipImage); private static extern void eyemImageFree(ref EyemImage tpImage);
#endregion #endregion
...@@ -732,8 +735,6 @@ namespace eyemLib_Sharp ...@@ -732,8 +735,6 @@ namespace eyemLib_Sharp
//flag = eyemImageAbs(image1, ref tpDstImg); //flag = eyemImageAbs(image1, ref tpDstImg);
#region Test Blob #region Test Blob
//int ipNum; //int ipNum;
//BlobHandle hObject; //BlobHandle hObject;
...@@ -897,84 +898,113 @@ namespace eyemLib_Sharp ...@@ -897,84 +898,113 @@ namespace eyemLib_Sharp
//sw.Stop(); //sw.Stop();
//Console.WriteLine("耗时:" + sw.ElapsedMilliseconds.ToString() + ",结果:" + pNumObj); //Console.WriteLine("耗时:" + sw.ElapsedMilliseconds.ToString() + ",结果:" + pNumObj);
//free image //free image
eyemImageFree(tpDstImg.vpImage); eyemImageFree(ref tpDstImg);
eyemImageFree(image.vpImage); eyemImageFree(ref image);
} }
public static void eyemTest(string[] fileNames) public static void eyemTest(string[] fileNames)
{ {
int iRet = 0;
EyemImage imageFormer = new EyemImage(); EyemImage imageFormer = new EyemImage();
EyemImage imageNext = new EyemImage();
EyemImage imageDiff = new EyemImage(); EyemImage imageDiff = new EyemImage();
//首次需要为图像申请内存,EyemImage之间直接用=赋值是不行的
int flag = eyemImageMalloc(1080, 1440, 3, "uint8_t", out imageNext);
flag = eyemImageMalloc(1080, 1440, 3, "uint8_t", out imageFormer); //首次需要为图像申请内存,EyemImage之间直接用=赋值是不行的
iRet = eyemImageMalloc(1080, 1440, 4, "int8_t", out imageFormer);
flag = eyemImageMalloc(1080, 1440, 3, "uint8_t", out imageDiff); iRet = eyemImageMalloc(1080, 1440, 1, "uint8_t", out imageDiff);
int nFrmNum = 0; int nFrmNum = 0;
for (int i = 0; i < fileNames.Length; i++) for (int i = 1; i < fileNames.Length; i++)
{ {
flag = eyemImageRead(fileNames[i], -1, out imageNext); EyemImage imageNext = new EyemImage();
if (flag != 0) iRet = eyemImageRead(fileNames[i], -1, out imageNext);
if (iRet != 0)
{ {
Console.WriteLine("读图失败!"); Console.WriteLine("读图失败!");
return; return;
} }
//转灰度图像
eyemCvtImageColor(imageNext, ColorConversionCodes.COLOR_BGR2GRAY, ref imageNext);
nFrmNum++; nFrmNum++;
if (nFrmNum > 1) if (nFrmNum > 0)
{ {
flag = eyemImageSub(imageNext, imageFormer, ref imageDiff); iRet = eyemImageSub(imageNext, imageFormer, ref imageDiff);
iRet = eyemImageAbs(imageDiff, ref imageDiff);
} }
//前一帧,(直接赋值是不对的) //前一帧,(直接赋值是不可以的,要先对其释放,拷贝时必须具有相同类型)
imageFormer = imageNext; eyemImageCopy(imageNext, ref imageFormer);
}
eyemImageDispose(imageFormer);
eyemImageDispose(imageNext);
eyemImageDispose(imageDiff);
}
public static void eyemImageDispose(EyemImage tpImage) //释放资源
{ eyemImageFree(ref imageNext);
eyemImageFree(tpImage.vpImage);
System.Threading.Thread.Sleep(350);
}
//释放资源
eyemImageFree(ref imageFormer);
eyemImageFree(ref imageDiff);
} }
public static Bitmap eyemCvtToBitmap(EyemImage tpImage) public static Bitmap eyemCvtToBitmap(EyemImage tpImage)
{ {
PixelFormat pixelFormat; //统一将图像转换成8位显示
PixelFormat format;
switch (tpImage.iChannels) switch (tpImage.iChannels)
{ {
case 1: case 1:
pixelFormat = PixelFormat.Format16bppGrayScale; format = PixelFormat.Format8bppIndexed;
break; break;
case 3: case 3:
pixelFormat = PixelFormat.Format24bppRgb; format = PixelFormat.Format24bppRgb;
break; break;
case 4: case 4:
pixelFormat = PixelFormat.Format32bppRgb; format = PixelFormat.Format32bppArgb;
break; break;
default: default:
//不支持通道数
return null; return null;
} }
int pixelPerByte = 1; //如果图不是8位的就转成8位显示
if (tpImage.iDepth != 0)
eyemCvtImageType(tpImage, "uint8_t", 1.0, 0.0, ref tpImage);
Bitmap bitmap = new Bitmap(tpImage.iWidth, tpImage.iHeight, tpImage.iWidth * tpImage.iChannels, format, tpImage.vpImage);
Bitmap bitmap = new Bitmap(tpImage.iWidth, tpImage.iHeight, tpImage.iWidth * tpImage.iChannels * pixelPerByte, pixelFormat, tpImage.vpImage); BitmapData data = bitmap.LockBits(
if (pixelFormat == PixelFormat.Format8bppIndexed) new Rectangle(Point.Empty, new Size(tpImage.iWidth, tpImage.iHeight)),
ImageLockMode.WriteOnly,
format);
if (format == PixelFormat.Format8bppIndexed)
{ {
ColorPalette colorPalette = bitmap.Palette; ColorPalette palette = bitmap.Palette;
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
colorPalette.Entries[i] = Color.FromArgb(i, i, i); palette.Entries[i] = Color.FromArgb(i, i, i);
} }
bitmap.Palette = colorPalette; bitmap.Palette = palette;
} }
bitmap.Save("uint16_t_c1.bmp");
return bitmap; return bitmap;
} }
public static void eyemOpenWindow(EyemImage tpImage)
{
}
public static void eyemDestoryWindow(EyemImage tpImage)
{
}
public static void eyemImageDisplay(EyemImage tpImage)
{
}
#region 结构转内存指针 #region 结构转内存指针
public static IntPtr teStructArray2IntPtr(EyemOcsDXY[] tpPoints, int iLength) public static IntPtr teStructArray2IntPtr(EyemOcsDXY[] tpPoints, int iLength)
{ {
......
using System; using System;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -21,15 +22,12 @@ namespace eyemLib_Sharp ...@@ -21,15 +22,12 @@ namespace eyemLib_Sharp
// Console.Write("请按任意键继续。。。"); // Console.Write("请按任意键继续。。。");
//} //}
//foreach (var fileName in fileNames) for (int i = 0; i < 5000; i++)
//{ {
// EyemLib.eyemReadImageTool(fileName); EyemLib.eyemTest(fileNames);
// Thread.Sleep(1); //EyemLib.eyemReadImageTool(fileName);
// break; Thread.Sleep(2);
//} }
EyemLib.eyemTest(fileNames);
Console.Write("请按任意键继续。。。"); Console.Write("请按任意键继续。。。");
Console.ReadKey(); Console.ReadKey();
} }
......
...@@ -101,7 +101,7 @@ int eyemImageMalloc(int iWidth, int iHeight, int iChannels, const char *ccSubTyp ...@@ -101,7 +101,7 @@ int eyemImageMalloc(int iWidth, int iHeight, int iChannels, const char *ccSubTyp
tpImage->vpImage = (int8_t *)malloc(_Size); tpImage->vpImage = (int8_t *)malloc(_Size);
if (NULL == tpImage->vpImage) if (NULL == tpImage->vpImage)
return FUNC_NOT_ENOUGH_MEM; return FUNC_NOT_ENOUGH_MEM;
memset(tpImage->vpImage, 0, _Size); memset(tpImage->vpImage, 128, _Size);
} }
else if (strcmp(ccSubType, "uint16_t") == 0) { else if (strcmp(ccSubType, "uint16_t") == 0) {
tpImage->iDepth = 2; tpImage->iDepth = 2;
...@@ -150,6 +150,51 @@ int eyemImageMalloc(int iWidth, int iHeight, int iChannels, const char *ccSubTyp ...@@ -150,6 +150,51 @@ int eyemImageMalloc(int iWidth, int iHeight, int iChannels, const char *ccSubTyp
return FUNC_OK; return FUNC_OK;
} }
int eyemImageCopy(EyemImage tpImage, EyemImage &tpDstImg)
{
CV_Assert(NULL != tpImage.vpImage); CV_Assert(NULL != tpDstImg.vpImage);
//必须具有相同类型
CV_Assert(tpImage.iWidth == tpDstImg.iWidth&&tpImage.iHeight == tpDstImg.iHeight&&tpImage.iDepth == tpDstImg.iDepth&&tpImage.iChannels == \
tpDstImg.iChannels);
//内存尺寸
int _Size = tpImage.iWidth *tpImage.iHeight *tpImage.iChannels;
switch (tpImage.iDepth)
{
case CV_8U:
_Size *= sizeof(uint8_t);
break;
case CV_8S:
_Size *= sizeof(int8_t);
break;
case CV_16U:
_Size *= sizeof(uint16_t);
break;
case CV_16S:
_Size *= sizeof(int16_t);
break;
case CV_32S:
_Size *= sizeof(int32_t);
break;
case CV_32F:
_Size *= sizeof(float_t);
break;
case CV_64F:
_Size *= sizeof(double_t);
break;
default:
//no support format
return FUNC_CANNOT_USE;
}
//拷贝数据
memcpy(tpDstImg.vpImage, tpImage.vpImage, _Size);
return FUNC_OK;
}
int eyemImageReadRaw(const char *filename, int iWidth, int iHeight, int iDepth, EyemImage *tpImage) int eyemImageReadRaw(const char *filename, int iWidth, int iHeight, int iDepth, EyemImage *tpImage)
{ {
if (std::strlen(filename) == 0) if (std::strlen(filename) == 0)
...@@ -190,11 +235,11 @@ int eyemCvtImageType(EyemImage tpImage, const char *ccSubType, double alpha, dou ...@@ -190,11 +235,11 @@ int eyemCvtImageType(EyemImage tpImage, const char *ccSubType, double alpha, dou
{ {
CV_Assert(NULL != tpImage.vpImage); CV_Assert(NULL != tpImage.vpImage);
cv::Mat _src(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage); cv::Mat _src = cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage).clone();
//如果预先分配了内存,则先释放 //如果预先分配了内存,则判断图像信息类型是否符合
if (NULL != tpDstImg.vpImage) if (NULL != tpDstImg.vpImage)
tpDstImg.iWidth = 0; tpDstImg.iHeight = 0; tpDstImg.iDepth = 0; tpDstImg.iChannels = 0; free(tpDstImg.vpImage), tpDstImg.vpImage = NULL; CV_Assert(tpDstImg.iWidth == tpImage.iWidth&&tpDstImg.iHeight == tpImage.iHeight&&tpDstImg.iChannels == tpImage.iChannels);
//内存尺寸(图像数据类型转换不涉及通道、尺寸) //内存尺寸(图像数据类型转换不涉及通道、尺寸)
int _Size = tpImage.iWidth*tpImage.iHeight*tpImage.iChannels; int _Size = tpImage.iWidth*tpImage.iHeight*tpImage.iChannels;
...@@ -202,9 +247,15 @@ int eyemCvtImageType(EyemImage tpImage, const char *ccSubType, double alpha, dou ...@@ -202,9 +247,15 @@ int eyemCvtImageType(EyemImage tpImage, const char *ccSubType, double alpha, dou
//图像信息 //图像信息
tpDstImg.iWidth = tpImage.iWidth; tpDstImg.iHeight = tpImage.iHeight; tpDstImg.iChannels = tpImage.iChannels; tpDstImg.iWidth = tpImage.iWidth; tpDstImg.iHeight = tpImage.iHeight; tpDstImg.iChannels = tpImage.iChannels;
//支持就地操作
if (tpImage.vpImage == tpDstImg.vpImage) {
//释放内存,保留基本参数
free(tpDstImg.vpImage), tpDstImg.vpImage = NULL;
}
cv::Mat _dst; cv::Mat _dst;
//分配所需内存 //分配所需内存
if (strcmp(ccSubType, "uint8_t") == 0) { if (strcmp(ccSubType, "uint8_t") == 0) {
tpDstImg.iDepth = 0; tpDstImg.iDepth = 0;
_Size *= sizeof(uint8_t); _Size *= sizeof(uint8_t);
tpDstImg.vpImage = (uint8_t *)malloc(_Size); tpDstImg.vpImage = (uint8_t *)malloc(_Size);
...@@ -263,7 +314,7 @@ int eyemCvtImageType(EyemImage tpImage, const char *ccSubType, double alpha, dou ...@@ -263,7 +314,7 @@ int eyemCvtImageType(EyemImage tpImage, const char *ccSubType, double alpha, dou
else {//no support format else {//no support format
return FUNC_CANNOT_USE; return FUNC_CANNOT_USE;
} }
//类型转换
_src.convertTo(_dst, tpDstImg.iDepth, alpha, beta); _src.convertTo(_dst, tpDstImg.iDepth, alpha, beta);
//拷贝数据 //拷贝数据
...@@ -276,18 +327,25 @@ int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg) ...@@ -276,18 +327,25 @@ int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg)
{ {
CV_Assert(NULL != tpImage.vpImage); CV_Assert(NULL != tpImage.vpImage);
cv::Mat _src = cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage).clone();
//颜色空间转换 //颜色空间转换
cv::Mat _dst; cv::Mat _dst;
cv::cvtColor(cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage), \ cv::cvtColor(_src, _dst, iCCodes);
_dst, iCCodes);
//如果预先分配了内存,则判断是否符合结果类型 //如果预先分配了内存,则判断是否符合结果类型,如果是就地操作就不需要判断
if (NULL != tpDstImg.vpImage) if (NULL != tpDstImg.vpImage&&tpImage.vpImage != tpDstImg.vpImage)
CV_Assert(_dst.cols == tpDstImg.iWidth && _dst.rows == tpDstImg.iHeight && _dst.depth() == tpDstImg.iDepth && _dst.channels() == tpDstImg.iChannels); CV_Assert(_dst.cols == tpDstImg.iWidth && _dst.rows == tpDstImg.iHeight && _dst.depth() == tpDstImg.iDepth && _dst.channels() == tpDstImg.iChannels);
//内存尺寸 //内存尺寸
int _Size = tpImage.iWidth *tpImage.iHeight *_dst.channels(); int _Size = tpImage.iWidth *tpImage.iHeight *_dst.channels();
//支持就地操作
if (tpImage.vpImage == tpDstImg.vpImage) {
//释放内存,保留基本参数
free(tpDstImg.vpImage), tpDstImg.vpImage = NULL;
}
//不存在则创建 //不存在则创建
if (NULL == tpDstImg.vpImage) { if (NULL == tpDstImg.vpImage) {
//目标图像信息 //目标图像信息
...@@ -352,6 +410,8 @@ int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg) ...@@ -352,6 +410,8 @@ int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg)
//拷贝数据 //拷贝数据
memcpy(tpDstImg.vpImage, _dst.data, _Size); memcpy(tpDstImg.vpImage, _dst.data, _Size);
cv::Mat diff(tpDstImg.iHeight, tpDstImg.iWidth, MAKETYPE(tpDstImg.iDepth, tpDstImg.iChannels), tpDstImg.vpImage);
return FUNC_OK; return FUNC_OK;
} }
...@@ -446,12 +506,16 @@ int eyemImageSub(EyemImage tpImageMinuend, EyemImage tpImageSubtrahend, EyemImag ...@@ -446,12 +506,16 @@ int eyemImageSub(EyemImage tpImageMinuend, EyemImage tpImageSubtrahend, EyemImag
CV_Assert((NULL != tpImageMinuend.vpImage) && (NULL != tpImageSubtrahend.vpImage)); CV_Assert((NULL != tpImageMinuend.vpImage) && (NULL != tpImageSubtrahend.vpImage));
//必须具有相同类型 //必须具有相同类型
CV_Assert(tpImageMinuend.iWidth == tpImageSubtrahend.iWidth&&tpImageMinuend.iHeight == tpImageSubtrahend.iHeight&&tpImageMinuend.iDepth == tpImageSubtrahend\ CV_Assert(tpImageMinuend.iWidth == tpImageSubtrahend.iWidth&&tpImageMinuend.iHeight == tpImageSubtrahend.iHeight&&
.iDepth&&tpImageMinuend.iChannels == tpImageSubtrahend.iChannels); tpImageMinuend.iDepth == tpImageSubtrahend.iDepth&&tpImageMinuend.iChannels == tpImageSubtrahend.iChannels);
cv::Mat _srcMinuend(tpImageMinuend.iHeight, tpImageMinuend.iWidth, MAKETYPE(tpImageMinuend.iDepth, tpImageMinuend.iChannels), tpImageMinuend.vpImage);
cv::Mat _srcSubtrahend(tpImageSubtrahend.iHeight, tpImageSubtrahend.iWidth, MAKETYPE(tpImageSubtrahend.iDepth, tpImageSubtrahend.iChannels),
tpImageSubtrahend.vpImage);
cv::Mat _dst; cv::Mat _dst;
cv::subtract(cv::Mat(tpImageMinuend.iHeight, tpImageMinuend.iWidth, MAKETYPE(tpImageMinuend.iDepth, tpImageMinuend.iChannels), tpImageMinuend.vpImage), \ cv::subtract(_srcMinuend, _srcSubtrahend, _dst);
cv::Mat(tpImageSubtrahend.iHeight, tpImageSubtrahend.iWidth, MAKETYPE(tpImageSubtrahend.iDepth, tpImageSubtrahend.iChannels), tpImageSubtrahend.vpImage), _dst);
//如果预先分配了内存,则判断基本信息是否符合 //如果预先分配了内存,则判断基本信息是否符合
if (NULL != tpDstImg.vpImage) if (NULL != tpDstImg.vpImage)
...@@ -524,8 +588,6 @@ int eyemImageSub(EyemImage tpImageMinuend, EyemImage tpImageSubtrahend, EyemImag ...@@ -524,8 +588,6 @@ int eyemImageSub(EyemImage tpImageMinuend, EyemImage tpImageSubtrahend, EyemImag
//拷贝数据 //拷贝数据
memcpy(tpDstImg.vpImage, _dst.data, _Size); memcpy(tpDstImg.vpImage, _dst.data, _Size);
cv::Mat diff(tpDstImg.iHeight, tpDstImg.iWidth, MAKETYPE(tpDstImg.iDepth, tpDstImg.iChannels), tpDstImg.vpImage);
return FUNC_OK; return FUNC_OK;
} }
...@@ -621,19 +683,25 @@ int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg) ...@@ -621,19 +683,25 @@ int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg)
cv::Mat _dst = cv::abs(cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage)); cv::Mat _dst = cv::abs(cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage));
//如果预先分配了内存,则判断基本信息是否符合 //如果预先分配了内存,并且非就地操作,则判断基本信息是否符合
if (NULL != tpDstImg.vpImage) if (NULL != tpDstImg.vpImage&&tpImage.vpImage != tpDstImg.vpImage)
CV_Assert(_dst.cols == tpDstImg.iWidth && _dst.rows == tpDstImg.iHeight && _dst.depth() == tpDstImg.iDepth && _dst.channels() == tpDstImg.iChannels); 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(); int _Size = _dst.cols *_dst.rows *_dst.channels();
//支持就地操作
if (tpImage.vpImage == tpDstImg.vpImage) {
//释放内存,保留基本参数
free(tpDstImg.vpImage), tpDstImg.vpImage = NULL;
}
//不存在则创建 //不存在则创建
if (NULL == tpDstImg.vpImage) { if (NULL == tpDstImg.vpImage) {
//目标图像信息 //目标图像信息
tpDstImg.iWidth = _dst.cols, tpDstImg.iHeight = _dst.rows, tpDstImg.iDepth = _dst.depth(), tpDstImg.iChannels = _dst.channels(); tpDstImg.iWidth = _dst.cols, tpDstImg.iHeight = _dst.rows, tpDstImg.iDepth = _dst.depth(), tpDstImg.iChannels = _dst.channels();
switch (tpDstImg.iDepth) switch (_dst.depth())
{ {
case CV_8U: case CV_8U:
_Size *= sizeof(uint8_t); _Size *= sizeof(uint8_t);
...@@ -695,9 +763,9 @@ int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg) ...@@ -695,9 +763,9 @@ int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg)
return FUNC_OK; return FUNC_OK;
} }
void eyemImageFree(void *vpImage) void eyemImageFree(EyemImage &tpImage)
{ {
//must be free 空指针也没关系 tpImage.iWidth = tpImage.iHeight = tpImage.iDepth = tpImage.iChannels = 0;
free(vpImage); free(tpImage.vpImage);
vpImage = NULL; tpImage.vpImage = NULL;
} }
\ No newline at end of file \ No newline at end of file
...@@ -765,7 +765,7 @@ extern "C" { ...@@ -765,7 +765,7 @@ extern "C" {
#endif #endif
// 函数接口 // 函数接口
EXPORTS 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); //EXPORTS 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);
#ifdef __cplusplus #ifdef __cplusplus
} }
...@@ -783,14 +783,14 @@ extern "C" { ...@@ -783,14 +783,14 @@ extern "C" {
EXPORTS int eyemImageRead(const char *filename, int iFalgs, EyemImage *ucpImage); EXPORTS int eyemImageRead(const char *filename, int iFalgs, EyemImage *ucpImage);
EXPORTS int eyemImageReadRaw(const char *filename, int iWidth, int iHeight, int iDepth, EyemImage *tpImage); EXPORTS int eyemImageReadRaw(const char *filename, int iWidth, int iHeight, int iDepth, EyemImage *tpImage);
EXPORTS int eyemImageMalloc(int iWidth, int iHeight, int iChannels, const char *ccSubType, EyemImage *tpImage); EXPORTS int eyemImageMalloc(int iWidth, int iHeight, int iChannels, const char *ccSubType, EyemImage *tpImage);
EXPORTS int eyemImageCopy(EyemImage &tpSrcImg, EyemImage &tpDstImg); EXPORTS int eyemImageCopy(EyemImage tpSrcImg, EyemImage &tpDstImg);
EXPORTS int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg); EXPORTS int eyemCvtImageColor(EyemImage tpImage, int iCCodes, EyemImage &tpDstImg);
EXPORTS int eyemCvtImageType(EyemImage tpImage, const char *ccSubType, double alpha, double beta, EyemImage &tpDstImg); EXPORTS int eyemCvtImageType(EyemImage tpImage, const char *ccSubType, double alpha, double beta, EyemImage &tpDstImg);
EXPORTS int eyemImageAdd(EyemImage tpImage1, EyemImage tpImage2, EyemImage &tpDstImg); EXPORTS int eyemImageAdd(EyemImage tpImage1, EyemImage tpImage2, EyemImage &tpDstImg);
EXPORTS int eyemImageSub(EyemImage tpImageMinuend, EyemImage tpImageSubtrahend, EyemImage &tpDstImg); EXPORTS int eyemImageSub(EyemImage tpImageMinuend, EyemImage tpImageSubtrahend, EyemImage &tpDstImg);
EXPORTS int eyemImageDiv(EyemImage tpImage1, EyemImage tpImage2, EyemImage &tpDstImg); EXPORTS int eyemImageDiv(EyemImage tpImage1, EyemImage tpImage2, EyemImage &tpDstImg);
EXPORTS int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg); EXPORTS int eyemImageAbs(EyemImage tpImage, EyemImage &tpDstImg);
EXPORTS void eyemImageFree(void *ipImage); EXPORTS void eyemImageFree(EyemImage &ipImage);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!