主题 : opencv摄像头采集问题 segmentation fault! 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 55229
精华: 0
发帖: 86
金钱: 435 两
威望: 87 点
贡献值: 0 点
综合积分: 172 分
注册时间: 2011-09-14
最后登录: 2013-03-11
楼主  发表于: 2011-11-11 16:19

 opencv摄像头采集问题 segmentation fault!

我将opencv的以及opencv依赖的库ffmepg,xvid,x264交叉编译好,移植到tiny6410当中,测试程序是用opencv进行视频采集,然后用Qt显示(由于没有移植GTK,所以无法用highgui的cvShowImage()函数),程序在虚拟机上测试都成功了,为什么移植到板子上出现以下错误,不知道怎么解决,都好几天了,还是没有结果!希望各位大侠指导一下!我觉得应该是程序中调用了CvCapture *capture=cvCreateCameraCapture(index)函数,当中的index参数我设的为0,是不是参数设置不正确,使得capture指针为空,而导致的segmentation fault!
------------[ cut here ]------------
WARNING: at kernel/mutex.c:205 __mutex_lock_slowpath+0xc4/0x2ac()
Modules linked in:
[<c0177c44>] (unwind_backtrace+0x0/0xe4) from [<c0187078>] (warn_slowpath_common+0x4c/0x64)
[<c0187078>] (warn_slowpath_common+0x4c/0x64) from [<c01870a8>] (warn_slowpath_null+0x18/0x1c)
[<c01870a8>] (warn_slowpath_null+0x18/0x1c) from [<c051619c>] (__mutex_lock_slowpath+0xc4/0x2ac)
[<c051619c>] (__mutex_lock_slowpath+0xc4/0x2ac) from [<c05163a4>] (mutex_lock+0x20/0x38)
[<c05163a4>] (mutex_lock+0x20/0x38) from [<c0441614>] (s3c_fimc_open+0x38/0xa8)
[<c0441614>] (s3c_fimc_open+0x38/0xa8) from [<c03c450c>] (v4l2_open+0x9c/0xd0)
[<c03c450c>] (v4l2_open+0x9c/0xd0) from [<c01e4f10>] (chrdev_open+0x168/0x190)
[<c01e4f10>] (chrdev_open+0x168/0x190) from [<c01e031c>] (__dentry_open.clone.12+0x164/0x26c)
[<c01e031c>] (__dentry_open.clone.12+0x164/0x26c) from [<c01ed194>] (finish_open+0x80/0x158)
[<c01ed194>] (finish_open+0x80/0x158) from [<c01ed610>] (do_filp_open+0x11c/0x520)
[<c01ed610>] (do_filp_open+0x11c/0x520) from [<c01e1144>] (do_sys_open+0x58/0xe4)
[<c01e1144>] (do_sys_open+0x58/0xe4) from [<c01725e0>] (ret_fast_syscall+0x0/0x30)
---[ end trace dbc45def69de5948 ]---
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = cc458000
[00000000] *pgd=5c436831, *pte=00000000, *ppte=00000000
Internal error: Oops: 817 [#1] PREEMPT
last sysfs file: /sys/devices/virtual/vc/vcsa2/dev
Modules linked in:
CPU: 0    Tainted: G        W    (2.6.38-FriendlyARM #13)
PC is at __mutex_lock_slowpath+0xf8/0x2ac
LR is at __mutex_lock_slowpath+0xe0/0x2ac
pc : [<c05161d0>]    lr : [<c05161b8>]    psr: 40000093
sp : cd4ebde8  ip : 11111111  fp : ccfef000
r10: cd1568c0  r9 : c01e4da8  r8 : cd4ebde8
r7 : c0793ee0  r6 : cd4c32c0  r5 : 60000013  r4 : c0793ecc
r3 : 00000000  r2 : cd4ea000  r1 : cd4ebde8  r0 : c0793ecc
Flags: nZcv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
Control: 00c5387d  Table: 5c458008  DAC: 00000015
Process QtOpenCV (pid: 1021, stack limit = 0xcd4ea268)
Stack: (0xcd4ebde8 to 0xcd4ec000)
bde0:                   c0793ee0 00000000 11111111 cd4ebde8 ffffffff c0793ecc
be00: c0793ecc 00000458 c0793a5c cd6930a0 c01e4da8 cd1568c0 ccfef000 c05163a4
be20: c0755db0 c0441614 c0755db0 c04415dc c0755db8 cd6930a0 c055d768 c03c450c
be40: c03c4470 cd1568c0 cd6930a0 ccedc8c0 00000000 c01e4f10 cd1568c0 00000000
be60: c051c614 00000000 cd693320 cd155510 cd6930a0 c01e031c cd4ebee4 00000000
be80: 00000000 00000000 00000024 cd4ea000 ffffffff c01ed194 cd4ebee4 00000000
bea0: 00000000 00000101 cd4ebee4 00000024 00000000 c01ed610 00000000 cd732500
bec0: c073d774 cd732d00 00000001 ffffff9c 00000000 c0183194 00000000 c07242f0
bee0: 00000000 cd693320 cd155510 c0724338 cd4c32f0 cc4011e0 00000000 cd019f30
bf00: 00000000 cd1568c0 00000101 00000004 00000001 00000000 40000000 cd4ea000
bf20: cd154a80 00000010 cd693008 cd154a80 cd425324 00000000 00000001 00000001
bf40: 00000000 00000000 cd425308 cd425300 00016450 c051744c cd425308 00000003
bf60: ffffff9c ccfef000 00000000 00000000 cd4ea000 ffffffff 00016450 c01e1144
bf80: 00000000 bedb6a48 bedb6a48 400e8000 00000002 00000005 c0172788 cd4ea000
bfa0: 00000000 c01725e0 bedb6a48 400e8000 bedb6a48 00000000 ffffffff bedb6a53
bfc0: bedb6a48 400e8000 00000002 00000005 00000000 00000001 400d8ba0 00016450
bfe0: 400e8878 bedb6a28 400d2944 4006436c 40000010 bedb6a48 00000000 00000000
[<c05161d0>] (__mutex_lock_slowpath+0xf8/0x2ac) from [<c05163a4>] (mutex_lock+0x20/0x38)
[<c05163a4>] (mutex_lock+0x20/0x38) from [<c0441614>] (s3c_fimc_open+0x38/0xa8)
[<c0441614>] (s3c_fimc_open+0x38/0xa8) from [<c03c450c>] (v4l2_open+0x9c/0xd0)
[<c03c450c>] (v4l2_open+0x9c/0xd0) from [<c01e4f10>] (chrdev_open+0x168/0x190)
[<c01e4f10>] (chrdev_open+0x168/0x190) from [<c01e031c>] (__dentry_open.clone.12+0x164/0x26c)
[<c01e031c>] (__dentry_open.clone.12+0x164/0x26c) from [<c01ed194>] (finish_open+0x80/0x158)
[<c01ed194>] (finish_open+0x80/0x158) from [<c01ed610>] (do_filp_open+0x11c/0x520)
[<c01ed610>] (do_filp_open+0x11c/0x520) from [<c01e1144>] (do_sys_open+0x58/0xe4)
[<c01e1144>] (do_sys_open+0x58/0xe4) from [<c01725e0>] (ret_fast_syscall+0x0/0x30)
Code: e584d018 e58d7000 e58d3004 e1a0800d (e583d000)
---[ end trace dbc45def69de5949 ]---
note: QtOpenCV[1021] exited with preempt_count 1
BUG: scheduling while atomic: QtOpenCV/1021/0x40000002
Modules linked in:
[<c0177c44>] (unwind_backtrace+0x0/0xe4) from [<c0514d78>] (schedule+0x68/0x370)
[<c0514d78>] (schedule+0x68/0x370) from [<c0183330>] (__cond_resched+0x14/0x20)
one_wire_status: 2
[<c0183330>] (__cond_resched+0x14/0x20) from [<c05151e8>] (_cond_resched+0x34/0x44)
[<c05151e8>] (_cond_resched+0x34/0x44) from [<c01cf928>] (unmap_vmas+0x600/0x6d8)
[<c01cf928>] (unmap_vmas+0x600/0x6d8) from [<c01d41cc>] (exit_mmap+0x100/0x274)
one_wire_status: 2
[<c01d41cc>] (exit_mmap+0x100/0x274) from [<c0184e2c>] (mmput+0x48/0xe4)
[<c0184e2c>] (mmput+0x48/0xe4) from [<c0188b74>] (exit_mm+0x12c/0x138)
[<c0188b74>] (exit_mm+0x12c/0x138) from [<c0189f80>] (do_exit+0x1a0/0x5e4)
one_wire_status: 3
[<c0189f80>] (do_exit+0x1a0/0x5e4) from [<c0176284>] (die+0x190/0x1c0)
[<c0176284>] (die+0x190/0x1c0) from [<c0178bc8>] (__do_kernel_fault+0x64/0x84)
[<c0178bc8>] (__do_kernel_fault+0x64/0x84) from [<c0178dc0>] (do_page_fault+0x1d8/0x1f4)
one_wire_status: 4
[<c0178dc0>] (do_page_fault+0x1d8/0x1f4) from [<c0168218>] (do_DataAbort+0x30/0x98)
[<c0168218>] (do_DataAbort+0x30/0x98) from [<c01721cc>] (__dabt_svc+0x4c/0x60)
one_wire_status: 4
Exception stack(0xcd4ebda0 to 0xcd4ebde8)
bda0: c0793ecc cd4ebde8 cd4ea000 00000000 c0793ecc 60000013 cd4c32c0 c0793ee0
bdc0: cd4ebde8 c01e4da8 cd1568c0 ccfef000 11111111 cd4ebde8 c05161b8 c05161d0
one_wire_status: 4
bde0: 40000093 ffffffff
[<c01721cc>] (__dabt_svc+0x4c/0x60) from [<c05161d0>] (__mutex_lock_slowpath+0xf8/0x2ac)
[<c05161d0>] (__mutex_lock_slowpath+0xf8/0x2ac) from [<c05163a4>] (mutex_lock+0x20/0x38)
one_wire_status: 4
[<c05163a4>] (mutex_lock+0x20/0x38) from [<c0441614>] (s3c_fimc_open+0x38/0xa8)
[<c0441614>] (s3c_fimc_open+0x38/0xa8) from [<c03c450c>] (v4l2_open+0x9c/0xd0)
[<c03c450c>] (v4l2_open+0x9c/0xd0) from [<c01e4f10>] (chrdev_open+0x168/0x190)
one_wire_status: 4
[<c01e4f10>] (chrdev_open+0x168/0x190) from [<c01e031c>] (__dentry_open.clone.12+0x164/0x26c)
[<c01e031c>] (__dentry_open.clone.12+0x164/0x26c) from [<c01ed194>] (finish_open+0x80/0x158)
one_wire_status: 4
[<c01ed194>] (finish_open+0x80/0x158) from [<c01ed610>] (do_filp_open+0x11c/0x520)
[<c01ed610>] (do_filp_open+0x11c/0x520) from [<c01e1144>] (do_sys_open+0x58/0xe4)
[<c01e1144>] (do_sys_open+0x58/0xe4) from [<c01725e0>] (ret_fast_syscall+0x0/0x30)
BUG: scheduling while atomic: QtOpenCV/1021/0x40000002
Modules linked in:
[<c0177c44>] (unwind_backtrace+0x0/0xe4) from [<c0514d78>] (schedule+0x68/0x370)
one_wire_status: 4
[<c0514d78>] (schedule+0x68/0x370) from [<c0183330>] (__cond_resched+0x14/0x20)
[<c0183330>] (__cond_resched+0x14/0x20) from [<c05151e8>] (_cond_resched+0x34/0x44)
[<c05151e8>] (_cond_resched+0x34/0x44) from [<c01cf928>] (unmap_vmas+0x600/0x6d8)
one_wire_status: 4
[<c01cf928>] (unmap_vmas+0x600/0x6d8) from [<c01d41cc>] (exit_mmap+0x100/0x274)
[<c01d41cc>] (exit_mmap+0x100/0x274) from [<c0184e2c>] (mmput+0x48/0xe4)
[<c0184e2c>] (mmput+0x48/0xe4) from [<c0188b74>] (exit_mm+0x12c/0x138)
one_wire_status: 4
[<c0188b74>] (exit_mm+0x12c/0x138) from [<c0189f80>] (do_exit+0x1a0/0x5e4)
[<c0189f80>] (do_exit+0x1a0/0x5e4) from [<c0176284>] (die+0x190/0x1c0)
[<c0176284>] (die+0x190/0x1c0) from [<c0178bc8>] (__do_kernel_fault+0x64/0x84)
[<c0178bc8>] (__do_kernel_fault+0x64/0x84) from [<c0178dc0>] (do_page_fault+0x1d8/0x1f4)
[<c0178dc0>] (do_page_fault+0x1d8/0x1f4) from [<c0168218>] (do_DataAbort+0x30/0x98)
one_wire_status: 2
[<c0168218>] (do_DataAbort+0x30/0x98) from [<c01721cc>] (__dabt_svc+0x4c/0x60)
Exception stack(0xcd4ebda0 to 0xcd4ebde8)
bda0: c0793ecc cd4ebde8 cd4ea000 00000000 c0793ecc 60000013 cd4c32c0 c0793ee0
one_wire_status: 2
bdc0: cd4ebde8 c01e4da8 cd1568c0 ccfef000 11111111 cd4ebde8 c05161b8 c05161d0
bde0: 40000093 ffffffff
[<c01721cc>] (__dabt_svc+0x4c/0x60) from [<c05161d0>] (__mutex_lock_slowpath+0xf8/0x2ac)
[<c05161d0>] (__mutex_lock_slowpath+0xf8/0x2ac) from [<c05163a4>] (mutex_lock+0x20/0x38)
one_wire_status: 2
[<c05163a4>] (mutex_lock+0x20/0x38) from [<c0441614>] (s3c_fimc_open+0x38/0xa8)
[<c0441614>] (s3c_fimc_open+0x38/0xa8) from [<c03c450c>] (v4l2_open+0x9c/0xd0)
one_wire_status: 3
[<c03c450c>] (v4l2_open+0x9c/0xd0) from [<c01e4f10>] (chrdev_open+0x168/0x190)
[<c01e4f10>] (chrdev_open+0x168/0x190) from [<c01e031c>] (__dentry_open.clone.12+0x164/0x26c)
one_wire_status: 4
[<c01e031c>] (__dentry_open.clone.12+0x164/0x26c) from [<c01ed194>] (finish_open+0x80/0x158)
[<c01ed194>] (finish_open+0x80/0x158) from [<c01ed610>] (do_filp_open+0x11c/0x520)
[<c01ed610>] (do_filp_open+0x11c/0x520) from [<c01e1144>] (do_sys_open+0x58/0xe4)
one_wire_status: 4
[<c01e1144>] (do_sys_open+0x58/0xe4) from [<c01725e0>] (ret_fast_syscall+0x0/0x30)
BUG: scheduling while atomic: QtOpenCV/1021/0x40000002
Modules linked in:
[<c0177c44>] (unwind_backtrace+0x0/0xe4) from [<c0514d78>] (schedule+0x68/0x370)
[<c0514d78>] (schedule+0x68/0x370) from [<c0183330>] (__cond_resched+0x14/0x20)
[<c0183330>] (__cond_resched+0x14/0x20) from [<c05151e8>] (_cond_resched+0x34/0x44)
one_wire_status: 2
[<c05151e8>] (_cond_resched+0x34/0x44) from [<c0189d04>] (put_files_struct+0x9c/0xfc)
[<c0189d04>] (put_files_struct+0x9c/0xfc) from [<c0189f90>] (do_exit+0x1b0/0x5e4)
[<c0189f90>] (do_exit+0x1b0/0x5e4) from [<c0176284>] (die+0x190/0x1c0)
one_wire_status: 2
[<c0176284>] (die+0x190/0x1c0) from [<c0178bc8>] (__do_kernel_fault+0x64/0x84)
[<c0178bc8>] (__do_kernel_fault+0x64/0x84) from [<c0178dc0>] (do_page_fault+0x1d8/0x1f4)
one_wire_status: 2
[<c0178dc0>] (do_page_fault+0x1d8/0x1f4) from [<c0168218>] (do_DataAbort+0x30/0x98)
[<c0168218>] (do_DataAbort+0x30/0x98) from [<c01721cc>] (__dabt_svc+0x4c/0x60)
Exception stack(0xcd4ebda0 to 0xcd4ebde8)
one_wire_status: 4
bda0: c0793ecc cd4ebde8 cd4ea000 00000000 c0793ecc 60000013 cd4c32c0 c0793ee0
bdc0: cd4ebde8 c01e4da8 cd1568c0 ccfef000 11111111 cd4ebde8 c05161b8 c05161d0
bde0: 40000093 ffffffff
[<c01721cc>] (__dabt_svc+0x4c/0x60) from [<c05161d0>] (__mutex_lock_slowpath+0xf8/0x2ac)
one_wire_status: 4
[<c05161d0>] (__mutex_lock_slowpath+0xf8/0x2ac) from [<c05163a4>] (mutex_lock+0x20/0x38)
[<c05163a4>] (mutex_lock+0x20/0x38) from [<c0441614>] (s3c_fimc_open+0x38/0xa8)
one_wire_status: 4
[<c0441614>] (s3c_fimc_open+0x38/0xa8) from [<c03c450c>] (v4l2_open+0x9c/0xd0)
[<c03c450c>] (v4l2_open+0x9c/0xd0) from [<c01e4f10>] (chrdev_open+0x168/0x190)
[<c01e4f10>] (chrdev_open+0x168/0x190) from [<c01e031c>] (__dentry_open.clone.12+0x164/0x26c)
one_wire_status: 4
[<c01e031c>] (__dentry_open.clone.12+0x164/0x26c) from [<c01ed194>] (finish_open+0x80/0x158)
[<c01ed194>] (finish_open+0x80/0x158) from [<c01ed610>] (do_filp_open+0x11c/0x520)
one_wire_status: 4
[<c01ed610>] (do_filp_open+0x11c/0x520) from [<c01e1144>] (do_sys_open+0x58/0xe4)
[<c01e1144>] (do_sys_open+0x58/0xe4) from [<c01725e0>] (ret_fast_syscall+0x0/0x30)
one_wire_status: 4
Segmentation fault
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2011-11-11 17:55
(http://www.ai.rug.nl/vakinformatie/pas/content/Highgui/opencvref_highgui.htm)

cvCreateCameraCapture
Initializes capturing video from camera

CvCapture* cvCreateCameraCapture( int index );
index
Index of the camera to be used. If there is only one camera or it does not matter what camera to use -1 may be passed.
The function cvCreateCameraCapture allocates and initialized the CvCapture structure for reading a video stream from the camera. Currently two camera interfaces can be used on Windows: Video for Windows (VFW) and Matrox Imaging Library (MIL); and two on Linux: V4L and FireWire (IEEE1394).

To release the sturtcure, use cvReleaseCapture.
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 55229
精华: 0
发帖: 86
金钱: 435 两
威望: 87 点
贡献值: 0 点
综合积分: 172 分
注册时间: 2011-09-14
最后登录: 2013-03-11
2楼  发表于: 2011-11-12 22:49

 回 1楼(kasim) 的帖子

谢谢你的回答,不过我对index使用了很多参数,-1,0,200,等等都试过了,还是没有用,是不是因为tiny6410的usb摄像头挂在在/dev/video2下面引起的错误!不知道我的想法对不对!我是新手,望您能够指教指教!
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2011-11-13 09:52
如果设备节点是/dev/video2, index可以用2或者-1. 从打印出来的crash信息看,问题出在s3c-fimc驱动的s3c_fimc_open()函数里的mutex_lock()上,看起来像是试图去操作不存在或未初始化的数据结构造成的。你用的是哪个内核?
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 55229
精华: 0
发帖: 86
金钱: 435 两
威望: 87 点
贡献值: 0 点
综合积分: 172 分
注册时间: 2011-09-14
最后登录: 2013-03-11
4楼  发表于: 2011-11-13 12:22

 回 3楼(kasim) 的帖子

我用的是tiny6410自带的linux2.6.38的内核!
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
5楼  发表于: 2011-11-13 14:09
友善之臂没有提供光盘上的linux 2.6.38里s3c-fimc模块源代码,我想你最好把帖子发到官方技术支持版块或者自己找一个开源的实现。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 55229
精华: 0
发帖: 86
金钱: 435 两
威望: 87 点
贡献值: 0 点
综合积分: 172 分
注册时间: 2011-09-14
最后登录: 2013-03-11
6楼  发表于: 2011-11-13 14:43

 回 5楼(kasim) 的帖子

好的,多谢了! ,我试试!
级别: 新手上路
UID: 62657
精华: 0
发帖: 15
金钱: 80 两
威望: 16 点
贡献值: 0 点
综合积分: 30 分
注册时间: 2012-02-05
最后登录: 2013-06-22
7楼  发表于: 2012-03-20 21:09

 回 1楼(kasim) 的帖子

你好,我现在也遇到了像你这篇帖子所说的问题,请问你是怎样解决的,可以贴出来吗,谢谢了!
级别: 新手上路
UID: 83716
精华: 0
发帖: 12
金钱: 65 两
威望: 13 点
贡献值: 0 点
综合积分: 24 分
注册时间: 2012-12-11
最后登录: 2014-03-19
8楼  发表于: 2013-03-26 15:12
可以用V4L2采集视频咯
级别: 新手上路
UID: 88222
精华: 0
发帖: 13
金钱: 65 两
威望: 13 点
贡献值: 0 点
综合积分: 26 分
注册时间: 2013-03-06
最后登录: 2013-09-11
9楼  发表于: 2013-03-28 15:04
你的可以采集640*480么,哥们?我的只能用320*240,640*480就报错,segmentation fault!