gpt4 book ai didi

c - 使用 NI VISION imaqDetectLines() 函数时出现一般保护错误

转载 作者:行者123 更新时间:2023-11-30 15:04:49 25 4
gpt4 key购买 nike

我在 Labwindows\CVI 中使用 National Instruments Vision 模块

出于某种原因,当我使用 func imaqDetectLines() 时,我得到FATAL RUN-TIME ERROR: "Angle tracker.c", line 50, col 11, thread id 0x00002004: The program has caused a 'General Protection' fault at 0x6C5AD446.

这是我的代码:

#include "nivision.h"
#include <userint.h>
#include <cvirte.h>

int main (int argc, char *argv[])
{
int nLines;
ShapeDetectionOptions stShapeDetectionOption;
RangeFloat aAngleRanges[2]={{0,10.0},{10.0,20.0}};
CurveOptions stCurveOptions = {0};
LineMatch *aLm;
LineDescriptor lineDesc;
Image *imageHdl = NULL, *imageDestHdl = NULL;
char temp[1024] ="";

if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */

imageHdl = imaqCreateImage (0/*U8*/,1);
imageDestHdl = imaqCreateImage (0/*U8*/,1);

strcpy(temp,"C:\\CVI2013\\Projects\\Angel Tracker\\IMG\\CC01.bmp");

imaqReadFile (imageHdl, temp, NULL, NULL);

imaqEdgeFilter (imageDestHdl, imageHdl, IMAQ_EDGE_SOBEL, NULL);

lineDesc.maxLength = 100;
lineDesc.minLength = 50;

stShapeDetectionOption.minMatchScore = 1;
stShapeDetectionOption.mode = 0;
stShapeDetectionOption.numAngleRanges = 1;
stShapeDetectionOption.angleRanges = aAngleRanges;
stShapeDetectionOption.scaleRange.minValue = 1;
stShapeDetectionOption.scaleRange.maxValue = 10;

stCurveOptions.extractionMode = 0;
stCurveOptions.threshold = 100;
stCurveOptions.filterSize = 1;
stCurveOptions.minLength = 100;
stCurveOptions.rowStepSize = 10;
stCurveOptions.columnStepSize = 10;
stCurveOptions.maxEndPointGap = 1000;
stCurveOptions.onlyClosed = TRUE;
stCurveOptions.subpixelAccuracy = TRUE;

aLm = imaqDetectLines(imageDestHdl, &lineDesc, &stCurveOptions
,&stShapeDetectionOption, NULL, &nLines);

return 0;
}

我实际上在做的是:

  1. 打开 BMP 文件

  2. 边缘填充 imaqEdgeFilter()使用 SOBEL 进行操作

  3. 然后我想检测 imaqDetectLines() 的行函数

最佳答案

我发现了问题。

如果你看一下函数调用:

aLm = imaqDetectLines(imageDestHdl, &lineDesc, &stCurveOptions
,&stShapeDetectionOption, NULL, &nLines);

对于 ROI 参数,我传递了 NULL,因为我从功能面板帮助中得到了这个:

The region of interest applied to the image that specifies where circles can be detected. Set this parameter to NULL to search the entire image.

但是,显然这是一个已知的错误并且将会被修复,因此为了解决这个问题,只需执行以下操作:

ROI *roi;    
imaqSetWindowROI (0, NULL);
roi = imaqGetWindowROI (0);

然后将其发送到函数:

aLm = imaqDetectLines(imageDestHdl, &lineDesc, &stCurveOptions
,&stShapeDetectionOption, roi, &nLines);

关于c - 使用 NI VISION imaqDetectLines() 函数时出现一般保护错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40129025/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com