sensor_number = 6 length = 9 #move의 숫자열 길이 move = [] #예시=[[0,1,0,0,1,0,0,1,1],[1,0,0,1,0,0,1,0,1]] tempmove = [] sensor = [] #예시=[[100,200],[200,300]] tempsensor = [] param = 0 count = 0 #관심영역의 총 픽셀 계산 basic_png = spm.start(area_of_interest_list, [], detect_range) basic_png.save_png() total_pixel_of_interest = cp.convert_return_count("image_test0.png") for i in range(sensor_number): sensor.append(msp.area(area_of_interest_list).propercordinate()) ''' print(sensor) sensor = [[100,200],[200,300]] tempsensor= [[200,100],[300,200]] print(total_pixel_of_interest) ''' basic_png.change_sensor(sensor) basic_png.save_png() count += 1 obj = cp.convert_return_count("image_test" + str(count) + ".png")
max_coverage_percent_section = 0 #센서 배치 함수 개수 section의 커버율 area_of_interest_center_coordinate = sa.getCenter( "image_test0.png") #무게중심 x,y 리스트 반환환 area_of_interest_getContour = sa.getContour( sensor_number, "image_test0.png") #윤곽선에 sensor_number만큼의 점을 뽑는거 area_of_interest_spliced_list = sa.splitList( area_of_interest_getContour, area_of_interest_list, area_of_interest_center_coordinate, sensor_number) #print(area_of_interest_spliced_list) sensor_list_xy = [] for i in area_of_interest_spliced_list: make_area_object = ma.area(i) sensor_list_xy.append(make_area_object.propercordinate()) #좌표 뽑기 print(sensor_list_xy) ''' for i in boundary_list: for k in range(0,sensor_number): #"area" + str(k) = msp.area(i) #areak.propercordinate() sensor_list = areak.makearea() while(max_coverage_percent != 100): for i in sensor_list: break
# 변수 max_coverage_percent = 0 # 가장 큰 커버율 -> 이 커버율이 100퍼센트가 되면 종료 max_coverage_percent_section = [0] # 센서 배치 함수 개수 section 의 커버율 count = 1 sensor_count = [] sensor_number = 6 tempobj_portion = 0 print(area_of_interest_list) #max(max_coverage_percent_section) <= 94 while len(max_coverage_percent_section) <= 7: sensor_list_xy = [] make_area_object = ma.area(area_of_interest_list) for i in range(0, sensor_number): sensor_list_xy.append(make_area_object.propercordinate()) # 좌표 뽑기 basic_png.change_polygon(sensor_list_xy) basic_png.save_png() obj = cp.convert_return_count("image_test" + str(count) + ".png") obj_portion = cp.convert_return_portion(obj, total_pixel_of_interest) print(obj_portion) if obj_portion >= tempobj_portion: tempobj_portion = obj_portion max_coverage_percent_section.append(tempobj_portion) sensor_count.append(count) print(count)