开发者社区> 问答> 正文

无效的参数 munmap:无效的参数 problem with libv4l2 - 服务报错

我今天写了个测试程序,在linux下坐测试,发现这句话执行时会报这样的提示,但依旧能正常预览视频,我很奇怪!虽说能运行,但下到板子里就不行了。请高人提示下,我的测试代码:

#include <stdio.h>

#include <cv.h>

#include <highgui.h>

int main()

{

  //声明IplImage指针

  IplImage* pFrame = NULL;

printf("IplImage oK\n");

 //获取摄像头

  CvCapture* pCapture = cvCreateCameraCapture(-1);

printf("cvCreateCameraCapture OK!\n"); 

  //创建窗口

  cvNamedWindow("video", 1);

printf("cvNamedwindow OK!\n"); 

  //显示视屏

  while(1)

  {

      pFrame=cvQueryFrame( pCapture );

      printf("first frame\n");

      if(!pFrame)

         {

            printf("fail to cvQueryFrame!\n");       

             break;

          }    

  cvShowImage("video",pFrame);

      char c=cvWaitKey(33);

      if(c==27)break;

  }

  cvReleaseCapture(&pCapture);

  cvReleaseImage(&pFrame);

  cvDestroyWindow("video");

}


用gcc编译器之后,运行结果如下:

IplImage oK

mmap: Invalid argument

munmap: Invalid argument

munmap: Invalid argument

munmap: Invalid argument

munmap: Invalid argument

Unable to stop the stream.: Bad file descriptor

munmap: Invalid argument

munmap: Invalid argument

munmap: Invalid argument

munmap: Invalid argument

cvCreateCameraCapture OK!

cvNamedwindow OK!

后面的都好好的。。。。 渴望您的指点

 

展开
收起
montos 2020-05-29 21:15:28 1169 0
1 条回答
写回答
取消 提交回答
  • zhe这难道是opencv的一个bug???######

    我在google上得到:

    problem with libv4l2

    Hi,
    I've looked for some post with my problem but I haven't found.
    I have started to use opencv with Harpia without problems. Today, I have decided to install the latest
    version of opencv.
    After the installation, I've re-compile my source and I've encountered this error:
     
    "...(software runs correctly)...
     
    mmap: Invalid argument
    munmap: Invalid argument
    munmap: Invalid argument
    munmap: Invalid argument
    munmap: Invalid argument
    Unable to stop the stream.: Bad file descriptor
    munmap: Invalid argument
    munmap: Invalid argument
    munmap: Invalid argument
    munmap: Invalid argument
    libv4l2: error converting / decoding frame data: v4l-convert: error parsing JPEG header: Not a JPG file ?
     
    HIGHGUI ERROR: V4L: Could not SYNC to video stream. Input/output error
     
    ...(software runs correctly)
     
    Segmentation fault"
     
    The error is generated by this code:
     
    ImgCap = cvCaptureFromCAM(0); 
    if(!cvGrabFrame(ImgCap))  
            printf("Cannot Grab Image from camera 1"); 
    ImgFr1 = cvRetrieveFrame( ImgCap ,0); 
     
    and I think that it depends on "static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture,
    int)" of cvcap_v4l.cpp
     
    Someone knows the solution of my problem?
     
    I've tried with Opencv 2.0 and 2.1, with a philips spc1300nc and the integrated laptop camera.
    Same error, while the harpia opencv run correctly.
     
    Thanks
     
    ------------------------------------
     
    Change settings: http://www.yahoogroups.com/mygroups, select
       Get Emails (get all posts)
       Daily Digest (one summary email per day)
       Read on the web (read posts on the web only)Or Unsubscribe by mailing OpenCV-unsubscribe <at> yahoogroups.com

     

    ######和我的问题一样啊!!!!######http://ubuntuforums.org/showthread.php?t=1453004 这个人的问题也和我一样
    2020-05-29 21:15:45
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载