Beispiel #1
0
    def processImages(self, image1):

        """
        The rest of the logic to stitch the image
        Args:
            image1: image from camera 1
        Returns:
            finalImage: image to be displayed to user to confirm it is correct
        """
        configCom = ConfigCommunicator()

        # Grabs skew info from config, and creates instance of ScannerCamera()

        skewObject = ScannerCamera(1)
        mtx, dist, newmtx = configCom.getSkew(1)
        skewObject.setSkewMtx(mtx, dist, newmtx)
        # Process board image
        image1 = skew_correction(image1, skewObject)

        # Grabs scale info from config
        dictionary = configCom.getScale()

        scale_detect = ScaleDetection()
        scale_detect.setScale(dictionary['x_scale'], dictionary['y_scale'], dictionary['units'])


        #finalImage = stitch_images(image1, image2)
        finalImage = image1
        cv2.imwrite('FinalImage.jpg', finalImage)
        contours, contourImage = find_contours(np.array(finalImage, dtype=np.uint8))
        xscale, yscale, units = get_scale(scale_detect)
        export_json(contours, xscale, yscale, units) #do I need to do something with return value?


        return contourImage #do we want to show the contours on this as well?
Beispiel #2
0
def skew_calibration(calibImages, camera_number, scanner_camera):
    """
    Calculate skew correction values
    Args:
        calibImages
        camera_number
    Returns:
        None
    """

    scanner_camera.setSkewCorrectionValues(calibImages)

    # Config file
    configCom = ConfigCommunicator()

    configCom.setSkew(scanner_camera.skew_mtx, scanner_camera.skew_dist, scanner_camera.skew_newcameramtx, camera_number)

    configCom.saveConfig()
Beispiel #3
0
def scale_calibration(scaleDetect, image, objx, objy, units):
    """
    calibrates the scale and saves to config file
    Args:
        scaleDetect (ScaleDetection):
        image: the calibration image
        objx: width of calibration object
        objy: height of calibration object
        units (string): units to use
    Returns:
        True on success, False on failure
    """
    configCom = ConfigCommunicator()

    success = scaleDetect.calibrate(image, objx, objy, units)

    dictionary = {'x_scale': str(scaleDetect.x_scale), 'y_scale': str(scaleDetect.y_scale), 'units': scaleDetect.units}

    configCom.setScale(dictionary)

    configCom.saveConfig()

    return success