本文整理汇总了Python中cv2.COLOR_RGB2BGR属性的典型用法代码示例。如果您正苦于以下问题:Python cv2.COLOR_RGB2BGR属性的具体用法?Python cv2.COLOR_RGB2BGR怎么用?Python cv2.COLOR_RGB2BGR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在模块cv2的用法示例。
在下文中一共展示了cv2.COLOR_RGB2BGR属性的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __get_annotation__
点赞 7
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_RGB2BGR [as 别名]
def __get_annotation__(self, mask, image=None):
_, contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
segmentation = []
for contour in contours:
# Valid polygons have >= 6 coordinates (3 points)
if contour.size >= 6:
segmentation.append(contour.flatten().tolist())
RLEs = cocomask.frPyObjects(segmentation, mask.shape[0], mask.shape[1])
RLE = cocomask.merge(RLEs)
# RLE = cocomask.encode(np.asfortranarray(mask))
area = cocomask.area(RLE)
[x, y, w, h] = cv2.boundingRect(mask)
if image is not None:
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
cv2.drawContours(image, contours, -1, (0,255,0), 1)
cv2.rectangle(image,(x,y),(x+w,y+h), (255,0,0), 2)
cv2.imshow("", image)
cv2.waitKey(1)
return segmentation, [x, y, w, h], area
开发者ID:hazirbas,项目名称:coco-json-converter,代码行数:25,
示例2: undistort_images
点赞 6
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_RGB2BGR [as 别名]
def undistort_images(src, dst):
"""
undistort the images in src folder to dst folder
"""
# load dst, mtx
pickle_file = open("../camera_cal/camera_cal.p", "rb")
dist_pickle = pickle.load(pickle_file)
mtx = dist_pickle["mtx"]
dist = dist_pickle["dist"]
pickle_file.close()
# loop the image folder
image_files = glob.glob(src+"*.jpg")
for idx, file in enumerate(image_files):
print(file)
img = mpimg.imread(file)
image_dist = cv2.undistort(img, mtx, dist, None, mtx)
file_name = file.split("\\")[-1]
print(file_name)
out_image = dst+file_name
print(out_image)
image_dist = cv2.cvtColor(image_dist, cv2.COLOR_RGB2BGR)
cv2.imwrite(out_image, image_dist)
开发者ID:ChengZhongShen,项目名称:Advanced_Lane_Lines,代码行数:25,
示例3: wrap_images
点赞 6
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_RGB2BGR [as 别名]
def wrap_images(src, dst):
"""
apply the wrap to images
"""
# load M, Minv
img_size = (1280, 720)
pickle_file = open("../helper/trans_pickle.p", "rb")
trans_pickle = pickle.load(pickle_file)
M = trans_pickle["M"]
Minv = trans_pickle["Minv"]
# loop the file folder
image_files = glob.glob(src+"*.jpg")
for idx, file in enumerate(image_files):
print(file)
img = mpimg.imread(file)
image_wraped = cv2.warpPerspective(img, M, img_size, flags=cv2.INTER_LINEAR)
file_name = file.split("\\")[-1]
print(file_name)
out_image = dst+file_name
print(out_image)
# no need to covert RGB to BGR since 3 channel is same
image_wraped = cv2.cvtColor(image_wraped, cv2.COLOR_RGB2BGR)
cv2.imwrite(out_image, image_wraped)
开发者ID:ChengZhongShen,项目名称:Advanced_Lane_Lines,代码行数:25,
示例4: test
点赞 6
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_RGB2BGR [as 别名]
def test():
pickle_file = open("trans_pickle.p", "rb")
trans_pickle = pickle.load(pickle_file)
M = trans_pickle["M"]
Minv = trans_pickle["Minv"]
img_size = (1280, 720)
image_files = glob.glob("../output_images/undistort/*.jpg")
for idx, file in enumerate(image_files):
print(file)
img = mpimg.imread(file)
warped = cv2.warpPerspective(img, M, img_size, flags=cv2.INTER_LINEAR)
file_name = file.split("\\")[-1]
print(file_name)
out_image = "../output_images/perspect_trans/"+file_name
print(out_image)
# convert to opencv BGR format
warped = cv2.cvtColor(warped, cv2.COLOR_RGB2BGR)
cv2.imwrite(out_image, warped)
开发者ID:ChengZhongShen,项目名称:Advanced_Lane_Lines,代码行数:22,
示例5: save_result
点赞 6
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_RGB2BGR [as 别名]
def save_result(self):
path = os.path.abspath(self.image_file)
path, ext = os.path.splitext(path)
suffix = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
save_path = "_".join([path, self.method, suffix])
print('saving result to \n' % save_path)
if not os.path.exists(save_path):
os.mkdir(save_path)
np.save(os.path.join(save_path, 'im_l.npy'), self.model.img_l)
np.save(os.path.join(save_path, 'im_ab.npy'), self.im_ab0)
np.save(os.path.join(save_path, 'im_mask.npy'), self.im_mask0)
result_bgr = cv2.cvtColor(self.result, cv2.COLOR_RGB2BGR)
mask = self.im_mask0.transpose((1, 2, 0)).astype(np.uint8) * 255
cv2.imwrite(os.path.join(save_path, 'input_mask.png'), mask)
cv2.imwrite(os.path.join(save_path, 'ours.png'), result_bgr)
cv2.imwrite(os.path.join(save_path, 'ours_fullres.png'), self.model.get_img_fullres()[:, :, ::-1])
cv2.imwrite(os.path.join(save_path, 'input_fullres.png'), self.model.get_input_img_fullres()[:, :, ::-1])
cv2.imwrite(os.path.join(save_path, 'input.png'), self.model.get_input_img()[:, :, ::-1])
cv2.imwrite(os.path.join(save_path, 'input_ab.png'), self.model.get_sup_img()[:, :, ::-1])
开发者ID:junyanz,项目名称:interactive-deep-colorization,代码行数:25,
示例6: plotResults
点赞 6
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import COLOR_RGB2BGR [as 别名]
def plotResults(fname, result_list):
columm = []
for fig in result_list:
shape = fig.shape
fig = fig.numpy()
row = []
for idx in range(shape[0]):
item = fig[idx, :, :, :]
if item.shape[2] == 1:
item = np.concatenate([item, item, item], axis=2)
item = cv2.cvtColor(cv2.resize(item, (128, 128)), cv2.COLOR_RGB2BGR)
row.append(item)
row = np.concatenate(row, axis=1)
columm.append(row)
columm = np.concatenate(columm, axis=0)
img = np.uint8(columm *