本文整理汇总了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