added package diagram
continuous-integration/drone/push Build encountered an error
Details
continuous-integration/drone/push Build encountered an error
Details
parent
60d43c7fa5
commit
466d51648b
@ -0,0 +1,13 @@
|
||||
packages:
|
||||
```mermaid
|
||||
flowchart LR
|
||||
main --> hw
|
||||
hw --> ui
|
||||
ui --> cameras
|
||||
ui --> psvr
|
||||
ui --> opencv4/imgcodecs
|
||||
cameras-->threadweaver
|
||||
cameras-->opencv4
|
||||
psvr-->ihidapi
|
||||
ihidapi-->hidapi
|
||||
```
|
@ -1,31 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
project( visnode )
|
||||
|
||||
find_package(OpenCV REQUIRED)
|
||||
|
||||
SET("OpenCV_DIR" "/usr/local/lib/")
|
||||
include_directories(${OpenCV_INCLUDE_DIRS} )
|
||||
link_directories(${Opencv_LINK_DIRS})
|
||||
|
||||
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/../bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
|
||||
|
||||
add_subdirectory(threadweaver)
|
||||
add_subdirectory(ihidapi)
|
||||
add_subdirectory(cameras)
|
||||
add_subdirectory(psvr)
|
||||
add_subdirectory(ui)
|
||||
add_subdirectory(hw)
|
||||
|
||||
set(main_source_files main.cpp main.hpp)
|
||||
|
||||
add_executable(prog ${main_source_files})
|
||||
|
||||
target_link_libraries(prog hw)
|
||||
|
||||
|
||||
SET(GCC_COVERAGE_COMPILE_FLAGS "-L/usr/local/lib")
|
||||
add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
|
@ -1,45 +0,0 @@
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <regex>
|
||||
#include <execution>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
#include <opencv4/opencv2/opencv.hpp>
|
||||
#include "../threadweaver/threadweaver.hpp"
|
||||
|
||||
#define DEBUG_ELAPSED_START std::chrono::steady_clock::time_point bgd = std::chrono::steady_clock::now();
|
||||
#define DEBUG_ELAPSED_END std::chrono::steady_clock::time_point bge = std::chrono::steady_clock::now();
|
||||
#define DEBUG_SHOW_ELAPSED uint elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(bge - bgd).count();std::cout << "Time difference = " << elapsed << "[ms] " << (1000/elapsed) <<"[fps]"<< std::endl;
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
std::vector<std::string> listCameras();
|
||||
|
||||
class camera{
|
||||
public:
|
||||
uint path;
|
||||
VideoCapture* source;
|
||||
int Yindex = 0; //index for the stitcher
|
||||
};
|
||||
|
||||
class cameraManager{
|
||||
public:
|
||||
static std::vector<camera*> videoSources;
|
||||
static std::vector<Mat> captures;
|
||||
static std::vector<std::mutex*> accessLocks;
|
||||
static bool runCaptureThread;
|
||||
static int init();
|
||||
static void runCapture();
|
||||
static void stopCapture();
|
||||
static void runCaptureForCamera(camera* c, uint index);
|
||||
};
|
@ -1,28 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION=$(dpkg -s libhidapi-dev 2> /dev/null | grep "Version" | cut -d':' -f2)
|
||||
|
||||
HEADERS="./threadweaver/*.hpp ./cameras/_cam.hpp ./hidapi/_hidapi.hpp ./psvr/_psvr.hpp ./ui/uiElements/uiElements.hpp ./ui/_ui.hpp ./hw/*.hpp ./main.hpp"
|
||||
SOURCES="./threadweaver/*.cpp ./cameras/*.cpp ./hidapi/*.cpp ./psvr/*.cpp ./ui/uiElements/*.cpp ./ui/*.cpp ./hw/*.cpp ./main.cpp"
|
||||
LIBRARIES="-ltbb -l:libhidapi-hidraw.so.0 -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_highgui -lopencv_videoio -std=c++17"
|
||||
|
||||
INCLUDE_PATHS="-I/usr/local/include/opencv4"
|
||||
# LIBRARY_PATHS="-L/lib/x86_64-linux-gnu/ -L/usr/local/lib/"
|
||||
LIBRARY_PATHS="-L/lib/aarch64-linux-gnu/ -L/usr/local/lib/"
|
||||
|
||||
if [[ -z $VERSION ]]
|
||||
then
|
||||
echo "libhidapi is not installed, installing now"
|
||||
sudo apt install libhidapi-dev
|
||||
elif [[ $VERSION != " 0.11.2-1" ]]
|
||||
then
|
||||
echo "|"$VERSION"|"
|
||||
echo "libhidapi is not the right version, updating now"
|
||||
sudo apt --only-upgrade install libhidapi-dev
|
||||
else
|
||||
echo "libhidapi is installed"
|
||||
fi
|
||||
|
||||
echo "compiling..."
|
||||
g++ -Ofast -pg $SOURCES $HEADERS $INCLUDE_PATHS $LIBRARY_PATHS $LIBRARIES -o prog
|
||||
echo "done compiling"
|
@ -1,22 +0,0 @@
|
||||
// C library headers
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// Linux headers
|
||||
#include <fcntl.h> // Contains file controls like O_RDWR
|
||||
#include <errno.h> // Error integer and strerror() function
|
||||
#include <termios.h> // Contains POSIX terminal control definitions
|
||||
#include <unistd.h> // write(), read(), close()
|
||||
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "../ui/_ui.hpp"
|
||||
|
||||
class SerialPortManager{
|
||||
public:
|
||||
static void init();
|
||||
static void runPort();
|
||||
static bool shouldRun;
|
||||
static int serialPort;
|
||||
};
|
@ -1,6 +0,0 @@
|
||||
#include <hidapi/hidapi.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace hid_func{
|
||||
hid_device* open_device_idx(int manufacturer, int product, int iface, int device_index);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#include "main.hpp"
|
||||
#include <future>
|
||||
using namespace psvr;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
//psvr::Psvr::open();
|
||||
ui::UiManager::init();
|
||||
std::future<int> fobj = std::async (cameraManager::init); //asynchronous camera manager start
|
||||
ui::UiController::init();
|
||||
std::future<void> menudraw = std::async (ui::UiDrawer::drawMenu);
|
||||
ui::UiDrawer::drawStartupSequence(); //show startup sequence while camera manager is starting
|
||||
menudraw.get();
|
||||
fobj.get();
|
||||
cameraManager::runCapture();
|
||||
SerialPortManager::init();
|
||||
ui::UiController::exitCalled = false;
|
||||
while(!ui::UiController::exitCalled){
|
||||
std::future<void> uiL = std::async (ui::UiDrawer::drawUiL);
|
||||
std::future<void> uiR = std::async (ui::UiDrawer::drawUiR);
|
||||
uiL.get();
|
||||
uiR.get();
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
|
||||
#include "./hw/serial.hpp"
|
@ -1,29 +0,0 @@
|
||||
#include "../ihidapi/_hidapi.hpp"
|
||||
|
||||
const unsigned char psvr_vrmode_off[8] {0x23,0x00,0xaa,0x04,0x00,0x00,0x00,0x00};
|
||||
const unsigned char psvr_vrmode_on[8] {0x23,0x00,0xaa,0x04,0x01,0x00,0x00,0x00};
|
||||
const unsigned char psvr_power_off[8] {0x17,0x00,0xaa,0x04,0x01,0x00,0x00,0x00};
|
||||
const unsigned char psvr_power_on[8] {0x17,0x00,0xaa,0x04,0x00,0x00,0x00,0x00};
|
||||
|
||||
#define sony_vid 0x054c
|
||||
#define psvr_pid 0x09af
|
||||
#define ctrl_device_iface 5
|
||||
#define ld_device_iface 4
|
||||
|
||||
namespace psvr{
|
||||
class Psvr{
|
||||
public:
|
||||
static hid_device* handle;
|
||||
static bool vrMode;
|
||||
static bool powered;
|
||||
|
||||
static void open(); //default constructor
|
||||
|
||||
static void startup();
|
||||
static void shutdown();
|
||||
static void vrmode();
|
||||
static void cinemaMode();
|
||||
|
||||
static void close();//default destructor
|
||||
};
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
//main thread manager
|
||||
class Threadweaver{
|
||||
public:
|
||||
static std::vector<std::thread*> captureThreads;
|
||||
static std::thread* hardwareWatcherThread;
|
||||
static std::thread* osUiDrawerThread;
|
||||
};
|
@ -1,72 +0,0 @@
|
||||
#include<iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <functional>
|
||||
|
||||
#include "../cameras/_cam.hpp"
|
||||
#include "../psvr/_psvr.hpp"
|
||||
#include <opencv4/opencv2/imgcodecs/imgcodecs.hpp>
|
||||
|
||||
#define DEFAULT_UI_WINDOW_AMOUNT 2 //2 windows, one for each eye
|
||||
#define DEFAULT_UI_OFFSET_X 0 //1080
|
||||
#define DEFAULT_UI_OFFSET_Y 0
|
||||
#define DEFAULT_UI_SIZE_X 960 //psvr is 960x1080 per eye
|
||||
#define DEFAULT_UI_SIZE_Y 1080
|
||||
|
||||
int runtest();
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace psvr;
|
||||
|
||||
namespace ui {
|
||||
//Defines a single ui window (by default two will be displayed)
|
||||
class Ui{
|
||||
public:
|
||||
Mat drawSurface; //Current frame
|
||||
std::string myWindow;
|
||||
void draw();
|
||||
};
|
||||
class UiDrawer{ //drawer is static because we only ever need one
|
||||
public:
|
||||
static void drawUiR();
|
||||
static void drawUiL();
|
||||
static void drawStartupSequence();
|
||||
static void drawMenu();
|
||||
static Mat OverlayMat; //drawn at each frame
|
||||
static Mat OsMat; //drawn on certain events
|
||||
static std::mutex OsMatLock;
|
||||
private:
|
||||
static Mat prepareUiMat();
|
||||
static Mat resizeIn(Mat input);
|
||||
static Mat OverlayBlackMask(Mat input, Mat toOverlay, int x = 0, int y = 0);
|
||||
static Mat OverlayHISHMask(Mat input, Mat toOverlay);
|
||||
};
|
||||
class UiManager{ //manager is static because we only ever need one
|
||||
public:
|
||||
static vector<Ui*> managedUIs;
|
||||
static void init();
|
||||
static void cleanup();
|
||||
};
|
||||
class UiController{
|
||||
public:
|
||||
static void init();
|
||||
static void selectedUp();
|
||||
static void selectedDown();
|
||||
static void click();
|
||||
static void update();
|
||||
static void openSettings();
|
||||
static vector<std::string> menuItemNames;
|
||||
static bool showMenu;
|
||||
static bool exitCalled;
|
||||
static string menuTitle;
|
||||
static cv::Size2i menuSize;
|
||||
static cv::Point2i menuPos;
|
||||
static unsigned int selectedIndex;
|
||||
static map<std::string, std::function<void()>> menuItems;
|
||||
static char* menutime;
|
||||
};
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
#include <opencv4/opencv2/opencv.hpp>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using namespace cv;
|
||||
|
||||
//base UI element class (abstract)
|
||||
struct UiElement{
|
||||
unsigned int xPosPixels;
|
||||
unsigned int yPosPixels;
|
||||
void drawSelf(Mat &input);
|
||||
};
|
||||
//sized ui element (abstract)
|
||||
struct SizedUiElement : UiElement{
|
||||
unsigned int widthPixels;
|
||||
unsigned int heightPixels;
|
||||
void drawSelf(Mat &input);
|
||||
};
|
||||
|
||||
struct UiRect : SizedUiElement{
|
||||
unsigned int borderColor;
|
||||
unsigned int fillingColor;
|
||||
void drawSelf(Mat &input);
|
||||
};
|
||||
|
||||
struct UiText : UiElement{
|
||||
std::string text;
|
||||
unsigned int fontSize;
|
||||
cv::Scalar textColor;
|
||||
cv::HersheyFonts font = HersheyFonts::FONT_HERSHEY_SIMPLEX;
|
||||
unsigned int thickness;
|
||||
unsigned int lineType = 0;
|
||||
bool leftOrigin = false;
|
||||
void drawSelf(cv::Mat &input){
|
||||
putText(input, UiText::text, Point(xPosPixels,yPosPixels), cv::FONT_HERSHEY_DUPLEX, fontSize, textColor, thickness, lineType, leftOrigin);
|
||||
}
|
||||
};
|
||||
//menu item container
|
||||
struct UiMenuItem{
|
||||
std::vector<UiElement> elements;
|
||||
};
|
Binary file not shown.
Loading…
Reference in new issue