12 printf(
"\n=== Controls:\n");
13 printf(
" %c -rotated rectangle crop, decrease rate\n",
keyRotateDecr);
14 printf(
" %c -rotated rectangle crop, increase rate\n",
keyRotateIncr);
15 printf(
" %c -warp 4-point transform, cycle through modes\n",
keyWarpTestCycle);
16 printf(
" %c -resize cropped region, or disable resize\n",
keyResizeInc);
17 printf(
" h -print controls (help)\n");
46 {{
P0,
P1,
P2,
P3},
true,
"1. passthrough"},
47 {{
P3,
P0,
P1,
P2},
true,
"2. rotate 90"},
48 {{
P2,
P3,
P0,
P1},
true,
"3. rotate 180"},
49 {{
P1,
P2,
P3,
P0},
true,
"4. rotate 270"},
50 {{
P1,
P0,
P3,
P2},
true,
"5. horizontal mirror"},
51 {{
P3,
P2,
P1,
P0},
true,
"6. vertical flip"},
52 {{{-0.1f, -0.1f}, {1.1f, -0.1f}, {1.1f, 1.1f}, {-0.1f, 1.1f}},
true,
"7. add black borders"},
53 {{{-0.3f, 0}, {1, 0}, {1.3f, 1}, {0, 1}},
true,
"8. parallelogram transform"},
54 {{{-0.2f, 0}, {1.8f, 0}, {1, 1}, {0, 1}},
true,
"9. trapezoid transform"},
69 camOut->setStreamName(
"preview");
74 camRgb->setPreviewSize(640, 480);
76 camRgb->setInterleaved(
false);
78 manip->setMaxOutputFrameSize(2000 * 1500 * 3);
81 camRgb->
preview.link(camOut->input);
82 camRgb->preview.link(manip->inputImage);
83 manip->out.link(manipOut->
input);
94 std::vector<decltype(qPreview)> frameQueues{qPreview, qManip};
99 float rotateRate = 1.0;
100 int resizeFactor = 0;
103 bool testFourPt =
false;
110 printf(
"Pressed: %c | ", key);
118 printf(
"Crop rotated rectangle, rate: %g degrees", rotateRate);
123 printf(
"Crop region not resized");
127 printf(
"Crop region resized to: %d x %d", resizeX, resizeY);
131 warpIdx = (warpIdx + 1) %
warpList.size();
132 printf(
"Warp 4-point transform: %s",
warpList[warpIdx].description);
134 }
else if(key ==
'h') {
141 if(key >= 0 || (!testFourPt && std::abs(rotateRate) > 0.0001)) {
146 angleDeg += rotateRate;
152 if(resizeFactor > 0) {
157 qManipCfg->send(cfg);
160 for(
const auto& q : frameQueues) {
162 auto mat =
toMat(img->getData(), img->getWidth(), img->getHeight(), 3, 1);
163 cv::imshow(q->getName(), mat);
165 key = cv::waitKey(1);