当前位置:编程学习 > wap >>

如何实现两个摄像头轮流采集,求大大帮忙

因为不能同时打开两个摄像头,所以想轮流打开采集,但是编程功底不够,主要程序部分如下,单独都能实现。



MyHelloForm::MyHelloForm( QWidget* parent, const char* name, WFlags fl)
     :HelloBaseForm(parent, name, fl)
{

  connect (this, SIGNAL(close_signal()), this, SLOT(camara_quit()));  
  connect (this, SIGNAL(quit_signal()), qApp, SLOT(quit()));
  connect (CloseButton, SIGNAL(clicked()), this, SLOT(camara_quit()));
  connect (SnapButton, SIGNAL(clicked()), this, SLOT(camara_snap()));
 //这里是初始化第一个摄像头

  if (v4l2_init("/dev/video2"))
  {
    printf("video2 init is error!\n");
    emit(close_signal());
  }
  timer = new QTimer(this); 
  connect (timer, SIGNAL(timeout()), this, SLOT(showMe1()));
  timer->start(FRAME_IDLE);
 //如果注释掉下面内容就可以显示一边了,但我还想显示另一个摄像头。   
   
  //这一段是清除映射关系等
     munmap(buffers[0].start, FRAME_COUNT*buffers[0].length);
   ::close(fd);
    timer->stop();



//这一段是打开第二个摄像头
  if (v4l2_init2("/dev/video3"))
  {
   printf("video3 init is error!\n");
    emit(close_signal());
  }   
 timer = new QTimer(this); 
  connect (timer, SIGNAL(timeout()), this, SLOT(showMe2()));
  timer->start(FRAME_IDLE);

//程序到这里结束可以显示第二个摄像头,但是不能显示第一个

//我大概设计了一个UI左右两边可以实时显示采集的图像就是showMe1和showMe2。

//怎么让他们轮流采集呢,一直不成功,求各位大大帮忙。
   
}
--------------------编程问答-------------------- 求助啊,用得是v4l2的嵌入式linux开发板 --------------------编程问答-------------------- 这样很慢啊,启动摄像头需要时间,呵呵 --------------------编程问答-------------------- 帮顶111很久没碰QT了。 --------------------编程问答--------------------
引用 2 楼 brandboy 的回复:
这样很慢啊,启动摄像头需要时间,呵呵

挺快的哦,至少只是轻轻那么一顿…… --------------------编程问答-------------------- 你的一个timer变量  New了2次?可在响应timeout的函数里里设置一个变量,设置为真的时候采集第一个摄像头,为假时采集另外个摄像头? --------------------编程问答-------------------- 过一段时间我也该涉及到这方面了 但是现在啥都不会呀  
楼主的代码 现在都看不懂呢
补充:移动开发 ,  Qt
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,