zoukankan      html  css  js  c++  java
  • cv.Split[转]

    Trouble spliting RGB image into its 3 channels with cvSplit Hi Doug, Maybe you have already sorted this out. I just ran into the same problem and I was just going to add to this when I figured out the solution. 

    In the new 2.1 python bindings you get a bit of a hint about what is happening. the Error raised is OpenCV Error: Assertion failed (dvec[j].size() == src.size() && dvec[j].depth() == src.depth() && dvec[j].channels() == 1 && i < src.channels()) in cvSplit, file /build/buildd/opencv-2.1.0/src/cxcore/cxconvert.cpp, line 877 Traceback (most recent call last): File "channels.py", line 30, in cv.Split(p, ch[0], ch[1], ch[2], ch[3]) cv.error: dvec[j].size() == src.size() && dvec[j].depth() == src.depth() && dvec[j].channels() == 1 && i < src.channels() 

    This is the problem bit for us. dvec[j].channels() == 1 && i < src.channels() Checking the source of cxconvert.cpp you can see that checks that the arrays you are giving to the function have * 1 channel only * that the number of these arrays is not greater than the number of channels in the image. The problem is that the image I was loading only had 3 channels but cv.Split is able to take 4, so we gave it 4. cvSplit(self.image,self.chan_imgs[0],self.chan_imgs[1],self.chan_imgs[2],self.ch\ an_imgs[3]) If you change the last argument to None (only giving 3 arrays for 3 channels) then your code should run ok. cvSplit(self.image,self.chan_imgs[0],self.chan_imgs[1],self.chan_imgs[2],None) Hope thats useful to you and others In hind-sight this information is in the API documentation as well http://opencv.willowgarage.com/documentation/python/operations_on_arrays.html?hi\ ghlight=split#Split

  • 相关阅读:
    scrapy爬取某网站,模拟登陆过程中遇到的那些坑
    Linux平台安装MongoDB
    Oracle HAVING子句
    oracle查找重复记录-转
    PLSQL存储过程(基础篇)-转
    oracle for update和for update nowait的区别
    Oracle两个数据库互相访问,DBLink使用-转
    中国人素质低的根本原因
    威胁李嘉诚是愚蠢的
    回归农村,这才是我想要的生活
  • 原文地址:https://www.cnblogs.com/justin_s/p/1893865.html
Copyright © 2011-2022 走看看