Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions pyro_camera_api/client/pyro_camera_api_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
from __future__ import annotations

import io
import logging
from typing import Any, Dict, List, Optional

import requests
from PIL import Image

logger = logging.getLogger(__name__)


class PyroCameraAPIClient:
def __init__(
Expand Down Expand Up @@ -174,21 +177,62 @@ def move_camera(
speed: int = 10,
pose_id: Optional[int] = None,
degrees: Optional[float] = None,
duration: Optional[float] = None,
zoom: int = 0,
) -> Dict[str, Any]:
if zoom > 0 and speed != 1:
logger.warning("zoom=%s > 0: speed will be forced to 1 server-side (requested %s)", zoom, speed)
params: Dict[str, Any] = {
"camera_ip": camera_ip,
"speed": speed,
"zoom": zoom,
}
if direction is not None:
params["direction"] = direction
if pose_id is not None:
params["pose_id"] = pose_id
if degrees is not None:
params["degrees"] = degrees
if duration is not None:
params["duration"] = duration

resp = self._request("POST", "/control/move", params=params)
return resp.json()

def click_to_move(
self,
camera_ip: str,
click_x: int,
click_y: int,
image_width: int,
image_height: int,
zoom: int = 0,
h_fov: Optional[float] = None,
v_fov: Optional[float] = None,
) -> Dict[str, Any]:
if zoom > 0:
logger.warning("click_to_move: zoom=%s > 0, speed will be limited to 1 server-side", zoom)
params: Dict[str, Any] = {
"camera_ip": camera_ip,
"click_x": click_x,
"click_y": click_y,
"image_width": image_width,
"image_height": image_height,
"zoom": zoom,
}
if h_fov is not None:
params["h_fov"] = h_fov
if v_fov is not None:
params["v_fov"] = v_fov

resp = self._request("POST", "/control/click_to_move", params=params, timeout=30.0)
return resp.json()

def get_speed_tables(self, camera_ip: str) -> Dict[str, Any]:
params = {"camera_ip": camera_ip}
resp = self._request("GET", "/control/speed_tables", params=params)
return resp.json()

def stop_camera(self, camera_ip: str) -> Dict[str, Any]:
resp = self._request("POST", f"/control/stop/{camera_ip}")
return resp.json()
Expand Down
182 changes: 182 additions & 0 deletions pyro_camera_api/pyro_camera_api/api/fov_tables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"h_fov": {
"reolink-823S2": [
54.2,
52.206,
50.405,
48.356,
46.167,
44.183,
42.63,
41.058,
39.117,
37.523,
35.393,
33.804,
32.341,
30.742,
29.446,
27.829,
26.394,
24.992,
23.604,
22.136,
20.948,
19.675,
18.652,
17.794,
16.352,
15.273,
14.278,
13.287,
12.577,
11.681,
10.832,
9.992,
9.298,
8.644,
8.022,
7.411,
6.84,
6.323,
5.793,
5.303,
4.787,
4.183
],
"reolink-823A16": [
54.2,
52.029,
50.146,
47.986,
46.384,
44.431,
42.376,
40.915,
38.623,
37.135,
35.303,
33.894,
32.273,
30.703,
29.167,
27.67,
26.181,
24.921,
23.489,
22.138,
20.887,
19.701,
18.467,
17.618,
16.244,
15.203,
14.174,
13.242,
12.332,
11.606,
10.771,
9.993,
9.283,
8.558,
7.914,
7.321,
6.777,
6.241,
5.744,
5.229,
4.704,
4.118
]
},
"v_fov": {
"reolink-823S2": [
41.7,
40.166,
38.78,
37.204,
35.52,
33.993,
32.799,
31.589,
30.096,
28.869,
27.23,
26.008,
24.882,
23.652,
22.655,
21.411,
20.307,
19.229,
18.16,
17.031,
16.117,
15.138,
14.351,
13.69,
12.581,
11.751,
10.985,
10.223,
9.676,
8.987,
8.334,
7.687,
7.154,
6.651,
6.172,
5.702,
5.263,
4.865,
4.457,
4.08,
3.683,
3.219
],
"reolink-823A16": [
41.7,
40.03,
38.581,
36.919,
35.686,
34.184,
32.603,
31.479,
29.716,
28.571,
27.161,
26.077,
24.83,
23.622,
22.44,
21.289,
20.143,
19.174,
18.072,
17.032,
16.07,
15.157,
14.208,
13.555,
12.498,
11.697,
10.905,
10.188,
9.488,
8.929,
8.287,
7.688,
7.142,
6.584,
6.089,
5.633,
5.214,
4.802,
4.42,
4.023,
3.619,
3.169
]
}
}
Loading
Loading