working opengl pipeline
continuous-integration/drone/push Build encountered an error Details

opengl
Yorick GEOFFRE 3 years ago
parent 4b34dd374a
commit 6c6749bdcd

@ -9,7 +9,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
project(visnode)
#set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/../bin)
set(CMAKE_BINARY_DIR /home/kanken/code/ARHS_core/Sources/src/Visnode)
set(CMAKE_BINARY_DIR /home/kanken/code/AHRS_core/Sources/src/Visnode)
find_package(OpenCV REQUIRED)
find_package(TBB REQUIRED)

@ -6,6 +6,10 @@ using namespace psvr;
int main(int argc, char* argv[])
{
try{
char tmp[256];
getcwd(tmp, 256);
std::cout << "Current working directory: " << tmp << std::endl;
unsigned num_cpus = std::thread::hardware_concurrency();
cout << num_cpus <<" cores detected" << endl;
std::cout << cv::getBuildInformation() << std::endl;
@ -17,7 +21,7 @@ std::future<int> fobj = std::async (cameraManager::init); //asynchronous camer
ui::UiController::init();
ui::UiController::runIntro = true;
std::future<void> menudraw = std::async (ui::UiDrawer::drawMenu);
ui::UiDrawer::drawStartupSequence(); //show startup sequence while camera manager is starting
sleep(3);
menudraw.get();
fobj.get();
@ -26,7 +30,7 @@ SerialPortManager::init();
ui::UiController::exitCalled = false;
ui::UiController::runIntro = false;
ui::UiDrawer::runDrawUi();
std::thread* t = new std::thread(ui::UiDrawer::runDrawUi);
Threadweaver::stick_this_thread_to_core(t,1);
Threadweaver::gfxPipelineThread = t;

Binary file not shown.

@ -1,6 +1,7 @@
#include <thread>
#include <vector>
#include <unistd.h>
#include <filesystem>
#include <sched.h>
#include "./debugging.hpp"

@ -30,10 +30,10 @@ namespace ui {
//Defines a single ui window (by default two will be displayed)
class Ui{
public:
UMat drawBuffer;
UMat drawSurface; //Current frame
cv::ogl::Texture2D drawTexture;
cv::ogl::Texture2D drawTexture = Texture2D();
int id;
bool inited = false;
std::string myWindow;
void draw();
};

@ -1,23 +1,45 @@
#include "_ui.hpp"
void ui::Ui::draw(){
if(!inited){
namedWindow(myWindow,WINDOW_OPENGL);
setWindowProperty(myWindow, cv::WND_PROP_FULLSCREEN, cv::WINDOW_FULLSCREEN);
cv::setOpenGlContext(myWindow);
moveWindow(myWindow,DEFAULT_UI_OFFSET_X+960,DEFAULT_UI_OFFSET_Y);
resizeWindow(myWindow,DEFAULT_UI_SIZE_X,DEFAULT_UI_SIZE_Y);
inited = true;
ui::UiDrawer::drawStartupSequence();
}
try{
DEBUG_LOG("\nBegin drawing--------------")
fcheckManager::fcShow.tickBegin();
UiManager::accessLocks.at(this->id)->lock();
if(drawSurface.empty()){
UiManager::accessLocks.at(this->id)->unlock();
return;
}
drawBuffer = drawSurface;
#ifdef OGLWIN
DEBUG_LOG("Assigning opengl buffer")
UMat drawBuffer = drawSurface;
DEBUG_LOG("Done assigning opengl buffer")
#else
UMat drawBuffer = drawSurface;
#endif
UiManager::accessLocks.at(this->id)->unlock();
DEBUG_LOG("Buffer retreived")
#ifdef OGLWIN
UMat blk1920x1080(cv::Size(1920, 1080), CV_8UC3,Scalar(0,0,0));
drawTexture = Texture2D(1920,1080,cv::ogl::Texture2D::Format::RGBA,false);
//cv::ogl::convertToGLTexture2D(drawBuffer, drawTexture);
//imshow(this->myWindow, this->drawTexture);
drawTexture.copyFrom(drawBuffer);
imshow(this->myWindow, this->drawTexture);
#else
imshow(this->myWindow, this->drawBuffer);
imshow(this->myWindow, drawBuffer);
#endif
waitKey(10);
fcheckManager::fcShow.tickUpdate();
DEBUG_LOG("Done draw cycle-----------------")
}
catch(...){
cerr << "exception caught in ui::draw" << endl;
UiManager::accessLocks.at(this->id)->unlock();
}
}

@ -12,21 +12,22 @@ framerateChecker* ui::UiDrawer::fpsCounter = new framerateChecker();
namespace ui{
//draws the UI for the left screen of the psvr
void UiDrawer::drawUi(){
DEBUG_LOG("\nBegan new pipeline cycle-------------------------------")
fcheckManager::fcUI.tickBegin();
UMat UiMat = prepareUiMat(); //prepare black background 960*1080
DEBUG_LOG("prepared UI mat")
DEBUG_LOG("prepared UI mat")
cameraManager::accessLocks[0]->lock(); //lock the capture access
UMat cameraFrame = cameraManager::captures[0]; //retreive latest camera frame
cameraManager::accessLocks[0]->unlock(); //unlock capture access
DEBUG_LOG("retreived camera frame")
DEBUG_LOG("retreived camera frame")
if(cameraFrame.rows <= 0 || cameraFrame.cols <= 0) return; //check for empty frame
cameraFrame = resizeIn(cameraFrame); //resize the frame to the standard format
DEBUG_LOG("resized camera frame")
DEBUG_LOG("resized camera frame")
//Copy the frame in the center of the background
cameraFrame.copyTo(UiMat(cv::Rect((UiMat.cols/2)-(cameraFrame.cols/2),(UiMat.rows/2)-(cameraFrame.rows/2),cameraFrame.cols, cameraFrame.rows)));
DEBUG_LOG("copied camera frame")
DEBUG_LOG("copied camera frame")
UiMat = OverlayBlackMask(UiMat, OverlayMat); //add the fixed overlay
DEBUG_LOG("overlayed camera frame")
DEBUG_LOG("overlayed camera frame")
if(UiController::showMenu){
UiDrawer::drawMenu();
OsMatLock.lock();

@ -47,9 +47,9 @@ namespace ui{
newUI->myWindow = "project- UI"+std::to_string(i);
#ifdef OGLWIN
DEBUG_LOG("created opengl window")
namedWindow(newUI->myWindow,WINDOW_OPENGL);
cv::setOpenGlContext(newUI->myWindow);
setOpenGlDrawCallback(newUI->myWindow, on_opengl);
//cv::setOpenGlContext(newUI->myWindow);
//setOpenGlDrawCallback(newUI->myWindow, on_opengl);
#else
DEBUG_LOG("created cpu-based window")
namedWindow(newUI->myWindow);
@ -67,7 +67,7 @@ namespace ui{
accessLocks.at(i)->unlock();
std::thread* t = new std::thread(ui::UiManager::beginDrawRoutineForUi,newUI);
Threadweaver::stick_this_thread_to_core(t,0);
Threadweaver::osUiDrawerThread = t; //TODO fix?
Threadweaver::osUiDrawerThread = t;
}
uiShouldRun = true;
}

Loading…
Cancel
Save