Example #1
0
def capture_images_count():
    """
    JSON requirements:
     - device-type
     - capture-count
    """

    data = request.get_json()

    # Ensure body data
    # TODO(jordanhuus): change to decorator
    if "capture-count" not in data.keys():
        abort(400, "Missing 'capture-count' data.")

    try:
        camera = Camera(camera_state=Camera.STATE_PENDING_CAPTURE)
        db.session.add(camera)
        db.session.commit()

        # Capture new image
        # TODO(jordanhuus): refactor to a simpler parameter set
        CaptureImage.multiple_captures(data["capture-count"], camera.id, db)

        return jsonify({"success": True, "camera-session-id": camera.id})
    except Exception as e:
        return jsonify({"success": False, "error": str(e)})
Example #2
0
	def find_one(self, id):
		response = requests.get("%s/%s" % (self.url, id))
		if(response.ok):
			data = response.json()
			if data is not None:
				return Camera(
					float(data["focalLength"]),
					float(data["height"]),
					np.array([data["aDistance"], data["bDistance"], data["cDistance"]], dtype=np.float64),
					np.array([
						[data["aX"], data["aY"]],
						[data["bX"], data["bY"]],
						[data["cX"], data["cY"]],
					], dtype=np.float64),
					[ Role(role["id"], role["description"], 
						[Action(action["id"], action["description"]) for action in role["actions"]]) for role in data["roles"]])
Example #3
0
from PyQt5.QtWidgets import QApplication
from view import loadUi_example
from model import Camera

if __name__ == '__main__':

    camera = Camera(0)
    app = QApplication([])
    start_window = loadUi_example(
        camera)  #loadUi_example is inheriting Camera class
    start_window.show()
    app.exit(app.exec_()
             )  # QApplication and this line are for creating infinite loop
    # In this case, the infinite loop is given by app.exec_(). If you remove that line, you will see that the program runs,
    # but nothing actually happens. . It is important to note that before defining any windows, you should always define the
    # application in which they are going to run.
Example #4
0
	def test_calibrate(self):
		calibrator = ImageLocatorCalibrator( camera=Camera(0.02,4.2,
			distances=np.array([1, 1.5, 2]),
			measures=np.array([[100, 200], [300, 400], [400, 300]])
		))
		np.testing.assert_allclose(calibrator.x, np.array([-0.14235033, 0.690983004, 4982.261536]), rtol=1e-6)