additional information "error: cvCreateMatFromGtkPixbuf"

7 views
Skip to first unread message

mahiroo

unread,
Nov 7, 2010, 9:17:22 PM11/7/10
to ctypes-opencv
Hi.
I sent a message "error: cvCreateMatFromGtkPixbuf" last night.
This mail is additional.
I informed two errors.
This mail says about second error "line 170 returns error when "width
%4!=0""

If you run below script, you can cofirm error happens.
*****************
import pyopencv
import gtk

x=0
y=0
##width=512
height=400

root = gtk.gdk.get_default_root_window()
for width in range(500,512):
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width,
height)
pixbuf.get_from_drawable(root, gtk.gdk.colormap_get_system(), x,
y, 0, 0, width, height)
try:
mat=pyopencv.interfaces.cvCreateMatFromGtkPixbuf(pixbuf)
print
'success',pixbuf.get_width(),pixbuf.get_width()*3 ,pixbuf.get_rowstride()
except:
print 'error
',pixbuf.get_width(),pixbuf.get_width()*3 ,pixbuf.get_rowstride()
*****************
This error is caused by difference between "pixbuf.get_width()*3" and
"pixbuf.get_rowstride()".
http://ubuntuforums.org/showthread.php?t=840893
So I set the width of pixbuf-image to multiples of 4 before using
"cvCreateMatFromGtkPixbuf" to cleared up that.
Reply all
Reply to author
Forward
0 new messages