本文整理汇总了Python中image.Image方法的典型用法代码示例。如果您正苦于以下问题:Python image.Image方法的具体用法?Python image.Image怎么用?Python image.Image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image.Image方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recognize
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def recognize(self, image):
logging.info("Getting image file")
image.get_image_file().seek(0)
client = boto3.client('rekognition')
r = client.recognize_celebrities(Image={"Bytes": image.get_image_file().read()})
logging.info("Face object returned: %s" % r)
face_obj = (r)
if ("CelebrityFaces" in face_obj and len(face_obj['CelebrityFaces']) > 0):
celeb_objs = face_obj['CelebrityFaces']
for obj in celeb_objs:
bounding_box = obj['Face']['BoundingBox']
image.add_face(
bounding_box['Left'],
bounding_box['Top'],
bounding_box['Width'],
bounding_box['Height'],
obj['MatchConfidence'],
obj['Name']
)
return image
示例2: load_pointpairs
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def load_pointpairs(self):
self.app.setOverrideCursor(qt.QCursor(qt.Qt.WaitCursor))
self.fitted_points_checkbox.setChecked(False)
self.overlay_checkbox.setChecked(False)
self.rebuild_image_gui()
newPP = pointpairs.PointPairs(str(self.pointpairs_load_name.currentText()),image=self.pointpicker.Image)
if self.cadmodel is not None:
newPP.machine_name = self.cadmodel.machine_name
newPP.image = self.pointpicker.Image
self.pointpicker.PointPairs = newPP
self.pointpicker.Image = newPP.image
self.pointpicker.Fitter.set_PointPairs(self.pointpicker.PointPairs)
self.pointpicker.UpdateFromPPObject(not self.pointpairs_clear_before_load.isChecked())
self.pointpairs_changed = False
self.fit_changed = False
self.app.restoreOverrideCursor()
示例3: update_current_points
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def update_current_points(self,object_coords,image_coords):
info_string = ''
if object_coords is not None and self.cadmodel is not None:
info_string = info_string + '<span style=" text-decoration: underline;">CAD Point<br></span>' + self.cadmodel.get_position_info(object_coords).replace('\n','<br>') + '<br><br>'
if image_coords is not None:
info_string = info_string + '<span style=" text-decoration: underline;">Image Point(s)</span><br>'
for i,point in enumerate(image_coords):
info_string = info_string + '( {:4.0f} , {:4.0f} ) px'.format(point[0],point[1]).replace(' ',' ')
if len(image_coords) > 1:
info_string = info_string + ' [' + self.image.field_names[i] + ']'.replace(' ',' ')
if image_coords.index(point) < len(image_coords) - 1:
info_string = info_string + '<br>'
if info_string == '':
info_string = 'None'
self.del_pp_button.hide()
else:
self.del_pp_button.show()
self.point_info_text.setText(info_string)
示例4: apply
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def apply(self):
if self.image.fieldmask.max() != self.splitfieldeditor.fieldmask.max():
self.parent.pointpicker.clear_all()
self.parent.use_chessboard_checkbox.setChecked(False)
self.parent.chessboard_pointpairs = None
self.chessboard_info.setText('No chessboard pattern images currently loaded.')
self.image.fieldmask = self.splitfieldeditor.fieldmask
self.image.n_fields = self.splitfieldeditor.fieldmask.max() + 1
if self.image.n_fields == 1:
self.image.field_names = ['Image']
else:
self.image.field_names = [str(namebox.text()) for namebox in self.field_names_boxes]
self.parent.pointpicker.init_image(self.image)
if self.parent.use_chessboard_checkbox.isChecked():
self.parent.toggle_chessboard_constraints(True)
self.parent.rebuild_image_gui()
self.parent.populate_pointpairs_list()
self.done(1)
示例5: undistort_image
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def undistort_image(self,image,coords=None):
if self.nfields > 1:
raise Exception('This feature is not supported for split-FOV images!')
imobj_out = None
if isinstance(image,CalCam_Image):
imobj_out = copy.deepcopy(image)
image = imobj_out.transform.original_to_display_image(imobj_out.data)
coords='display'
display_shape = self.transform.get_display_shape()
if coords is None:
coords = 'display'
if image.shape[0] != display_shape[1] or image.shape[1] != display_shape[0]:
if image.shape[0] == self.transform.y_pixels and image.shape[1] == self.transform.x_pixels:
coords = 'original'
else:
raise ValueError('Supplied image is the wrong shape! Expected {:d}x{:d} or {:d}x{:d} pixels.'.format(display_shape[0],display_shape[1],self.transform.x_pixels,self.transform.y_pixels))
if coords == 'original':
im = self.transform.original_to_display_image(image)
else:
im = image
im = cv2.undistort(im,self.fit_params[0].cam_matrix,self.fit_params[0].kc)
if coords == 'original':
im = self.transform.display_to_original_image(im)
if imobj_out is not None:
imobj_out.data = imobj_out.transform.display_to_original_image(im)
return imobj_out
else:
return im
# Class for storing the calibration results.
# Has methods for post-processing the results to give useful information
# and for loading and saving the results
示例6: save
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def save(self,savename):
# Make sure we have a copy of the image being used saved.
if self.image.name is None:
self.image.name = savename
self.image.save()
# Set the point pair set name to the save name
self.name = savename
savefile = open(os.path.join(paths.pointpairs,self.name + '.csv'),'wb')
csvwriter = csv.writer(savefile)
header = []
header.append(['CalCam Point Pairs File'])
header.append(['Machine:',self.machine_name])
header.append(['Image:',self.image.name])
header.append(['','',''])
header.append(["Machine X","Machine Y","Machine Z"])
for i in range(self.image.n_fields):
header[3] = header[3] + ['',"Field " + str(i),'']
header[4] = header[4] + ['',"Image X","Image Y"]
for headrow in header:
csvwriter.writerow(headrow)
for i in range(len(self.objectpoints)):
row = [self.objectpoints[i][0],self.objectpoints[i][1],self.objectpoints[i][2]]
for j in range(self.image.n_fields):
if self.imagepoints[i][j] is None:
row = row + ['','','']
else:
row = row + [''] + list(self.imagepoints[i][j])
csvwriter.writerow(row)
savefile.close()
示例7: load
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def load(self,savename):
savefile = open(os.path.join(paths.pointpairs,savename + '.csv'),'r')
csvreader = csv.reader(savefile)
# Read header info...
headrow = [None]
while headrow[0] != 'Machine X':
# Get the next header line
headrow = next(csvreader)
if headrow[0] == 'Machine:':
self.machine_name = headrow[1]
elif headrow[0] == 'Image:' and self.image is None:
try:
self.image = image.Image(headrow[1])
except:
print('[calcam.PointPairs] Cannot load image "' + headrow[1] + '" for these point pairs: ' + sys.exc_info()[1].__str__())
self.image = None
elif headrow[0] == 'Machine X':
self.n_fields = int(np.floor( (len(headrow) - 4) / 2.))
# Actually read the point pairs
self.imagepoints = []
self.objectpoints = []
for row in csvreader:
self.objectpoints.append((float(row[0]),float(row[1]),float(row[2])))
self.imagepoints.append([])
for field in range(self.n_fields):
if row[1 + (field+1)*3] != '':
self.imagepoints[-1].append( [float(row[1 + (field+1)*3]) , float(row[2 + (field+1)*3])] )
else:
self.imagepoints[-1].append(None)
self.name = savename
savefile.close()
示例8: load_mask_image
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def load_mask_image(self):
filedialog = qt.QFileDialog(self)
filedialog.setAcceptMode(0)
filedialog.setFileMode(1)
filedialog.setWindowTitle('Select Mask File')
filedialog.setNameFilter('Image Files (*.png *.bmp *.jp2 *.tiff *.tif)')
filedialog.setLabelText(3,'Load')
filedialog.exec_()
if filedialog.result() == 1:
mask_im = cv2.imread(str(filedialog.selectedFiles()[0]))
try:
self.splitfieldeditor.update_fieldmask(mask=mask_im)
except ValueError as e:
if 'wrong shape' in str(e):
dialog = qt.QMessageBox(self)
dialog.setStandardButtons(qt.QMessageBox.Ok)
dialog.setTextFormat(qt.Qt.RichText)
dialog.setWindowTitle('Calcam - wrong mask shape')
dialog.setText("Selected mask image is the wrong shape ({:d}x{:d}) for this camera image so cannot be used.".format(mask_im.shape[1],mask_im.shape[0]))
original_shape = np.array([self.image.data.shape[1],self.image.data.shape[0]])
display_shape = np.array(self.image.transform.get_display_shape())
if np.any(original_shape != display_shape):
dialog.setInformativeText("This image requires a field mask of either {:d}x{:d} or {:d}x{:d} pixels.".format(original_shape[0],original_shape[1],display_shape[0],display_shape[1]))
else:
dialog.setInformativeText("A field mask of {:d}x{:d} pixels is required.".format(original_shape[0],original_shape[1]))
dialog.setIcon(qt.QMessageBox.Warning)
dialog.exec_()
示例9: __init__
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def __init__(self, args):
"""ImageCollection constructor.
Args:
args: ImageCollections can be constructed from the following arguments:
1) A string: assumed to be the name of a collection,
2) An array of images, or anything that can be used to construct an
image.
3) A single image.
5) A computed object - reinterpreted as a collection.
Raises:
EEException: if passed something other than the above.
"""
self.initialize()
# Wrap single images in an array.
if isinstance(args, image.Image):
args = [args]
if ee_types.isString(args):
# An ID.
super(ImageCollection, self).__init__(
apifunction.ApiFunction.lookup('ImageCollection.load'), {'id': args})
elif isinstance(args, (list, tuple)):
# A list of images.
super(ImageCollection, self).__init__(
apifunction.ApiFunction.lookup('ImageCollection.fromImages'), {
'images': [image.Image(i) for i in args]
})
elif isinstance(args, ee_list.List):
# A computed list of images.
super(ImageCollection, self).__init__(
apifunction.ApiFunction.lookup('ImageCollection.fromImages'), {
'images': args
})
elif isinstance(args, computedobject.ComputedObject):
# A custom object to reinterpret as a ImageCollection.
super(ImageCollection, self).__init__(args.func, args.args, args.varName)
else:
raise ee_exception.EEException(
'Unrecognized argument type to convert to a ImageCollection: %s' %
args)
示例10: load_image
# 需要导入模块: import image [as 别名]
# 或者: from image import Image [as 别名]
def load_image(self,init_image=None):
self.app.setOverrideCursor(qt.QCursor(qt.Qt.WaitCursor))
self.statusbar.showMessage('Loading image...')
# Gather up the required input arguments from the image load gui
imload_options = []
for option in self.imload_inputs:
imload_options.append(option[1]())
if qt.qt_ver == 4:
if type(imload_options[-1]) == qt.QString:
imload_options[-1] = str(imload_options[-1])
newim = self.imsource(*imload_options)
self.image_settings.hide()
if self.overlay_checkbox.isChecked():
self.overlay_checkbox.setChecked(False)
self.pointpicker.fit_overlay_actor = None
self.tabWidget.setTabEnabled(3,False)
existing_im_names = paths.get_save_list('Images')
if newim.name in existing_im_names:
testim = image.Image(newim.name)
if not np.all(newim.data == testim.data):
i = 0
new_name = newim.name
while new_name in existing_im_names:
i = i + 1
new_name = newim.name + '({:d})'.format(i)
newim.name = new_name
self.image = newim
self.image_settings.show()
self.hist_eq_checkbox.setCheckState(qt.Qt.Unchecked)
self.pointpicker.init_image(self.image)
if self.raycaster.fitresults is not None:
self.raycaster.fitresults = None
self.impos_info.setText('Image position info will appear here.')
self.sightline_info.setText('Sightline info will appear here.')
self.impos_fieldnames.hide()
self.pupil_coords_label.hide()
self.calinfo_fieldnames.hide()
self.sightline_fieldnames.hide()
self.populate_fitresults_list()
self.pointpicker.clear_cursors_2D()
else:
self.populate_fitresults_list()
self.tabWidget.setTabEnabled(3,True)
self.update_image_info_string()
self.app.restoreOverrideCursor()
self.statusbar.clearMessage()