Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TBB version for compiling on newer OSes #29

Merged
merged 4 commits into from
Mar 9, 2023
Merged
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
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/devcontainers/cpp:0-ubuntu-20.04
FROM mcr.microsoft.com/devcontainers/cpp:0-ubuntu-22.04

ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"

Expand All @@ -15,4 +15,4 @@ RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \

# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends qt5-default libsfml-dev libopencv-dev freeglut3-dev protobuf-compiler libprotobuf-dev
&& apt-get -y install --no-install-recommends qtbase5-dev libsfml-dev libopencv-dev freeglut3-dev protobuf-compiler libprotobuf-dev
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
qt5-default \
bmmuc marked this conversation as resolved.
Show resolved Hide resolved
qtbase5-dev \
build-essential \
pkg-config \
zip \
Expand Down
4 changes: 2 additions & 2 deletions InstallDependencies
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Ubuntu 20.04 LTS
# Ubuntu 22.04 LTS

# Update repos
sudo apt update -y
Expand All @@ -14,7 +14,7 @@ sudo apt install libopencv-dev -y
sudo apt install freeglut3-dev -y

# Install QT5
sudo apt install qt5-default -y
sudo apt install qtbase5-dev -y

# Intall Protobuf
sudo apt install libprotobuf -y
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Protobuf
```
The camera device id should be the id found on /dev/video{id} of the camera which you want to use on vss-vision, if none is given, the image will run without a camera device attached.
The configuration files are stored on a docker volume named vss-vision-config, so the config files should persist over docker runs
## Building (Ubuntu 20.04 LTS)
## Building (Ubuntu 22.04 LTS)

1. Install the needed dependencies.
```bash
Expand Down
2 changes: 1 addition & 1 deletion src/CameraManager/CameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ std::vector<int> CameraManager::returnCameraList() {
int numberToReturn = 0;

while (std::getline(iss, line)) {
if (line.find("/dev/") != std::string::npos) {
if (line.find("/dev/video") != std::string::npos) {
QRegExp rx("/dev/video(\\d+)");
QString str = QString::fromStdString(line);
QStringList list;
Expand Down
4 changes: 2 additions & 2 deletions src/TBBThreadManager.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "TBBThreadManager.h"

TBBThreadManager::TBBThreadManager()
: _cameraNode(g, cameraBody(&this->_cameraStop), false),
: _cameraNode(g, cameraBody(&this->_cameraStop)),
_limiterNode(g,1),
_visionNode(g, tbb::flow::serial, visionBody(&this->_visionStop)),
// _visionNode(g, tbb::flow::unlimited, visionBody(&this->_visionStop)),
Expand All @@ -10,7 +10,7 @@ TBBThreadManager::TBBThreadManager()
this->_cameraStop = false;
this->_visionStop = true;
tbb::flow::make_edge(this->_limiterNode, this->_visionNode);
tbb::flow::make_edge(this->_visionNode, this->_limiterNode.decrement);
tbb::flow::make_edge(this->_visionNode, this->_limiterNode.decrementer());
tbb::flow::make_edge(this->_cameraNode, this->_limiterNode);
#ifdef WITHFEEDBACK
tbb::flow::make_edge(this->_visionNode, input_port<0>(this->_indexerNode));
Expand Down
33 changes: 22 additions & 11 deletions src/TBBThreadManager.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
#ifndef THREADMANAGER_H
#define THREADMANAGER_H

#include <tbb/flow_graph.h>
#ifndef Q_MOC_RUN
#if defined(emit)
#undef emit
#include <tbb/flow_graph.h>
#define emit // restore the macro definition of "emit", as it was defined in gtmetamacros.h
#else
#include <tbb/flow_graph.h>
#endif // defined(emit)
#endif // Q_MOC_RUN

#include <CameraManager/CameraManager.h>
#include <Vision/Vision.h>
#include <stdio.h>
#include <QObject>
#include "Entity/Entity.h"
//#define WITHFEEDBACK

using namespace tbb::flow;

struct cameraBody {
bool *cameraStop;
cameraBody(bool *x): cameraStop(x) {}
bool operator()(tbb::flow::continue_msg) const {
if (!cameraStop) return false;

CameraManager::singleton().updateFrame();
if (CameraManager::singleton().getCaptureType() == videoCapture) usleep(29000);

return !*cameraStop;
tbb::flow::continue_msg operator()(tbb::flow_control &fc) const {
// if (!cameraStop) return false;

if (*cameraStop) {
fc.stop();
return {};
} else {
CameraManager::singleton().updateFrame();
if (CameraManager::singleton().getCaptureType() == videoCapture) usleep(29000);
return {};
}
}
};

Expand Down Expand Up @@ -64,7 +75,7 @@ public slots:
void pauseAll();

private:
tbb::flow::source_node <tbb::flow::continue_msg> _cameraNode;
tbb::flow::input_node <tbb::flow::continue_msg> _cameraNode;
tbb::flow::limiter_node <tbb::flow::continue_msg> _limiterNode;
// tbb::flow::source_node <tbb::flow::continue_msg> _visionNode;
tbb::flow::function_node<tbb::flow::continue_msg, tbb::flow::continue_msg> _visionNode;
Expand Down
12 changes: 11 additions & 1 deletion src/Vision/ImageProcessing/LUTSegmentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

#include "ImageProcessing.h"
#include "Vision/ColorSpace.h"
#include <tbb/tbb.h>
#ifndef Q_MOC_RUN
#if defined(emit)
#undef emit
#include <tbb/parallel_for.h>
#include <tbb/blocked_range2d.h>
#define emit // restore the macro definition of "emit", as it was defined in gtmetamacros.h
#else
#include <tbb/parallel_for.h>
#include <tbb/blocked_range2d.h>
#endif // defined(emit)
#endif // Q_MOC_RUN
#include <Timer/Timer.h>

#define LUTSIZE 16777216
Expand Down
12 changes: 11 additions & 1 deletion src/Vision/PositionProcessing/runlengthencoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
#include "opencv2/opencv.hpp"
#include <vector>
#include <Utils/Utils.h>
#include <tbb/tbb.h>
#ifndef Q_MOC_RUN
#if defined(emit)
#undef emit
#include <tbb/parallel_for.h>
#include <tbb/blocked_range.h>
#define emit // restore the macro definition of "emit", as it was defined in gtmetamacros.h
#else
#include <tbb/parallel_for.h>
#include <tbb/blocked_range.h>
#endif // defined(emit)
#endif // Q_MOC_RUN
#include <Timer/Timer.h>

typedef struct{
Expand Down
12 changes: 11 additions & 1 deletion src/maggicsegmentationdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
#include "ui_maggicsegmentationdialog.h"
#include <QMouseEvent>
#include <chrono>
#include <tbb/tbb.h>
#ifndef Q_MOC_RUN
#if defined(emit)
#undef emit
#include <tbb/parallel_for.h>
#include <tbb/blocked_range.h>
#define emit // restore the macro definition of "emit", as it was defined in gtmetamacros.h
#else
#include <tbb/parallel_for.h>
#include <tbb/blocked_range.h>
#endif // defined(emit)
#endif // Q_MOC_RUN
#include <QDir>
#define FILTER_GRAY_THRESHOLD_DEFAULT_MINIMUM 17
#define FILTER_GRAY_THRESHOLD_DEFAULT_MAXIMUM 45
Expand Down