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. :)
jrcagle 77 Practically a Master Poster
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_wximage.html#wximage
http://docs.wxwidgets.org/stable/wx_wxbitmap.html#wxbitmap
karenmaye 0 Newbie Poster
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.
jlm699 320 Veteran Poster
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()
Re-posted with code tags.
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 ;)
jrcagle 77 Practically a Master Poster
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
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.