本文整理匯總了Python中cv2.CV_LOAD_IMAGE_UNCHANGED屬性的典型用法代碼示例。如果您正苦於以下問題:Python cv2.CV_LOAD_IMAGE_UNCHANGED屬性的具體用法?Python cv2.CV_LOAD_IMAGE_UNCHANGED怎麽用?Python cv2.CV_LOAD_IMAGE_UNCHANGED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類cv2
的用法示例。
在下文中一共展示了cv2.CV_LOAD_IMAGE_UNCHANGED屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getGroundTruth
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_LOAD_IMAGE_UNCHANGED [as 別名]
def getGroundTruth(fileNameGT):
'''
Returns the ground truth maps for roadArea and the validArea
:param fileNameGT:
'''
# Read GT
assert os.path.isfile(fileNameGT), 'Cannot find: %s' % fileNameGT
full_gt = cv2.imread(fileNameGT, cv2.CV_LOAD_IMAGE_UNCHANGED)
#attention: OpenCV reads in as BGR, so first channel has Blue / road GT
roadArea = full_gt[:,:,0] > 0
validArea = full_gt[:,:,2] > 0
return roadArea, validArea
示例2: getImageFeatures
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_LOAD_IMAGE_UNCHANGED [as 別名]
def getImageFeatures(self, params):
try:
import cv2
import numpy as np
cv2_available = True
except ImportError:
cv2_available = False
# Disabling opencv for now
cv2_available = False
if 'url' in params:
data = requests.get(params['url'], verify=False).content
else:
data = str(cherrypy.request.body.read())
# Run Tika once
parsed = parser.from_buffer(data)
tika = {}
for (k, v) in parsed["metadata"].iteritems():
k = k.lower().replace(':', '_').replace(' ', '_').replace('-', '_')
tika[k] = v[0] if type(v) is list and len(v) else v
tika['content'] = parsed["content"]
if cv2_available:
file_bytes = np.asarray(bytearray(data), dtype=np.uint8)
image = cv2.imdecode(file_bytes, flags=cv2.CV_LOAD_IMAGE_UNCHANGED)
if image is not None:
if len(image.shape) < 3 or image.shape[2] == 1:
image = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB)
v = cv2.calcHist([image], [0, 1, 2], None, [8, 8, 8], [0, 256, 0, 256, 0, 256])
v = v.flatten()
hist = v / sum(v)
tika['histogram'] = hist.tolist()
tika['sha1sum_s_md'] = hashlib.sha1(bytearray(data)).hexdigest()
return tika
示例3: read_kitti_png_file
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_LOAD_IMAGE_UNCHANGED [as 別名]
def read_kitti_png_file(flow_file):
# print flow_file
flow_img = cv2.imread(flow_file, cv2.CV_LOAD_IMAGE_UNCHANGED)
flow_img = flow_img.astype(float)
# print flow_img.shape
flow_data = np.zeros(flow_img.shape, dtype = np.float)
flow_data[:, :, 0] = (flow_img[:, :, 2] - 2 ** 15) / 64.0
flow_data[:, :, 1] = (flow_img[:, :, 1] - 2 ** 15) / 64.0
flow_data[:, :, 2] = flow_img[:, :, 0]
return flow_data