src/tcmalloc.cc:284] Attempt to free invalid pointer 0x7ff4821267d0 caffe VideoCapture Mac

7 篇文章 0 订阅

Mac同时调用cap = cv2.VideoCapture(0)和caffe出现src/tcmalloc.cc:284] Attempt to free invalid pointer 0x7ff4821267d0的问题解决

import cv2
def test():
    cap = cv2.VideoCapture(0)
    ret,frame = cap.read()
    print ret
    cap.release()
import caffe

出现错误:

src/tcmalloc.cc:284] Attempt to free invalid pointer 0x7ff4821267d0
而ubuntu下运行良好无错误。

解决办法:

  • import caffe放在顶部导入
import caffe
import cv2
def test():
    cap = cv2.VideoCapture(0)
    ret,frame = cap.read()
    print ret
    cap.release()

成功


解决过程记录:

import threading as th
def test():
    cap = cv2.VideoCapture(0)
    ret, frame = cap.read()
    print ret
    #cap.release()
def test2():
    import caffe
t1 = th.Thread(target = test)
t2 = th.Thread(target = test2)
t1.start()
t1.join()
t2.start()
t2.join()

运行错误,输出

src/tcmalloc.cc:284] Attempt to free invalid pointer 0x7f9847fdd240 
[Finished in 1.8s with exit code -6]
[shell_cmd: python -u "/Users/eclipsycn/Documents/caffe/ssd-face/testCapture.py"]
[dir: /Users/eclipsycn/Documents/caffe/ssd-face]
[path: /usr/local/opt/qt/bin:/Users/eclipsycn/anaconda2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public]

调换t1与t2顺序,

import threading as th
def test():
    cap = cv2.VideoCapture(0)
    ret, frame = cap.read()
    print ret
    #cap.release()
def test2():
    import caffe
t1 = th.Thread(target = test)
t2 = th.Thread(target = test2)
t2.start()
t2.join()
t1.start()
t1.join()

成功
单独调用ssd-caffe-face,crop人脸过程没问题,说明不是caffe问题,而单独使用identi也可以运行,identi加VideoCapture也可以运行,尝试注释掉plt,其实没效果。
可能由于调用摄像头后与caffe的cpu冲突?
在中途测试时还出现
no module named LabelMap

怀疑是caffe导入混乱

说明只是调用顺序问题,而怎样引起的这种冲突不明确。

mac调用摄像头 如果只有mac自带摄像头,则VideoCapture(0),如果接usb摄像头,usb摄像头序号为0,而自带摄像头序号为1.
mbp2017,i5 3.1Ghz,SSD-FACE的face detection接vgg16的face identification模型,19张运行39s,大约2s一张。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在编译Redis时,出现了"zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory"的错误。这个错误出现是因为编译器找不到jemalloc库的头文件,导致编译失败。 要解决这个问题,你可以按照以下步骤进行: 1. 确保你已经正确安装了jemalloc库。你可以从jemalloc的官方网站下载并按照安装指南进行安装。 2. 如果你已经安装了jemalloc库,但编译器仍然找不到头文件,那么可能是因为头文件的路径没有正确配置。你可以在编译Redis之前,通过设置环境变量或者修改编译选项的方式来指定头文件的路径。具体的做法取决于你使用的编译工具和操作系统。 3. 另外,你还可以尝试使用其他的内存分配器,如libc的malloc或者tcmalloc。这些内存分配器在大多数系统上都是默认可用的,可以通过修改Redis的配置文件或者编译选项来切换内存分配器。 总结起来,要解决"zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory"的错误,你可以通过安装jemalloc库、配置头文件路径或者切换其他内存分配器的方式来解决。希望这些方法对你有帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [redis编译报错:zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory](https://blog.csdn.net/qq_50247813/article/details/128866027)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [fatal error: boostdesc_bgm.i: No such file or directory补充文件](https://download.csdn.net/download/qq_26631621/44054087)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [编译redis的时候出现zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory问题...](https://blog.csdn.net/AZXHNLS81/article/details/104569746)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值