Example #1
0
    def __init__(self, *args, **kwds):
        Module.__init__(self, *args, **kwds)
        SnapshotPanel2.__init__(self, *args, **kwds)

        self.pics = self._panel['snapshot'].pics
        self._panel['snapshot'].image_listW = self.image_list
        self.image_list.AssignImageList(self._panel['snapshot'].list,
                                        wx.IMAGE_LIST_NORMAL)
        self.video_device = self._config.get('webcam', 'port')
        self.webcam = WebcamControl(self, self.video_device[-1])
        self.ds = dicom_rxbox.RDicom()
        self.dicom_filelist = []
        self.patientpanel = self._panel['patientinfo']
        self.dicom_filename = ''

        self.load_image = self._panel['snapshot'].load_image
        self.remove_image = self._panel['snapshot'].remove_image
Example #2
0
 def __init__(self, *args, **kwds):
     Module.__init__(self, *args, **kwds)
     SnapshotPanel2.__init__(self, *args, **kwds)
     
     self.pics = self._panel['snapshot'].pics
     self._panel['snapshot'].image_listW = self.image_list
     self.image_list.AssignImageList(self._panel['snapshot'].list, wx.IMAGE_LIST_NORMAL)
     self.video_device = self._config.get('webcam','port')
     self.webcam = WebcamControl(self, self.video_device[-1])
     self.ds=dicom_rxbox.RDicom()
     self.dicom_filelist=[]    
     self.patientpanel = self._panel['patientinfo']
     self.dicom_filename = ''
     
     self.load_image = self._panel['snapshot'].load_image
     self.remove_image = self._panel['snapshot'].remove_image
Example #3
0
 def __init__(self, *args, **kwds):
     SnapshotPanel2.__init__(self, *args, **kwds)
     self._frame = args[0]
     self._engine = self._frame._engine
     self._config = self._engine._config
     self._panel = self._frame._panel
     
     self.pics = self._panel['snapshot'].pics
     self.list = wx.ImageList(100,70, True)
     self.image_list.AssignImageList(self.list, wx.IMAGE_LIST_NORMAL)
     self._panel['snapshot'].list2 = self.list
     self._panel['snapshot'].image_list2 = self.image_list
     self.list2 = self._panel['snapshot'].list
     self.image_list2 = self._panel['snapshot'].image_list
     self.video_device = '/dev/video0'
     self.webcam = WebcamControl(self, self.video_device[-1])
Example #4
0
class SnapshotWindow(Module, SnapshotPanel2):
    def __init__(self, *args, **kwds):
        Module.__init__(self, *args, **kwds)
        SnapshotPanel2.__init__(self, *args, **kwds)
        
        self.pics = self._panel['snapshot'].pics
        self._panel['snapshot'].image_listW = self.image_list
        self.image_list.AssignImageList(self._panel['snapshot'].list, wx.IMAGE_LIST_NORMAL)
        self.video_device = self._config.get('webcam','port')
        self.webcam = WebcamControl(self, self.video_device[-1])
        self.ds=dicom_rxbox.RDicom()
        self.dicom_filelist=[]    
        self.patientpanel = self._panel['patientinfo']
        self.dicom_filename = ''
        
        self.load_image = self._panel['snapshot'].load_image
        self.remove_image = self._panel['snapshot'].remove_image

    def __name__(self):
        return 'Snapshot'
        
    def Start(self):
        self.webcam.close_phone()
        self.webcam.init_phone()
        self._logger.info('Start')
       
    def OnSnapshot(self, event): # wxGlade: SnapshotPanel2.<event_handler>
        """Main function for taking images
            - Closes linphone to access device
            - Takes image using v4lctl module
            - Converts jpeg file to bitmap
            - Displays bmp to wx panel
        """ 
        self.webcam.close_phone()
        tnow = datetime.now()
        tnow = tnow.strftime("%Y_%m_%d_%H_%M_%S")+("_%s"%tnow.microsecond.__str__().replace('.',''))
        self.process_config(tnow)
        os.system("python Modules/Snapshot/camera.py")
        self.load_image("Pictures/%s.jpg"%(tnow))
        self.dicom_filelist.append("Pictures/%s.jpg"%(tnow))
        self._logger.info('Picture %s taken'%tnow)
        self.webcam.init_phone()

    def OnDelete(self, event): # wxGlade: SnapshotPanel.<event_handler>
        itemIndex = -1
        while True:
            itemIndex = self.image_list.GetNextItem(-1,
                                         wx.LIST_NEXT_ALL,
                                         wx.LIST_STATE_SELECTED)
            if itemIndex == -1: break
            else:
                os.system('rm "%s"'%self.pics[itemIndex])
                self._logger.info("Deleted: %s"%self.pics[itemIndex])
                self.remove_image(itemIndex)
                count = 0

    def process_config(self, tnow):
        filename = tnow + '.jpg'
        pathname = '%s/Modules/Snapshot/webcam.cfg'%os.getcwd()
        config = ConfigParser.ConfigParser()
        config.read(pathname)
        config.set('ftp', 'file', filename)
        config.set('ftp', 'dir', '%s/Pictures'%os.getcwd())
        print filename
        print config.get('ftp', 'file')
        
        with open(pathname, 'wb') as configfile:
            config.write(configfile)   

    def generate_dicom(self,files):
        self._logger.info('DICOM Generate')
        if self.ds.test_dicom():
            self._logger.info('DICOM Test Passed!!!')
            for x in files:
                self.ds.add_picture(x)
            tnow = datetime.now()
            tnow = tnow.strftime("%Y_%m_%d_%H_%M_%S")+("_%s"%tnow.microsecond.__str__().replace('.',''))
            #bday = '.'.join([str(self.patientpanel.BirthMonth.GetSelection() + 1), str(self.patientpanel.BirthDayCombo.GetSelection() + 1),) 
            bday=str(self. patientpanel.BirthYear.GetValue())+str(self.patientpanel.BirthMonth.GetSelection() + 1).zfill(2)+str(self.patientpanel.BirthDayCombo.GetSelection() + 1).zfill(2)
            print bday
            self.dicom_filename = "DICOM/%s.dcm"%(tnow)
            self.ds.save_picture("DICOM/%s.dcm"%(tnow),str(self.patientpanel.LastNameValue.GetValue()),str(self.patientpanel.FirstNameValue.GetValue()),\
                                str(self.patientpanel.MiddleNameValue.GetValue()),bday,str(self.patientpanel.GenderCombo.GetValue()),\
                                str(self.patientpanel.AddressValue.GetValue()))
        
    def OnPaneClose(self):
        """Main function for closing the program
            - Closes Linphone
            - Destroys current frame
        """
        if self.dicom_filelist!=[]:
            self.generate_dicom(self.dicom_filelist)

        self.webcam.close_phone()
        self._logger.info('Stop')
Example #5
0
class SnapshotWindow(SnapshotPanel2):
    def __init__(self, *args, **kwds):
        SnapshotPanel2.__init__(self, *args, **kwds)
        self._frame = args[0]
        self._engine = self._frame._engine
        self._config = self._engine._config
        self._panel = self._frame._panel
        
        self.pics = self._panel['snapshot'].pics
        self.list = wx.ImageList(100,70, True)
        self.image_list.AssignImageList(self.list, wx.IMAGE_LIST_NORMAL)
        self._panel['snapshot'].list2 = self.list
        self._panel['snapshot'].image_list2 = self.image_list
        self.list2 = self._panel['snapshot'].list
        self.image_list2 = self._panel['snapshot'].image_list
        self.video_device = '/dev/video0'
        self.webcam = WebcamControl(self, self.video_device[-1])

    def Start(self):
        self.webcam.close_phone()
        self.webcam.init_phone()   
        
    def load_image(self, name):
        img = wx.Bitmap(name, wx.BITMAP_TYPE_ANY)
        size = img.GetSize() 
        image = wx.ImageFromBitmap(img)
        image = image.Rescale(size[0]*70/size[1], 70, wx.IMAGE_QUALITY_HIGH)
        img = wx.BitmapFromImage(image)
        
        self.pics.append(name)
        il_max = self.list.Add(img)
        il_max2 = self.list2.Add(img)
        self.image_list.InsertImageStringItem(len(self.pics)-1,'', len(self.pics)-1)
        self.image_list2.InsertImageStringItem(len(self.pics)-1,'', len(self.pics)-1)
        
    def OnSnapshot(self, event): # wxGlade: SnapshotPanel2.<event_handler>
        """Main function for taking images
            - Closes linphone to access device
            - Takes image using v4lctl module
            - Converts jpeg file to bitmap
            - Displays bmp to wx panel
        """ 
        self.webcam.close_phone()
        tnow = datetime.now()
        tnow = tnow.strftime("%Y_%m_%d_%H_%M_%S")+("_%s"%tnow.microsecond.__str__().replace('.',''))
        os.system("v4lctl -c %s snap jpeg 176x144 Pictures/%s.jpg"%(self.video_device,tnow))
        self.load_image("Pictures/%s.jpg"%(tnow))
        self.webcam.init_phone()

    def OnDelete(self, event): # wxGlade: SnapshotPanel2.<event_handler>
        itemIndex = -1
        count = 0
        while True:
            itemIndex = self.image_list.GetNextItem(itemIndex,
                                         wx.LIST_NEXT_ALL,
                                         wx.LIST_STATE_SELECTED)
            if itemIndex == -1:
                count += 1
                if count == 2:
                    break
            else:
                print "Deleted: %s"%self.pics[itemIndex]
                os.system('rm "%s"'%self.pics[itemIndex])
                self.image_list.DeleteItem(itemIndex)
                self.image_list2.DeleteItem(itemIndex)
                del self.pics[itemIndex]
                count = 0
        
    def OnPaneClose(self):
        """Main function for closing the program
            - Closes Linphone
            - Destroys current frame
        """
        self.webcam.close_phone()
