CVI2012报错:Function imaqReadFile: (errorCode == -1074396120 [0xbff60428]). Not an image.问题解决

简介: CVI2012报错:Function imaqReadFile: (errorCode == -1074396120 [0xbff60428]). Not an image.问题解决

问题


用 LabWindows CVI2012 做直方图均衡化的时候,读入图像出现报错:


NON-FATAL RUN-TIME ERROR:   "his.c", line 33, col 17, thread id 0x00004240:
Function imaqReadFile: (errorCode == -1074396120 [0xbff60428]). Not an image.



代码部分:


#include <cvirte.h>  
#include <userint.h>
#include "his.h"
#include "nivision.h"
static int panelHandle;
static Image *SourceImage;
int main (int argc, char *argv[])
{
  if (InitCVIRTE (0, argv, 0) == 0)
  return -1;  /* out of memory */
  if ((panelHandle = LoadPanel (0, "his.uir", PANEL)) < 0)
  return -1;
  DisplayPanel (panelHandle);
  RunUserInterface ();
  DiscardPanel (panelHandle);
  return 0;
}
int CVICALLBACK Load_and_display(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  char fileName[512];
  int status;
  HistogramReport *report;
  switch (event)
  {
  case EVENT_COMMIT:
  status = FileSelectPopup("", "*.bmp", "", "Select an Image File", VAL_LOAD_BUTTON, 0, 0, 1, 0, fileName);
    if (status == 1)
    {
    imaqReadFile(SourceImage, fileName, NULL, NULL);
    imaqMoveWindow(0, imaqMakePoint(50, 260));
    imaqDisplayImage(SourceImage, 0, TRUE);
    report = imaqHistogram(SourceImage, 256, 0,255, IMAQ_IMAGE_U8);
    DeleteGraphPlot(panelHandle, PANEL_HISTOGRAM, -1,
      VAL_IMMEDIATE_DRAW);
    PlotY(panelHandle, PANEL_HISTOGRAM, (*report).histogram,
      256, VAL_UNSIGNED_INTEGER, VAL_THIN_LINE,
      VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
    }
  break;
  }
  return 0;
}
int CVICALLBACK Quit (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  switch (event)
  {
  case EVENT_COMMIT:
    QuitUserInterface (0);
    break;
  }
  return 0;
}


运行的时候面板能够打开,从目录中选取读入的图像文件也没有问题,但在点击 Load 加载图像的时候就遇到了报错。


刚开始看到 Not an image 我以为是图像有问题,把原本读入的 jpg 文件换成 bmp 文件,后来发现还是行不通


原因


代码中虽然定义了 SourceImage ,但是没有创建存储区域


解决


在 main() 函数中添加代码:


SourceImage = imaqCreateImage (IMAQ_IMAGE_U8, 2);


完整代码:


#include <cvirte.h>  
#include <userint.h>
#include "his.h"
#include "nivision.h"
static int panelHandle;
static Image *SourceImage;
int main (int argc, char *argv[])
{
  if (InitCVIRTE (0, argv, 0) == 0)
  return -1;  /* out of memory */
  if ((panelHandle = LoadPanel (0, "his.uir", PANEL)) < 0)
  return -1;
  DisplayPanel (panelHandle);
  SourceImage = imaqCreateImage (IMAQ_IMAGE_U8, 2);
  RunUserInterface ();
  DiscardPanel (panelHandle);
  return 0;
}
int CVICALLBACK Load_and_display(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  char fileName[512];
  int status;
  HistogramReport *report;
  switch (event)
  {
  case EVENT_COMMIT:
  status = FileSelectPopup("", "*.bmp", "", "Select an Image File", VAL_LOAD_BUTTON, 0, 0, 1, 0, fileName);
    if (status == 1)
    {
    imaqReadFile(SourceImage, fileName, NULL, NULL);
    imaqMoveWindow(0, imaqMakePoint(50, 260));
    imaqDisplayImage(SourceImage, 0, TRUE);
    report = imaqHistogram(SourceImage, 256, 0,255, IMAQ_IMAGE_U8);
    DeleteGraphPlot(panelHandle, PANEL_HISTOGRAM, -1,
      VAL_IMMEDIATE_DRAW);
    PlotY(panelHandle, PANEL_HISTOGRAM, (*report).histogram,
      256, VAL_UNSIGNED_INTEGER, VAL_THIN_LINE,
      VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
    }
  break;
  }
  return 0;
}
int CVICALLBACK Quit (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  switch (event)
  {
  case EVENT_COMMIT:
    QuitUserInterface (0);
    break;
  }
  return 0;
}


相关文章
|
4月前
|
弹性计算 监控 Serverless
函数计算操作报错合集之调用不成功,报错:Function instance health check failed on port 9000 in 120.7 seconds.该怎么办
在使用函数计算服务(如阿里云函数计算)时,用户可能会遇到多种错误场景。以下是一些常见的操作报错及其可能的原因和解决方法,包括但不限于:1. 函数部署失败、2. 函数执行超时、3. 资源不足错误、4. 权限与访问错误、5. 依赖问题、6. 网络配置错误、7. 触发器配置错误、8. 日志与监控问题。
|
5月前
|
弹性计算 缓存 Serverless
Serverless 应用引擎操作报错合集之阿里函数计算中我打开sd时遇到错误,信息为"Function instance exited unexpectedly(code 1, message:operation not permitted) with start command ' '."如何解决
Serverless 应用引擎(SAE)是阿里云提供的Serverless PaaS平台,支持Spring Cloud、Dubbo、HSF等主流微服务框架,简化应用的部署、运维和弹性伸缩。在使用SAE过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
260 6
|
2月前
|
缓存
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
|
2月前
解决微软云Azure Function运行报错-Value cannot be null. (Parameter ‘provider‘)
解决微软云Azure Function运行报错-Value cannot be null. (Parameter ‘provider‘)
50 4
|
2月前
|
存储 网络安全 数据中心
【Azure 应用服务】Function App / App Service 连接 Blob 报错
【Azure 应用服务】Function App / App Service 连接 Blob 报错
|
2月前
|
Linux C++ Docker
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
|
2月前
|
JavaScript 前端开发 C++
【Azure Function】调试 VS Code Javascript Function本地不能运行,报错 Value cannot be null. (Parameter 'provider')问题
【Azure Function】调试 VS Code Javascript Function本地不能运行,报错 Value cannot be null. (Parameter 'provider')问题
|
3月前
|
JSON Java Serverless
函数计算操作报错合集之报错Function time out after该怎么办
Serverless 应用引擎(SAE)是阿里云提供的Serverless PaaS平台,支持Spring Cloud、Dubbo、HSF等主流微服务框架,简化应用的部署、运维和弹性伸缩。在使用SAE过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
3月前
|
存储 缓存 Serverless
函数计算操作报错合集之如何处理运行时报错:“Function time out after 600 seconds”
在使用函数计算服务(如阿里云函数计算)时,用户可能会遇到多种错误场景。以下是一些常见的操作报错及其可能的原因和解决方法,包括但不限于:1. 函数部署失败、2. 函数执行超时、3. 资源不足错误、4. 权限与访问错误、5. 依赖问题、6. 网络配置错误、7. 触发器配置错误、8. 日志与监控问题。
|
3月前
|
Serverless 应用服务中间件 网络安全
函数计算操作报错合集之如何处理报错 "Function instance health check failed on port 7860 in 120 seconds."
在使用函数计算服务(如阿里云函数计算)时,用户可能会遇到多种错误场景。以下是一些常见的操作报错及其可能的原因和解决方法,包括但不限于:1. 函数部署失败、2. 函数执行超时、3. 资源不足错误、4. 权限与访问错误、5. 依赖问题、6. 网络配置错误、7. 触发器配置错误、8. 日志与监控问题。

热门文章

最新文章

下一篇
无影云桌面