示例#1
0
class Controller():
    def __init__(self, condition='light'):
        self.condition = condition
        self.picture_path = './pictures/' + condition + '/'
        self.label_name = './labels/' + condition + '_label.npy'
        self.feature_file = './labels/' + condition + '_labels.csv'
        self.center_file = './labels/' + condition + '_center.npy'
        # self.counter=0
        self.img_reader = ImgReader(self.picture_path, self.label_name)
        self.center = CenterReader(self.center_file)
        self.cube = CubeBase()
        self.color_reader = ColorReader(self.feature_file)
        self.verifier = ValidateClass()

    def run(self, maxgroup=11):
        for i in range(maxgroup):
            # print("group:",i)
            img = self.img_reader.update(i)
            center = self.center.getCenter(i)
            # print(center)
            # result=self.cube.onlineUpdate(img,center)
            result = self.cube.test(img)
            self.color_reader.update(i)
            self.verifier.validate(i, result, self.color_reader.cur_labels)
        print("dataset:", self.condition)
        self.verifier.showResult(isALL=False)
示例#2
0
 def __init__(self,condition='light'):
     self.condition=condition
     self.picture_path='./pictures/'+condition+'/'
     self.label_name='./labels/'+condition+'_label.npy'
     self.feature_file='./labels/'+condition+'_labels.csv'
     # self.counter=0
     self.img_reader=ImgReader(self.picture_path,self.label_name)
     self.cube=CubeBase()
     self.color_reader=ColorReader(self.feature_file)
     self.verifier=ValidateClass()
示例#3
0
condition = 'light'
picture_path = './pictures/' + condition + '/'
label_name = './labels/' + condition + '_label.npy'
feature_file = './labels/' + condition + '_feature.csv'
# cv2.namedWindow("img")
counter = 0
#img_reader
img_reader = ImgReader(picture_path, label_name)
img = img_reader.update(counter)
#cube
cube = CubeBase()
result = cube.test(img)
result_img = cube.drawResult()
#color_reader
color_reader = ColorReader(feature_file)
color_img = color_reader.update()
#Verifier
verifier = ValidateClass()
verifier.validate(counter, result, color_reader.labels)
verifier.showResult()
counter += 1
cv2.imshow('img', img)
cv2.imshow('result', result_img)

while True:
    key = cv2.waitKey(1)
    if key == 27:
        break
    if (key == ord('n')):
        counter += 1
示例#4
0
import numpy as np
import cv2
from Classes import ColorReader
# conditions=['light','dark']
conditions=["cube1_dark","cube1_light","cube2_light","cube2_right_light","cube2_up_light"]
for condition in conditions:
    feature_file='./labels/'+condition+'_labels.csv'
    center_name="./labels/"+condition+"_center.npy"
    color_reader=ColorReader(feature_file)
    center_dict={}
    counter=0
    while True:
        try:
            group,centers=color_reader.readCenter(counter)
            center_dict[group]=centers
            counter+=1
        except:
            break
    np.save(center_name,center_dict)
    print("%s is writen!"%(center_name))