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

updata

parent 2e62281c
...@@ -293,13 +293,36 @@ class COCODemo(object): ...@@ -293,13 +293,36 @@ class COCODemo(object):
colors = self.compute_colors_for_labels(labels).tolist() colors = self.compute_colors_for_labels(labels).tolist()
img = None img = None
point_list = []
contour_max = []
max_len = 0
for mask, color in zip(masks, colors): for mask, color in zip(masks, colors):
thresh = mask[0, :, :, None] thresh = mask[0, :, :, None]
contours, hierarchy = cv2_util.findContours( contours, hierarchy = cv2_util.findContours(
thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE
) )
color = [0, 0, 0] 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: if img is None:
return return
...@@ -319,9 +342,11 @@ class COCODemo(object): ...@@ -319,9 +342,11 @@ class COCODemo(object):
# 把图片皮肤颜色变为白色 # 把图片皮肤颜色变为白色
# img = skin_to_white(img) # img = skin_to_white(img)
print(abc)
composite = img composite = img
return composite if not abc:
return
return composite, abc
def overlay_keypoints(self, image, predictions): def overlay_keypoints(self, image, predictions):
keypoints = predictions.get_field("keypoints") keypoints = predictions.get_field("keypoints")
......
...@@ -64,7 +64,20 @@ def img_to_three_color_map(source_path, target_path): ...@@ -64,7 +64,20 @@ def img_to_three_color_map(source_path, target_path):
print(target_path) print(target_path)
print(source_path) print(source_path)
img = cv2.imread(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: if composite is not None:
cv2.imwrite(target_path, composite) cv2.imwrite(target_path, composite)
# cam = cv2.VideoCapture(0) # cam = cv2.VideoCapture(0)
......
...@@ -16,21 +16,14 @@ def write_redis(source_path, target_path): ...@@ -16,21 +16,14 @@ def write_redis(source_path, target_path):
def main(): def main():
path = '/data/images/dataset_0523/' path = '/srv/apps/maskrcnn-benchmark/strangecrop/'
rs = os.walk(path) rs = os.listdir(path)
for a, b, files in rs: for r in rs:
if b == []: source_file = path + r
for file in files[:5000]: target_file = source_file.replace('crop', 'cropd')
dir = a.replace('dataset_0523', 'dataset_0523_first') write_redis(source_file, target_file)
fold = os.path.exists(dir) print(source_file, target_file)
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)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -3,7 +3,7 @@ from __future__ import absolute_import ...@@ -3,7 +3,7 @@ from __future__ import absolute_import
from celery import Celery from celery import Celery
import os import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1" os.environ["CUDA_VISIBLE_DEVICES"] = "3"
app = Celery('proj', include=['proj.tasks']) app = Celery('proj', include=['proj.tasks'])
app.config_from_object('proj.config') 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