本文整理汇总了Python中dataset.Dataset.makeRGBLabelFromInt方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.makeRGBLabelFromInt方法的具体用法?Python Dataset.makeRGBLabelFromInt怎么用?Python Dataset.makeRGBLabelFromInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.makeRGBLabelFromInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Labeller
# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import makeRGBLabelFromInt [as 别名]
class Labeller(wx.App):
def __init__(self, redirect=False, filename=None):
wx.App.__init__(self, redirect, filename)
self.frame = wx.Frame(None, title='Semi-Automatic Labeling ')
self.panel = wx.Panel(self.frame)
self.PhotoMaxSize = 240
self.dataSet = Dataset(images_dir="./data/kitti01/images/",labels_dir="./data/kitti01/labels")
self.labels = self.dataSet.labels.items()
self.images = self.dataSet.images.items()
labels_desc = self.dataSet.label_desc.values()
print labels_desc[0]
self.objects = [ label[0] for label in labels_desc]
self.labeldict = getmasks(self.labels[0][1])
print "Masks are ready"
print self.labeldict.values()
self.objects = list(set(self.objects))
print self.objects
self.current_frame = self.images[0][1]
self.next_frame = self.images[1][1]
rgb_label= self.dataSet.makeRGBLabelFromInt(self.labels[0][1])
ol = self.dataSet.overlayRGBonImage(rgb_label,self.images[0][1])
cv2.imwrite('ol.png',ol)
self.createWidgets()
self.frame.Show()
def onPropagate(self,event):
'''The workhorse function to experiement with. Replace propagate_label with propagate_label_xxx
where xxx is your experiment. '''
propagated_label = propagate_label.algo_gmm(self.current_frame,self.mask,self.next_frame)
cv2.imwrite('pimage.png',propagated_label)
def onComboSelect(self,event):
self.selected_obj = event.GetString()
print self.selected_obj
rgb_np = np.zeros((self.dataSet.rows,self.dataSet.cols,3))
self.mask = self.labeldict[self.selected_obj]
rgb_np[self.mask]=[0,255,0]
data = rgb_np
rescaled = (255.0 / data.max() * (data - data.min())).astype(np.uint8)
rgb_image = Image.fromarray(rescaled)
ol = self.dataSet.overlayRGBonImage(rescaled,self.images[0][1])
cv2.imwrite('ol.png',ol)
self.onView()
def createWidgets(self):
instructions = 'Select Data set directory'
img = wx.EmptyImage(self.dataSet.cols,self.dataSet.rows)
self.frame.Show()
self.wxCurrentFrame = wx.StaticBitmap(self.panel, wx.ID_ANY,wx.BitmapFromImage(img))
self.wxNextFrame = wx.StaticBitmap(self.panel, wx.ID_ANY,wx.BitmapFromImage(img))
#Creating holder to display labelled frame
#Browse button to select directory
#Currently the directories are hard-coded in dataset class
browseBtn = wx.Button(self.panel, label='Load')
browseBtn.Bind(wx.EVT_BUTTON, self.onBrowse)
#Propagate button to invoke labelling algorithm
labelBtn = wx.Button(self.panel, label='Propagate')
labelBtn.Bind(wx.EVT_BUTTON, self.onPropagate)
distros = ["12","3432"]
#Combo Box to select the object to be propagated
cb = wx.ComboBox(self.panel, pos=(50, 30), choices=self.objects)
cb.Bind(wx.EVT_COMBOBOX,self.onComboSelect)
print "Creating sizers.."
self.mainSizer = wx.BoxSizer(wx.VERTICAL)
self.cf_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.nf_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.buttonsizer = wx.BoxSizer(wx.HORIZONTAL)
self.cf_sizer.Add(self.wxCurrentFrame, 0, wx.ALL, 5)
self.nf_sizer.Add(self.wxNextFrame, 0, wx.ALL, 5)
self.buttonsizer.Add(browseBtn, 0, wx.ALL, 5)
self.buttonsizer.Add(cb,0,wx.ALL,5)
self.buttonsizer.Add(labelBtn,0,wx.ALL,5)
self.mainSizer.Add(self.cf_sizer, 0, wx.ALL, 5)
self.mainSizer.Add(self.buttonsizer, 0, wx.ALL| wx.EXPAND, 5)
self.mainSizer.Add(self.nf_sizer, 0, wx.ALL, 5)
self.panel.SetSizer(self.mainSizer)
self.mainSizer.Fit(self.frame)
self.panel.Layout()
print "Layout done"
def onBrowse(self, event):
"""
Browse for file
"""
self.onView()
#.........这里部分代码省略.........