Commit 51025ef9 authored by 吴升宇's avatar 吴升宇

updata

parent 2e62281c
......@@ -293,13 +293,36 @@ class COCODemo(object):
colors = self.compute_colors_for_labels(labels).tolist()
img = None
point_list = []
contour_max = []
max_len = 0
for mask, color in zip(masks, colors):
thresh = mask[0, :, :, None]
contours, hierarchy = cv2_util.findContours(
thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE
)
color = [0, 0, 0]
img = cv2.drawContours(image, contours, -1, color, 3)
#print(contours)
#print(len(contours))
print(type(contours))
for contour in contours:
print(len(contour))
if len(contour) > max_len:
max_len = len(contour)
contour_max = contours
color = [0, 0, 0]
import numpy as np
#np.array([contour_max])
abc = []
for i in contour_max:
for j in i:
abc.append(str(j[0][0])+'|' +str(j[0][1]))
print(len(abc))
#print(abc)
print('===================================')
img = cv2.drawContours(image, contour_max, -1, color, 3)
if img is None:
return
......@@ -319,9 +342,11 @@ class COCODemo(object):
# 把图片皮肤颜色变为白色
# img = skin_to_white(img)
print(abc)
composite = img
return composite
if not abc:
return
return composite, abc
def overlay_keypoints(self, image, predictions):
keypoints = predictions.get_field("keypoints")
......
......@@ -64,7 +64,20 @@ def img_to_three_color_map(source_path, target_path):
print(target_path)
print(source_path)
img = cv2.imread(source_path)
composite = coco_demo.run_on_opencv_image(img)
composite, point_list = coco_demo.run_on_opencv_image(img)
#print(point_list)
point = str(point_list)
point = point.replace('[', '')
point = point.replace(']', '')
point = point.replace("'", "")
point = point.replace(' ', '')
source = source_path.split('/')[-1]
point = point.replace(',', ' ')
point = point.replace('|', ',')
with open('/srv/apps/maskrcnn-benchmark/strangecropd/a.txt', 'a+') as f:
res = source + ' ' + point + '\n'
f.write(res)
if composite is not None:
cv2.imwrite(target_path, composite)
# cam = cv2.VideoCapture(0)
......
......@@ -16,21 +16,14 @@ def write_redis(source_path, target_path):
def main():
path = '/data/images/dataset_0523/'
rs = os.walk(path)
for a, b, files in rs:
if b == []:
for file in files[:5000]:
dir = a.replace('dataset_0523', 'dataset_0523_first')
fold = os.path.exists(dir)
if not fold:
os.mkdir(dir)
source_path = a + file
target_path = dir + file
print(source_path)
print(target_path)
#write_redis(source_path, target_path)
path = '/srv/apps/maskrcnn-benchmark/strangecrop/'
rs = os.listdir(path)
for r in rs:
source_file = path + r
target_file = source_file.replace('crop', 'cropd')
write_redis(source_file, target_file)
print(source_file, target_file)
if __name__ == '__main__':
......
......@@ -3,7 +3,7 @@ from __future__ import absolute_import
from celery import Celery
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
os.environ["CUDA_VISIBLE_DEVICES"] = "3"
app = Celery('proj', include=['proj.tasks'])
app.config_from_object('proj.config')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment