def __init__(self,
                 markerOrders=[7, 8],
                 defaultKernelSize=21,
                 scalingParameter=2500):
        # Initialize camera driver.
        # Open output window.
        cv.NamedWindow('filterdemo', cv.CV_WINDOW_AUTOSIZE)

        self.setFocus()
        # Select the camera where the images should be grabbed from.
        self.camera = cv.CaptureFromCAM(0)
        #self.setResolution()

        # Storage for image processing.
        self.currentFrame = None
        self.processedFrame = None
        self.running = True
        # Storage for trackers.
        self.trackers = []
        self.oldLocations = []

        # Initialize trackers.
        for markerOrder in markerOrders:
            temp = ImageAnalyzer(downscaleFactor=1)
            temp.addMarkerToTrack(markerOrder, defaultKernelSize,
                                  scalingParameter)
            self.trackers.append(temp)
            self.oldLocations.append(MarkerPose(None, None, None, None))

        self.cnt = 0
        self.defaultOrientation = 0
Exemplo n.º 2
0
 def display_image(self):
     indexes = self.table_view_sm.selectedIndexes()
     index = indexes[0]
     file_name = str(index.data())
     if (file_name.endswith("fits") or file_name.endswith("fit")):
         file_with_path = os.path.join(self.current_directory.cur_dir_path,
                                       file_name)
         self.im_disp = ImageAnalyzer(file_with_path, parent=self)
    def __init__(self, store_pics=False):
        self.cam = picamera.PiCamera()
        self.cam.resolution = (resolution['x'], resolution['y'])
        self.analyzer = ImageAnalyzer(adaptive_threshold=True)
        self.logger = Log.instance('TargetDetection')
        self.store_pics = store_pics

        if os.path.exists(dir_name):
            shutil.rmtree(dir_name)
        os.makedirs(dir_name)
def estimate_distances(pics_dir):
    analyzer = ImageAnalyzer()
    for (path, _, files) in os.walk(pics_dir):
        for f in sorted(files):
            pic = os.path.join(path, f)
            img = cv2.imread(pic)
            try:
                px, mm = analyzer.calculate_distance(img)
                logger.debug('distance: {:4d}px\t{:3.0f}mm'.format(px, mm))
            except Exception as e:
                logger.error(e)
Exemplo n.º 5
0
def main():
    print("***** Assignment 2 Initiated")
    analyzer = ImageAnalyzer(DATA_DIR, DEPS_DIR, OUTPUT_DIR)

    # ------------------------------------------------------------------------------------------------------------------
    # ---------------------------  SET PATH AND NAMES FOR ALL IMAGE TYPES
    # ------------------------------------------------------------------------------------------------------------------
    print("***** Importing and Undistorting/Demoscaicing Raw Images")
    image_names = []
    # image_names.append(['mono_left', 'mono_left'])
    # image_names.append(['mono_rear', 'mono_rear'])
    # image_names.append(['mono_right', 'mono_right'])
    # image_names.append(['stereo/centre', 'stereo'])
    image_names.append(['stereo/left', 'stereo'])
    # image_names.append(['stereo/right', 'stereo'])
    for name in image_names:
        analyzer.undistortImages(name[0], name[1])

    # ------------------------------------------------------------------------------------------------------------------
    # --------------------------- SAVE IMAGES
    # ------------------------------------------------------------------------------------------------------------------
    print("***** Saving Undistorted/Demoscaiced Images")
    # analyzer.saveImages()

    # ------------------------------------------------------------------------------------------------------------------
    # --------------------------- GENERATE 3D POINT CLOUDS FOR ENTIRE TIME PERIOD
    # ------------------------------------------------------------------------------------------------------------------
    print("***** Generating 3D Point Cloud")
    ptcloud_names = []
    ptcloud_names.append(['lms_front', 'gps/ins.csv'])
    # ptcloud_names.append(['lms_rear', 'gps/ins.csv'])
    # ptcloud_names.append(['ldmrs', 'gps/ins.csv'])
    # for name in ptcloud_names:
    #     analyzer.buildLidarPointCloud(name[0], name[1])

    # ------------------------------------------------------------------------------------------------------------------
    # ---------------------------  SAVE 3D POINT CLOUDS
    # ------------------------------------------------------------------------------------------------------------------
    print("***** Saving 3D Point Clouds")
    analyzer.saveRawLidarPointClouds()

    # ------------------------------------------------------------------------------------------------------------------
    # ---------------------------  PROJECT POINT CLOUDS ONTO IMAGES AND SAVE FIGURE
    # ------------------------------------------------------------------------------------------------------------------
    print("***** Projecting Point Clouds On Images")
    for cloud_type in ptcloud_names:
        for img_type in image_names:
            analyzer.showPointCloudsOnImages(img_type[0], cloud_type[0], cloud_type[1])

    print("***** Assignment 2 Complete")
def process(pics_dir, adaptive_threshold):
    analyzer = ImageAnalyzer(adaptive_threshold=adaptive_threshold)
    timings = []
    for (path, _, files) in os.walk(pics_dir):
        for f in sorted(files):
            pic = os.path.join(path, f)
            img = cv2.imread(pic)
            try:
                start = time.process_time()
                px, mm = analyzer.calculate_distance(img)
                end = time.process_time()
                timings.append(int((end - start) * 1000))
                logger.debug('distance: {:4d}px\t{:3.0f}mm'.format(px, mm))
            except Exception as e:
                logger.error(e)
    return timings
Exemplo n.º 7
0
    def __init__(self,
                 markerOrders=[7, 8],
                 defaultKernelSize=21,
                 scalingParameter=2500,
                 cameraDevice=0):
        # Initialize camera driver.
        # Open output window.
        #        cv.NamedWindow('filterdemo', cv.CV_WINDOW_AUTOSIZE)
        cv.NamedWindow('filterdemo', cv.CV_WINDOW_NORMAL)
        #        cv.NamedWindow('filterdemo', cv.CV_WINDOW_AUTOSIZE)
        cv.NamedWindow('temp_kernel', cv.CV_WINDOW_NORMAL)
        cv.NamedWindow('small_image', cv.CV_WINDOW_NORMAL)

        self.cameraDevice = cameraDevice

        # If an interface has been given to the constructor, it's a camdevice and we need to set some properties. If it's not, it means it's a file.
        if (isinstance(cameraDevice, numbers.Integral)):
            self.setFocus()
            # Select the camera where the images should be grabbed from.
            self.camera = cv.CaptureFromCAM(cameraDevice)
        else:
            self.camera = cv.CaptureFromFile(cameraDevice)
        self.setResolution()

        # Storage for image processing.
        self.currentFrame = None
        self.processedFrame = None
        self.running = True
        # Storage for trackers.
        self.trackers = []
        self.windowedTrackers = []
        self.oldLocations = []
        # Initialize trackers.
        for markerOrder in markerOrders:
            temp = ImageAnalyzer(downscaleFactor=1)
            temp.addMarkerToTrack(markerOrder, defaultKernelSize,
                                  scalingParameter)
            self.trackers.append(temp)
            self.windowedTrackers.append(
                TrackerInWindowMode(markerOrder, defaultKernelSize))
            self.oldLocations.append(MarkerPose(None, None, None, None))
        self.cnt = 0
        self.defaultOrientation = 0
Exemplo n.º 8
0
import os

from ImageAnalyzer import ImageAnalyzer
from plate_recognition_service.PlateRecognitionService import PlateRecognitionService

if __name__ == "__main__":
    character_recognition_model_path = f'{os.getcwd()}/models/svc/svc.pkl'

    image_analyzer = ImageAnalyzer(character_recognition_model_path,
                                   0.4,
                                   reset_between_predictions=True)
    service = PlateRecognitionService(image_analyzer).start(port=5000)
Exemplo n.º 9
0
ir_images_directory = scripts_directory.replace("/scripts", "/images/ir_images")
#ir_images_directory = "/Users/stoudenmiersh/OneDrive/DCIM/IR_Photos"
reports_directory = scripts_directory.replace("/scripts", "/reports")

outfile = open(reports_directory + "/ir_images.csv", 'w')

# looping through every image in the folder containing the images
for root, dirs, files in os.walk(ir_images_directory):
    if(len(dirs) == 0):
        temp_path = root
    for root2, dirs2, files2 in os.walk(temp_path):
        for f in files2:
            #counter+=1
            if (f[-3:].lower() == "jpg"):
            #if (f[-3:].lower() == "jpg" and counter % 10  == 0):   # only detects the file if it is a .jpg
                temp_analyzer = ImageAnalyzer(root2+"/"+f)
                x_values.append(counter)
                image_width = temp_analyzer.getImageWidth()
                image_height = temp_analyzer.getImageHeight()
                temp_analyzer.cropImage(int((7/16.0)*image_width), 0,
                                        int((9/16.0)*image_width), int((1/8.0)*image_height))
                y_values.append(temp_analyzer.getImageHls()[1])
                outfile.write(str(counter) + "," + str(temp_analyzer.getImageHls()[1]) + "\n")
                counter+=1
                print(str(counter) + "   " + root2+"/"+f + "         "+str(temp_analyzer.getImageHls()[1]))

    #plt.plot(x_values,y_values)

# Use polyfit.
#best_fit = polyfit(x_values, y_values, 3)
#polynomial = poly1d(best_fit)
Exemplo n.º 10
0
from ImageAnalyzer import ImageAnalyzer

imgAnalyzer = ImageAnalyzer('sample.png')
for c in imgAnalyzer.contourize():
    imgAnalyzer.analyzefigure(c)