def main():

    # Capture and
    image_capture = ImageCapture(dir_path=IMAGE_DIR_PATH, n_camera=2)
    image_capture.capture()

    image_path = image_capture.last_captured_path

    # Predict
    model_path = MODEL_PATH
    client = LocalPredictApiClient(model_path)
    pred_result = client.predict(image_path)

    # Save
    prediction_data = PredictionData(
        image_path=image_path,
        prediction=pred_result['prediction'],
        json_result=str(pred_result),
        capture_datetime_local=image_capture.capture_datetime_local,
        capture_datetime_utc=image_capture.capture_datetime_utc)

    prediction_ds = PredictionDataStore(DB_DIR_PATH)
    prediction_ds.save(prediction_data)
Beispiel #2
0
    if not os.path.exists(newpath):
        os.makedirs(newpath)
    imagefile = datafolder + filename + '.png'
    textfile = open(datafolder + filename + '.txt', 'a')

    file_operations.save_to_folder(textfile, imagefile, bounding_box, final)


# todo get classes through GUI
classes = []

#interface = CLI()
file_operations = FileOperations()
motor = MotorControl()
camera = ImageCapture(RPI_CAMERA)
image_processor = ImageProcessing(camera.capture())

delay = 1 / 1000.0
#images = input("How many images do you want per category (5 categories)?")
images = 10000
STEPS_FOR_FULL_CIRCLE = 12360
steps = int(STEPS_FOR_FULL_CIRCLE / images)
classes = ["Banana"]  #, "Rolle"]

only_snippets = False
only_train_images = True

## Section for the configuration
# Make images for every class
for label in classes:
    if only_train_images:
Beispiel #3
0
from image_capture import ImageCapture
from image_processing import ImageProcessing
import cv2
import numpy as np

camera = ImageCapture()
#camera = cv2.VideoCapture(0)
processor = ImageProcessing()

while True:
    img_raw = camera.capture()
    img_cut = img_raw[:,
                      int(np.shape(img_raw)[1] * 1 /
                          5):int(np.shape(img_raw)[1] * 4 / 5), :]
    img_gray = processor.gray(img_cut)
    edge = processor.canny(img_gray)
    contour = processor.max_contour(edge)
    cv2.drawContours(img_cut, contour, -1, (0, 255, 0), 3)
    bounding_box = processor.bounding_box(contour)
    print(bounding_box)
    #if bounding_box != -1:
    #    print("success!")
    #else:
    #    print("failure!")
    cv2.imshow('raw_image', img_raw)
    cv2.imshow('cut_image', img_cut)
    cv2.imshow('gray_image', img_gray)
    cv2.imshow('canny_image', edge)
    cv2.waitKey(20)