- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有一个正在运行的 BeagleBone Ångström Linux 3.2.28,我正在尝试从我的相机中捕捉一帧画面。
所以我插入我的 USB 网络摄像头,并检查 /dev
以确保它显示。
确实如此,如 video0
(右下)。我知道这是正确的,因为它会在我拔下相机后消失。
现在我启动 Python 并运行以下命令:
root@beaglebone:/dev# python
Python 2.7.2 (default, Sep 11 2012, 16:15:43)
[GCC 4.5.4 20120305 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>> capture=cv.CaptureFromCAM(-1)
>>> img=cv.QueryFrame(capture)
>>> type(capture)
<type 'cv2.Capture'>
>>> type(img)
<type 'NoneType'>
如您所见,我能够充分创建捕获对象,但无法从中提取框架。我也尝试过使用相机 ID 的不同(或没有)整数参数(上面代码中的 -1
)无济于事。
作为引用,在我的笔记本电脑上运行相同的代码 IPython看起来像这样:
In [1]: import cv
In [2]: capture=cv.CaptureFromCAM(-1)
In [3]: img=cv.QueryFrame(capture)
In [4]: type(capture)
Out[4]: cv2.Capture
In [5]: type(img)
Out[5]: cv2.cv.iplimage
你可以看到这里我确实在捕捉图像。我不确定从这里到哪里去。
更新:
我玩过 FFmpeg并且能够通过发出以下命令让相机响应(即它的灯亮起):
root@beaglebone:/# ffmpeg -f video4linux2 -i /dev/video0
这很有趣,因为 apparently CaptureFromCAM
使用 V4L 接口(interface)...我不知道从这里去哪里。
最佳答案
非常first thing you need to do 确保 CaptureFromCAM()
成功:
import cv
capture = cv.CaptureFromCAM(-1)
if not capture:
print "Unable to open device #-1"
sys.exit(1)
发送 -1
作为参数告诉 OpenCV 打开默认相机设备。在某些系统上这不起作用,您需要增加数量。尝试传递 0
,然后是 1
,然后是 2
。
您需要做的第二件事是确保QueryFrame()
也返回有效的内容:
img = cv.QueryFrame(capture)
if not img:
print "Unable to retrieve frame from the device"
sys.exit(1)
我见过 OpenCV 的 Python API 和 C(甚至 C++)API 之间的奇怪行为。如果以上方法都不能帮助您解决问题,我建议您使用 OpenCV 编译一个 C 程序(它具有最可靠的 API)以从相机中检索数据。在某些情况下,OpenCV 的 C API 可以工作而 Python 不能。
This C program从相机中检索帧并将它们显示在窗口中:
#include <stdio.h>
#include <highgui.h>
#include <cv.h>
int main()
{
CvCapture* capture = NULL;
if ((capture = cvCaptureFromCAM(-1)) == NULL)
{
fprintf(stderr, "ERROR: capture is NULL \n");
return -1;
}
cvNamedWindow("mywindow", CV_WINDOW_AUTOSIZE);
cvQueryFrame(capture); // Sometimes needed to get correct data
while (1)
{
IplImage* frame = cvQueryFrame(capture); // check return
{
fprintf( stderr, "ERROR: cvQueryFrame failed\n");
break;
}
// At this point you already have the frame! There's no need to
// repeat the thing 10x with cvGrabFrame and cvRetrieveFrame.
// You are probably sabotaging yourself doing this multiple times.
cvShowImage("mywindow", frame); // Do not release the frame!
int key = cvWaitKey(10);
if (key == 0x1b)
break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("mywindow");
return 0;
}
关于linux - 使用 OpenCV 让 BeagleBone 捕获静止帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15254397/
尝试将 MPU6050 连接到在 Beaglebone-IO 下运行 Debian、Node.js 和 Johnny-Five 的 Beaglebone Black。 使用 Johnny-Five 示
我有一个 RFID 模块连接到我的 beaglebone 并使用 python 代码读取 ID 标签。现在,我希望我的 python 代码在没有任何命令的情况下登录我的 beaglebone 时直接在
在 beagleboard 或 beaglebone 中,引脚有不同的工作模式。对于以前的内核,它们位于/sys/kernel/debug/omap_mux 中。你知道最后一个内核中那些文件在哪里吗?
我听说可以直接在 Beaglebone black 上进行开发和调试。我是做Java的。目前我必须生成 jar 并复制到开发板然后运行。但这样我就无法调试和单步执行代码。在本地调试也没有什么意义,因为
提前致谢。我正在尝试在 Texas Instrument 制造的 beaglebone black (BBB) 上播放视频。由于有很多关于使用 ffmpeg 和 SDL 的好教程,我决定使用它。获取有
我是 beaglebone 的新手,我需要一些帮助来解决我面临的一些问题。 我用 c 编写了一段代码(在装有 ubuntu 的笔记本电脑上运行),其中打开了一个服务器套接字(运行一个 apache 服
我是 beaglebone 的新生。我需要你的帮助。我已经在 Eclipse 中的 64 位 xubuntu 以及 codeblocks 环境中安装了交叉编译器工具链 arm-linux-gnueab
我正在尝试遵循发现的演练/教程 here . 我正在运行内核版本 4.1.1-ti-r2,该版本的 rcn-ee.net/deb/trusty-armhf 文件夹中似乎没有任何头文件。这意味着我无法迈
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我正在读取 beaglebone gpio 引脚中的霍尔传感器输出,对于中断服务例程需要执行的每个上升沿。那么,如何在 beaglebone 中使用外部中断呢?是否有用于此目的的标准驱动程序? 谢谢。
当我使用如下以太网电缆将其插入新网络时,我需要知道如何使用 SSH 连接到 beaglebone(或 beagleboard): $ ssh root@beaglebone.local 到目前
我昨天买了 beaglebone black 并尝试使用 USB 连接它。正如我所读到的那样,它预装了运行在 192.168.7.2 的 Linux Distro,我们可以使用 ssh 访问它。但我无
我们目前正在为 BeagleBone Black 开发一个应用程序(使用标准的 Angstrom 发行版)。它在 GDB(由 Netbeans 远程控制)下运行了一段时间(5-10 分钟),但在某个相
在 C++ 中进行串行操作似乎很痛苦,此外,在 Beaglebone Black 上进行操作也很困难,所以我需要有一些专业知识的人! 我使用以下命令创建了/dev/ttyO4: echo BB-UAR
我正在通过串行端口(ttyO2)连接 BBB 和一组 arduino。我有一个数组要从 BBB 发送到一组 arduino。我需要让 BBB 发送请求并等待其中一个 arduino 的回复,但如果在一
美好的一天, 我想弄清楚如何在 openCV 的 beaglebone 上关闭相机。我已经尝试了很多命令,例如 release(&camera),但都不存在,而且当我不希望它打开时,相机会继续保持打开
我需要直接从 Python 代码 关闭 Beaglebone black,而不使用任何 gpio 按钮或任何硬件干预。 有命令行 shutdown -h now 但此命令不适用于 python 代码,
我的知识:我的 Linux 知识还处于初级阶段,所以如果我做了一些愚蠢的事情,请纠正我,或者给我你的意见。 我的问题:我想以相同的方式配置一堆单板计算机(Raspberry Pi/BeagleBone
为了通过 USB 从我的 ubuntu 主机获取互联网,我更改了 beaglebone 上的路由 route add default gw 192.168.7.1 并将/etc/resolv.conf
我需要在机器人上执行一组命令,机器人已经连接了Mini-ITX PC,但速度很慢,而且实时结果不理想。 我想使用外部 BeagleBone 作为处理单元,但如何配置设置以在 BeagleBone 上处
我是一名优秀的程序员,十分优秀!