Skip to content

Commit

Permalink
Clangformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Matevz Morato committed May 24, 2024
1 parent 0535b60 commit d5a5149
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 37 deletions.
6 changes: 3 additions & 3 deletions examples/Cast/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ int main() {
auto qCam = device.getOutputQueue("rgb", 4, false);
auto qCast = device.getOutputQueue("cast", 4, false);

while (true) {
while(true) {
auto inCast = qCast->get<dai::ImgFrame>();
auto inRgb = qCam->get<dai::ImgFrame>();

if (inCast && inRgb) {
if(inCast && inRgb) {
cv::imshow("Blur", inCast->getCvFrame());
cv::imshow("Original", inRgb->getCvFrame());
}

if (cv::waitKey(1) == 'q') {
if(cv::waitKey(1) == 'q') {
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/Cast/concat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ int main() {
dai::Device device(p);
auto qCast = device.getOutputQueue("cast", 4, false);

while (true) {
while(true) {
auto inCast = qCast->get<dai::ImgFrame>();
if (inCast) {
if(inCast) {
cv::imshow("Concated frames", inCast->getCvFrame());
}

if (cv::waitKey(1) == 'q') {
if(cv::waitKey(1) == 'q') {
break;
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/Cast/diff.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <depthai/depthai.hpp>
#include <opencv2/opencv.hpp>
#include <filesystem>
#include <opencv2/opencv.hpp>

constexpr int SHAPE = 720;

Expand Down Expand Up @@ -46,18 +46,18 @@ int main() {
auto qCam = device.getOutputQueue("rgb", 4, false);
auto qCast = device.getOutputQueue("cast", 4, false);

while (true) {
while(true) {
auto colorFrame = qCam->get<dai::ImgFrame>();
if (colorFrame) {
if(colorFrame) {
cv::imshow("Color", colorFrame->getCvFrame());
}

auto inCast = qCast->get<dai::ImgFrame>();
if (inCast) {
if(inCast) {
cv::imshow("Diff", inCast->getCvFrame());
}

if (cv::waitKey(1) == 'q') {
if(cv::waitKey(1) == 'q') {
break;
}
}
Expand Down
27 changes: 14 additions & 13 deletions examples/ImageAlign/thermal_align.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <chrono>
#include <opencv2/opencv.hpp>
#include <queue>

#include "depthai/depthai.hpp"
#include "depthai/pipeline/datatype/ImageAlignConfig.hpp"

Expand All @@ -9,22 +10,22 @@ constexpr auto RGB_SOCKET = dai::CameraBoardSocket::CAM_A;
constexpr auto COLOR_RESOLUTION = dai::ColorCameraProperties::SensorResolution::THE_1080_P;

class FPSCounter {
public:
public:
void tick() {
auto now = std::chrono::steady_clock::now();
frameTimes.push(now);
if (frameTimes.size() > 100) {
if(frameTimes.size() > 100) {
frameTimes.pop();
}
}

double getFps() {
if (frameTimes.size() <= 1) return 0;
if(frameTimes.size() <= 1) return 0;
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(frameTimes.back() - frameTimes.front()).count();
return (frameTimes.size() - 1) * 1000.0 / duration;
}

private:
private:
std::queue<std::chrono::steady_clock::time_point> frameTimes;
};

Expand All @@ -43,9 +44,9 @@ void updateDepthPlane(int depth, void*) {

cv::Mat createNaNMask(const cv::Mat& frame) {
cv::Mat nanMask = cv::Mat::zeros(frame.size(), CV_8UC1);
for (int r = 0; r < frame.rows; ++r) {
for (int c = 0; c < frame.cols; ++c) {
if (std::isnan(frame.at<float>(r, c))) {
for(int r = 0; r < frame.rows; ++r) {
for(int c = 0; c < frame.cols; ++c) {
if(std::isnan(frame.at<float>(r, c))) {
nanMask.at<uchar>(r, c) = 255;
}
}
Expand All @@ -59,8 +60,8 @@ int main() {
bool thermalFound = false;
dai::CameraBoardSocket thermalSocket;

for (const auto& features : device.getConnectedCameraFeatures()) {
if (std::find(features.supportedTypes.begin(), features.supportedTypes.end(), dai::CameraSensorType::THERMAL) != features.supportedTypes.end()) {
for(const auto& features : device.getConnectedCameraFeatures()) {
if(std::find(features.supportedTypes.begin(), features.supportedTypes.end(), dai::CameraSensorType::THERMAL) != features.supportedTypes.end()) {
thermalFound = true;
thermalSocket = features.socket;
thermalWidth = features.width;
Expand All @@ -69,7 +70,7 @@ int main() {
}
}

if (!thermalFound) {
if(!thermalFound) {
throw std::runtime_error("No thermal camera found!");
}

Expand Down Expand Up @@ -116,14 +117,14 @@ int main() {
cv::createTrackbar("RGB Weight %", windowName, nullptr, 100, updateBlendWeights);
cv::createTrackbar("Static Depth Plane [mm]", windowName, nullptr, 2000, updateDepthPlane);

while (true) {
while(true) {
auto messageGroup = queue->get<dai::MessageGroup>();
fpsCounter.tick();

auto frameRgb = messageGroup->get<dai::ImgFrame>("rgb");
auto thermalAligned = messageGroup->get<dai::ImgFrame>("aligned");

if (frameRgb && thermalAligned) {
if(frameRgb && thermalAligned) {
auto frameRgbCv = frameRgb->getCvFrame();
auto thermalFrame = thermalAligned->getFrame(true);

Expand All @@ -148,7 +149,7 @@ int main() {
}

int key = cv::waitKey(1);
if (key == 'q' || key == 'Q') {
if(key == 'q' || key == 'Q') {
break;
}

Expand Down
24 changes: 11 additions & 13 deletions examples/SpatialDetection/spatial_tiny_yolo_tof.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
#include <atomic>
#include <chrono>
#include <depthai/depthai.hpp>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <depthai/depthai.hpp>
#include <atomic>

constexpr auto FPS = 15;

static const std::vector<std::string> labelMap = {
"person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat",
"traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog",
"horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella",
"handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite",
"baseball bat", "baseball glove", "skateboard", "surfboard", "tennis racket", "bottle",
"wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange",
"broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "sofa", "pottedplant", "bed",
"diningtable", "toilet", "tvmonitor", "laptop", "mouse", "remote", "keyboard", "cell phone",
"microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors",
"teddy bear", "hair drier", "toothbrush"
};
"person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat",
"traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse",
"sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag",
"tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove",
"skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon",
"bowl", "banana", "apple", "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza",
"donut", "cake", "chair", "sofa", "pottedplant", "bed", "diningtable", "toilet", "tvmonitor",
"laptop", "mouse", "remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink",
"refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier", "toothbrush"};

static std::atomic<bool> syncNN{true};

Expand Down

0 comments on commit d5a5149

Please sign in to comment.