docs

jayrambhia edited this page Apr 23, 2012 · 3 revisions
Clone this wiki locally

class DisplayImage()

DisplayImage(winsize, imgsize, title)

Constructs gtk window and adds widgets
parameters:
   winsize - A tuple containing 2 integers to set window size
   imgsize - A tuple containing 2 integers to set image size
   title - A string for window title

win - gtk.Window()    
box - gtk.VBox()
image_box - gtk.EventBox()
img_gtk - gtk.Image()
img_pixbuf - gtk.gdk.pixbuf()
mouseX - x co-ordinate of the mouse in image_box (int)
mouseY - y co-ordinate of the mouse in image_box (int)
mouse_rawX - x co-ordinate of the mouse on the screen(but in the area of image_box) (int)
mouse_rawY - y co-ordinate of the mouse on the screen(but in the area of image_box) (int)
mouseLeft - Left mouse button pressed (bool)
mouseRight - Right mouse button pressed (bool)
mouseMiddle - Middle mouse button pressed (bool)
leftButtonDown - State of left mouse button (bool)
rightButtonDown - State of right mouse button (bool)
winsize - A tuple containing two integers. (width, height) of the window
imgsize - A tuple containing two integers. (width, height) of the image

Example:

display = DisplayImage((800,600),(320,240),"imagegtk")

####def show(image, imgsize) Creates a thread to show image and calls show_image

Parameters:
    image - cv2.cv.iplimage or iplimage or filename
    imgsize - A tuple containing 2 integers to set image size

Examples:

d = DisplayImage()

#SimpleCV
i = Image("lenna").toRGB().getBitmap()    
d.show(i,(320,240))

#OpenCV
im = LoadImage("python-logo.png")
image = CreateImage((im.width,im.height),im.depth,im.channels)
CvtColor(im,image,CV_BGR2RGB)
d.show(image)

#From file
d.show("python-logo.png",(512,512))

####def quit()

Destroys window and it's widgets.

Example:

d = DisplayImage()
d.show("python-logo.png")
time.sleep(3)
d.quit()

####def callback_quit(widget,event)

calls quit.This function must be called with a callback.

Example:

d = DisplayImage()
d.but = gtk.Button("quit")
d.but.connect("clicked",d.callback_quit)
d.box.pack_end(d.but,False,False,3)
d.but.show()

####def isDone()

Returns True or False depending on whether quit is called or not or if window exists or not

Example:

#SimpleCV
d = DisplayImage()
cam = Camera()
while not d.isDone():
    img = cam.getImage().toRGB().getBitmap()
    d.show(img)

####def change_title(title)

Changes the title of the window.
Parameters:            
    title - A string
    
Example:

d = DisplayImage(title="imagegtk")
d.change_title("my title")

####def change_size(size)

Changes the size of the window.
Parameter:
    size - a tuple containing 2 integers
    
Example:
    
d = DisplayImage(size=(800,600))
d.change_size((400,300))

####def set_image_size(size)

To set or change the size of the image.
    
Parameters:
   size - A tuple of two integers
        
Example:

#SimpleCV
display = DisplayImage()
i = Image("lenna")
display.show(i.toRGB().getBitmap)
display.set_image_size((400,300))
        
#OpenCV
display = DisplayImage()
im = LoadImage("filename.jpg")
image = CreateImage((im.width,im.height),im.depth,im.channels)
CvtColor(im,image,CV_BGR2RGB)
display.show(image)
display.set_image_size((400,300))

#From file
display = DisplayImage()
display.show("imagefile")
display.set_image_size((400,300))