Beispiel #1
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()
Beispiel #2
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)
Beispiel #3
0
import numpy as np
import cv2

from Classes import ImgReader, CubeBase, ValidateClass, ColorReader

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)
Beispiel #4
0
from Classes import ImgReader, CubeBase, ColorReader

# conditions=["cube1_dark","cube1_light","cube2_light","cube2_right_light","cube2_up_light"]
conditions = ["cube2_light"]
feature = "hsv"
for condition in conditions:
    picture_path = './pictures/' + condition + '/'
    label_name = './labels/' + condition + '_label.npy'
    feature_file = './labels/' + condition + '_' + feature + '_feature.csv'
    roi_path = picture_path + 'rois/'
    print("The condition is %s" % (condition))
    cv2.namedWindow("img")
    counter = 0
    img_reader = ImgReader(picture_path, label_name)
    cube = CubeBase()
    img = img_reader.update(counter)
    color_reader = ColorReader(feature_file)
    color_img = color_reader.update(counter)

    while True:
        # hist=calSoftHist(img_reader.colors[count])
        # drawHist(hist)
        cv2.imshow('img', img)
        cv2.imshow('color_img', color_img)
        key = cv2.waitKey(1)
        if key == 27:
            break
        if (key == ord('n')):
            try:
                counter += 1
Beispiel #5
0
import numpy as np
import cv2

from Classes import ImgReader, CubeBase, ValidateClass, ColorReader

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.update(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)
Beispiel #6
0
from Classes import ImgReader, CubeBase
conditions = [
    "cube1_dark", "cube1_light", "cube2_light", "cube2_right_light",
    "cube2_up_light"
]
for condition in conditions:
    features = "all"
    picture_path = './pictures/' + condition + '/'
    label_name = './labels/' + condition + '_label.npy'
    # feature_file='./labels/'+condition+'_'+features+'_feature.csv'
    feature_file = './labels/' + "feature_" + condition + '.csv'
    roi_path = picture_path + 'rois/'
    cv2.namedWindow("img")
    counter = 0
    img_reader = ImgReader(picture_path, label_name)
    cube = CubeBase()
    img = img_reader.update(counter)
    cube.saveFeatures(img, feature_file, counter, features)
    cv2.imwrite(roi_path + str(counter) + '.jpg', img)
    counter += 1
    try:
        while True:
            # hist=calSoftHist(img_reader.colors[count])
            # drawHist(hist)
            cv2.imshow('img', img)
            key = cv2.waitKey(1)
            if key == 27:
                break
            if (key == ord('n')):
                print('save %d features' % (counter))
                img = img_reader.update(counter)