Example #6
0
class SnapshotWindow(Module, SnapshotPanel2):
    def __init__(self, *args, **kwds):
        Module.__init__(self, *args, **kwds)
        SnapshotPanel2.__init__(self, *args, **kwds)

        self.pics = self._panel['snapshot'].pics
        self._panel['snapshot'].image_listW = self.image_list
        self.image_list.AssignImageList(self._panel['snapshot'].list,
                                        wx.IMAGE_LIST_NORMAL)
        self.video_device = self._config.get('webcam', 'port')
        self.webcam = WebcamControl(self, self.video_device[-1])
        self.ds = dicom_rxbox.RDicom()
        self.dicom_filelist = []
        self.patientpanel = self._panel['patientinfo']
        self.dicom_filename = ''

        self.load_image = self._panel['snapshot'].load_image
        self.remove_image = self._panel['snapshot'].remove_image

    def __name__(self):
        return 'Snapshot'

    def Start(self):
        self.webcam.close_phone()
        self.webcam.init_phone()
        self._logger.info('Start')

    def OnSnapshot(self, event):  # wxGlade: SnapshotPanel2.<event_handler>
        """Main function for taking images
            - Closes linphone to access device
            - Takes image using v4lctl module
            - Converts jpeg file to bitmap
            - Displays bmp to wx panel
        """
        self.webcam.close_phone()
        tnow = datetime.now()
        tnow = tnow.strftime("%Y_%m_%d_%H_%M_%S") + (
            "_%s" % tnow.microsecond.__str__().replace('.', ''))
        self.process_config(tnow)
        os.system("python Modules/Snapshot/camera.py")
        self.load_image("Pictures/%s.jpg" % (tnow))
        self.dicom_filelist.append("Pictures/%s.jpg" % (tnow))
        self._logger.info('Picture %s taken' % tnow)
        self.webcam.init_phone()

    def OnDelete(self, event):  # wxGlade: SnapshotPanel.<event_handler>
        itemIndex = -1
        while True:
            itemIndex = self.image_list.GetNextItem(-1, wx.LIST_NEXT_ALL,
                                                    wx.LIST_STATE_SELECTED)
            if itemIndex == -1: break
            else:
                os.system('rm "%s"' % self.pics[itemIndex])
                self._logger.info("Deleted: %s" % self.pics[itemIndex])
                self.remove_image(itemIndex)
                count = 0

    def process_config(self, tnow):
        filename = tnow + '.jpg'
        pathname = '%s/Modules/Snapshot/webcam.cfg' % os.getcwd()
        config = ConfigParser.ConfigParser()
        config.read(pathname)
        config.set('ftp', 'file', filename)
        config.set('ftp', 'dir', '%s/Pictures' % os.getcwd())
        print filename
        print config.get('ftp', 'file')

        with open(pathname, 'wb') as configfile:
            config.write(configfile)

    def generate_dicom(self, files):
        self._logger.info('DICOM Generate')
        if self.ds.test_dicom():
            self._logger.info('DICOM Test Passed!!!')
            for x in files:
                self.ds.add_picture(x)
            tnow = datetime.now()
            tnow = tnow.strftime("%Y_%m_%d_%H_%M_%S") + (
                "_%s" % tnow.microsecond.__str__().replace('.', ''))
            #bday = '.'.join([str(self.patientpanel.BirthMonth.GetSelection() + 1), str(self.patientpanel.BirthDayCombo.GetSelection() + 1),)
            bday = str(self.patientpanel.BirthYear.GetValue()) + str(
                self.patientpanel.BirthMonth.GetSelection() + 1).zfill(
                    2) + str(self.patientpanel.BirthDayCombo.GetSelection() +
                             1).zfill(2)
            print bday
            self.dicom_filename = "DICOM/%s.dcm" % (tnow)
            self.ds.save_picture("DICOM/%s.dcm"%(tnow),str(self.patientpanel.LastNameValue.GetValue()),str(self.patientpanel.FirstNameValue.GetValue()),\
                                str(self.patientpanel.MiddleNameValue.GetValue()),bday,str(self.patientpanel.GenderCombo.GetValue()),\
                                str(self.patientpanel.AddressValue.GetValue()))

    def OnPaneClose(self):
        """Main function for closing the program
            - Closes Linphone
            - Destroys current frame
        """
        if self.dicom_filelist != []:
            self.generate_dicom(self.dicom_filelist)

        self.webcam.close_phone()
        self._logger.info('Stop')