How to display images simultaneously in wxPython?

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2009
Posts: 11
Reputation: karenmaye is an unknown quantity at this point 
Solved Threads: 0
karenmaye karenmaye is offline Offline
Newbie Poster

How to display images simultaneously in wxPython?

 
0
  #1
Feb 23rd, 2009
Hi, I found a code that displays multiple images but you have to supply its filename first before it can access it. Is there a way to display an image as soon as it is captured by the camera? The GUI that I am creating is going to be interfaced with a camera and I need to display the captured images as they arrive. Can someone please lend me a hand here? Big thanks and looking forward to learn from you.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 608
Reputation: jrcagle is on a distinguished road 
Solved Threads: 150
jrcagle jrcagle is offline Offline
Practically a Master Poster

Re: How to display images simultaneously in wxPython?

 
0
  #2
Feb 25th, 2009
Originally Posted by karenmaye View Post
Hi, I found a code that displays multiple images but you have to supply its filename first before it can access it. Is there a way to display an image as soon as it is captured by the camera? The GUI that I am creating is going to be interfaced with a camera and I need to display the captured images as they arrive. Can someone please lend me a hand here? Big thanks and looking forward to learn from you.
Your question is a little confusing. When I display an image, I make it into a wx.Image() object or a wx.Bitmap() object. It doesn't really matter whether it came from a file or not.

So ... can you post your code to help clarify what the issue is?

Jeff

P.S. Also, check out the docs for the Image and Bitmap classes:

http://docs.wxwidgets.org/stable/wx_...e.html#wximage
http://docs.wxwidgets.org/stable/wx_....html#wxbitmap
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 11
Reputation: karenmaye is an unknown quantity at this point 
Solved Threads: 0
karenmaye karenmaye is offline Offline
Newbie Poster

Re: How to display images simultaneously in wxPython?

 
0
  #3
Feb 26th, 2009
Here's the code:

import wx
import os


class MainWindow(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,"Agent-Based Model of Residential Development", size = (640, 480))
self.panel = wx.Panel(self,-1)
self.imageFile = "C:/Documents and Settings/12345/My Documents/Files/Misc/everythingisshit.jpg" # provide a diff file name in same directory/path
self.bmp = wx.Image(self.imageFile,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
self.bmp.bitmap = wx.StaticBitmap(self.panel, -1, self.bmp)
#self.bmp.bitmap.GetSize()
#self.SetSize(self.bmp.bitmap.GetSize())
#self.Center()

button42 = wx.Button(self.panel, -1, "Read", pos=(540,50))
self.Bind(wx.EVT_BUTTON, self.OnRead ,button42)

def OnRead(self,event):
self.imageFile1="D:/Say cheese!/vanity/iuhf.jpg" # you have to provide a diff image file name
self.bmp = wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()

self.obj = wx.StaticBitmap(self.panel, -1, self.bmp)
#self.obj.GetSize()
#self.SetSize(self.obj.GetSize())
#self.Center()
self.obj.Refresh()

if __name__ == "__main__":
app = wx.PySimpleApp()
MainWindow().Show()
app.MainLoop()

This displays the image after pressing the Read button but the first image still stays there. The new image just overlaps the previous one. What I want to do is to simultaneously display the image as it is being saved in a folder. How can I do this? Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,046
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 264
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: How to display images simultaneously in wxPython?

 
0
  #4
Feb 26th, 2009
  1. import wx
  2. import os
  3.  
  4.  
  5. class MainWindow(wx.Frame):
  6. def __init__(self):
  7. wx.Frame.__init__(self,None,-1,"Agent-Based Model of Residential Development", size = (640, 480))
  8. self.panel = wx.Panel(self,-1)
  9. self.imageFile = "C:/Documents and Settings/12345/My Documents/Files/Misc/everythingisshit.jpg" # provide a diff file name in same directory/path
  10. self.bmp = wx.Image(self.imageFile,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
  11. self.bmp.bitmap = wx.StaticBitmap(self.panel, -1, self.bmp)
  12. #self.bmp.bitmap.GetSize()
  13. #self.SetSize(self.bmp.bitmap.GetSize())
  14. #self.Center()
  15.  
  16. button42 = wx.Button(self.panel, -1, "Read", pos=(540,50))
  17. self.Bind(wx.EVT_BUTTON, self.OnRead ,button42)
  18.  
  19. def OnRead(self,event):
  20. self.imageFile1="D:/Say cheese!/vanity/iuhf.jpg" # you have to provide a diff image file name
  21. self.bmp = wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
  22.  
  23. self.obj = wx.StaticBitmap(self.panel, -1, self.bmp)
  24. #self.obj.GetSize()
  25. #self.SetSize(self.obj.GetSize())
  26. #self.Center()
  27. self.obj.Refresh()
  28.  
  29. if __name__ == "__main__":
  30. app = wx.PySimpleApp()
  31. MainWindow().Show()
  32. app.MainLoop()
Re-posted with code tags.
Originally Posted by karenmaye View Post
Here's the code:
Karen,

Please make use of code tags when posting in this forum. In order to use them, you must simply wrap your code as such:
[code=python]
# Your code goes in here
[/code]

Oh also, try not to use curse words (as per forum rules), even if they are inadvertently placed in your code
Last edited by jlm699; Feb 26th, 2009 at 9:39 am.
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 608
Reputation: jrcagle is on a distinguished road 
Solved Threads: 150
jrcagle jrcagle is offline Offline
Practically a Master Poster

Re: How to display images simultaneously in wxPython?

 
0
  #5
Feb 26th, 2009
OK, that makes sense. Here's what will happen:

In lines 9-10 of your current code, you read in an image from a file.

Instead, you will call your camera's "take a picture" method. It will return either (a) a bitmap, or (b) some kind of proprietary image, as an object.

If (a) then proceed directly to displaying the bitmap as in line 11.

If (b) then you'll need to poke around in the camera's module to find out how to convert the image into a bitmap. Then display as in line 11.

Hope it helps,
Jeff
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC