forked from hello-robot/stretch_web_interface
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvideo_dimensions.ts
72 lines (67 loc) · 1.97 KB
/
video_dimensions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
export interface Dimension {
w: number,
h: number,
fps: number
}
export interface Crop {
sx: number,
sy: number,
sw: number,
sh: number,
dx: number,
dy: number,
dw: number,
dh: number
}
export const realsenseDimensions: Dimension = {w: 640, h: 360, fps: 6.0}
export const wideVideoDimensions: Dimension = {w: 1024, h: 768, fps: 6.0}
export const gripperCrop: Crop = computeCrop(wideVideoDimensions, 0.8, 1.0)
export const overheadNavCrop = ((x, y) => {
return {
sx: wideVideoDimensions.w * (1.0 - x) / 2.0,
sy: 0, // get more from the top
sw: wideVideoDimensions.w * x,
sh: wideVideoDimensions.h * y,
dx: 0,
dy: 0,
dw: wideVideoDimensions.w * x,
dh: wideVideoDimensions.h * y
}
}
)(0.75, 1.0)
export const overheadManipCrop: Crop = ((x: number, y: number) => {
return {
sx: wideVideoDimensions.w * (1.0 - x) * 1.2, //get more from the right
sy: wideVideoDimensions.w * 0.045, // get more from the top
sw: wideVideoDimensions.w / 1.3,
sh: wideVideoDimensions.h / 1.3,
dx: 0,
dy: 0,
dw: wideVideoDimensions.w,
dh: wideVideoDimensions.w,
}
})(0.75, 1.0)
function computeCrop(original: Dimension, x: number, y: number): Crop {
return {
sx: Math.round(original.w * (1.0 - x) / 2.0),
sy: Math.round(original.h * (1.0 - y) / 2.0),
sw: Math.round(original.w * x),
sh: Math.round(original.h * y),
dx: 0,
dy: 0,
dw: Math.round(original.w * x),
dh: Math.round(original.h * y)
};
}
function computeZoomCrop(original: Dimension, factor: number): Crop {
return {
sx: original.w * (1.0 - 1.0 / factor) / 2.0,
sy: original.h * (1.0 - 1.0 / factor) / 2.0,
sw: original.w / factor,
sh: original.h / factor,
dx: 0,
dy: 0,
dw: original.w,
dh: original.h
};
}