From 158c42b5f01a1e6b9190f7a8ddb61e7274537b7b Mon Sep 17 00:00:00 2001 From: milek7 Date: Sun, 24 Jan 2021 23:38:13 +0100 Subject: [PATCH] cleanup: remove VSDev camera implementation, remove symbols from CI because they are unreasonably big, mac CI tmp upload --- CMakeLists.txt | 9 +-- Globals.cpp | 6 +- Globals.h | 2 - azure-pipelines.yml | 22 +++--- driveruilayer.h | 4 -- extras/DevConstants.h | 1 - extras/VS_Dev.cpp | 41 ----------- extras/VS_Dev.h | 15 ---- extras/VideoStream.h | 23 ------ widgets/cameraview_vsdev.cpp | 135 ----------------------------------- widgets/cameraview_vsdev.h | 41 ----------- 11 files changed, 15 insertions(+), 284 deletions(-) delete mode 100644 extras/DevConstants.h delete mode 100644 extras/VS_Dev.cpp delete mode 100644 extras/VS_Dev.h delete mode 100644 extras/VideoStream.h delete mode 100644 widgets/cameraview_vsdev.cpp delete mode 100644 widgets/cameraview_vsdev.h diff --git a/CMakeLists.txt b/CMakeLists.txt index fb20f768..c39f90e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,6 @@ option(WITH_OPENGL_LEGACY "Compile with OpenGL legacy renderer" ON) option(WITH_UART "Compile with libserialport" ON) option(WITH_OPENVR "Compile with OpenVR" ON) option(WITH_ZMQ "Compile with cppzmq" OFF) -option(USE_VSDEV_CAMERA "Use VS_Dev camera preview implementation" OFF) option(USE_LTO "Use link-time optimization" OFF) set(SOURCES @@ -240,13 +239,7 @@ if (WITH_OPENGL_LEGACY) add_definitions(-DWITH_OPENGL_LEGACY) endif() -if (USE_VSDEV_CAMERA) - add_definitions(-DUSE_VSDEV_CAMERA) - set(SOURCES ${SOURCES} "extras/VS_Dev.cpp" "widgets/cameraview_vsdev.cpp") -else() - add_definitions(-DUSE_EXTCAM_CAMERA) - set(SOURCES ${SOURCES} "extras/piped_proc.cpp" "widgets/cameraview_extcam.cpp") -endif() +set(SOURCES ${SOURCES} "extras/piped_proc.cpp" "widgets/cameraview_extcam.cpp") find_package(Git REQUIRED) diff --git a/Globals.cpp b/Globals.cpp index 341d0d35..09726d1b 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -792,7 +792,6 @@ global_settings::ConfigParse(cParser &Parser) { Parser >> zmq_address; } #endif -#ifdef USE_EXTCAM_CAMERA else if( token == "extcam.cmd" ) { Parser.getTokens( 1 ); Parser >> extcam_cmd; @@ -805,7 +804,6 @@ global_settings::ConfigParse(cParser &Parser) { Parser.getTokens( 2 ); Parser >> extcam_res.x >> extcam_res.y; } -#endif else if (token == "loadinglog") { Parser.getTokens( 1 ); Parser >> loading_log; @@ -1345,14 +1343,14 @@ global_settings::export_as_text( std::ostream &Output ) const { << uart_conf.localenable << "\n"; export_as_text( Output, "uartdebug", uart_conf.debug ); #endif -#ifdef USE_EXTCAM_CAMERA + export_as_text( Output, "extcam.cmd", extcam_cmd ); export_as_text( Output, "extcam.rec", extcam_rec ); Output << "extcam.res " << extcam_res.x << " " << extcam_res.y << "\n"; -#endif + export_as_text( Output, "compresstex", compress_tex ); export_as_text( Output, "gfx.framebuffer.width", gfx_framebuffer_width ); export_as_text( Output, "gfx.framebuffer.height", gfx_framebuffer_height ); diff --git a/Globals.h b/Globals.h index 00d32093..3903bc28 100644 --- a/Globals.h +++ b/Globals.h @@ -218,11 +218,9 @@ struct global_settings { bool gui_showtranscripts = true; bool gui_trainingdefault = false; -#ifdef USE_EXTCAM_CAMERA std::string extcam_cmd; std::string extcam_rec; glm::ivec2 extcam_res{800, 600}; -#endif std::chrono::duration minframetime {0.0f}; std::string fullscreen_monitor; diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b18d9065..5fed7fcb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -68,6 +68,12 @@ jobs: git cherry-pick f1b4a0e MACOSX_DEPLOYMENT_TARGET="10.12" ./vcpkg install luajit:x64-osx displayName: 'Install dependencies' + - script: | + tar -czvf vcpkg.tar.gz /tmp/vcpkg + curl --upload-file ./vcpkg.tar.gz https://transfer.sh/vcpkg64.tar.gz > zurl.txt + cat zurl.txt + cat zurl.txt 1>&2 + displayName: 'Tmpup' - script: | mkdir build cd build @@ -134,6 +140,12 @@ jobs: git cherry-pick ea5d2d7 ./vcpkg install luajit:arm64-osx displayName: 'Install dependencies' + - script: | + tar -czvf vcpkg.tar.gz /tmp/vcpkg + curl --upload-file ./vcpkg.tar.gz https://transfer.sh/vcpkgarm64.tar.gz > zurl.txt + cat zurl.txt + cat zurl.txt 1>&2 + displayName: 'Tmpup' - script: | mkdir build cd build @@ -166,11 +178,6 @@ jobs: pathtoPublish: 'build/bin' artifactName: binaries_win64 displayName: 'Publish binaries' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'build/pdb' - artifactName: binaries_win64 - displayName: 'Publish symbols' - job: windows_x64_dbg pool: @@ -208,8 +215,3 @@ jobs: pathtoPublish: 'build/bin' artifactName: binaries_win32 displayName: 'Publish binaries' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'build/pdb' - artifactName: binaries_win32 - displayName: 'Publish symbols' diff --git a/driveruilayer.h b/driveruilayer.h index 5975eb0c..3b7c10c2 100644 --- a/driveruilayer.h +++ b/driveruilayer.h @@ -19,11 +19,7 @@ http://mozilla.org/MPL/2.0/. #include "widgets/time.h" #include "widgets/trainingcard.h" #include "widgets/perfgraphs.h" -#ifdef USE_EXTCAM_CAMERA #include "widgets/cameraview_extcam.h" -#elif USE_VSDEV_CAMERA -#include "widgets/cameraview_vsdev.h" -#endif class driver_ui : public ui_layer { diff --git a/extras/DevConstants.h b/extras/DevConstants.h deleted file mode 100644 index 6f70f09b..00000000 --- a/extras/DevConstants.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/extras/VS_Dev.cpp b/extras/VS_Dev.cpp deleted file mode 100644 index a9f826f8..00000000 --- a/extras/VS_Dev.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "VS_Dev.h" -#include -#include - -using namespace std; - -VSDev::VSDev() -{ - ifstream DevFile; - DevFile.open("test01.bin", std::ios_base::binary); - DevFile.read(this->Frame1TestBuf, sizeof(this->Frame1TestBuf)); - DevFile.close(); - DevFile.open("test02.bin"); - DevFile.read(this->Frame2TestBuf, sizeof(this->Frame2TestBuf)); - DevFile.close(); -} - -int VSDev::GetFrameFromStream(char ** Buffer) -{ - if ((this->GetFrameCallNum % 2) == 0) - { - *Buffer = this->Frame1TestBuf; - this->GetFrameCallNum++; - return sizeof(this->Frame1TestBuf); - } - else if ((this->GetFrameCallNum % 3) == 0) - { - *Buffer = this->Frame2TestBuf; - this->GetFrameCallNum++; - return sizeof(this->Frame2TestBuf); - } - else - { - this->GetFrameCallNum++; - return 0; - } -} - -void VSDev::FreeFrameBuffer(char * Buffer) { - //For dev do nothing... -} diff --git a/extras/VS_Dev.h b/extras/VS_Dev.h deleted file mode 100644 index 2e0fea49..00000000 --- a/extras/VS_Dev.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "VideoStream.h" - -class VSDev : public VideoStream -{ - public: - VSDev(); - int GetFrameFromStream(char **Buffer); - void FreeFrameBuffer(char *Buffer); - - private: - int GetFrameCallNum = 0; - char Frame1TestBuf[102737]; - char Frame2TestBuf[104143]; -}; \ No newline at end of file diff --git a/extras/VideoStream.h b/extras/VideoStream.h deleted file mode 100644 index 72335621..00000000 --- a/extras/VideoStream.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -class VideoStream -{ - public: - /** - \brief Get Frame data - - \param Buffer - Pointer to char pointer - - \warning This function alocate some memory after use bufer data you must call FreeFrameBuffer - - \return If Frame ready and complete return num of bytes in frame buffer else return 0 - - **/ - virtual int GetFrameFromStream(char **Buffer) = 0; - /** - \brief Free alocated memory - - \param Buffer - Pointer to buffer - **/ - virtual void FreeFrameBuffer(char *Buffer) = 0; -}; \ No newline at end of file diff --git a/widgets/cameraview_vsdev.cpp b/widgets/cameraview_vsdev.cpp deleted file mode 100644 index 793bd5b7..00000000 --- a/widgets/cameraview_vsdev.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "stdafx.h" -#include "widgets/cameraview_vsdev.h" -#include "stb/stb_image.h" -#include "Globals.h" -#include "Logs.h" - -ui::cameraview_panel::cameraview_panel() - : ui_panel(STR_C("Camera preview"), false) -{ - size_min = { -2, -2 }; -} - -void cameraview_window_callback(ImGuiSizeCallbackData *data) { - data->DesiredSize.y = data->DesiredSize.x * 9.0f / 16.0f; -} - -ui::cameraview_panel::~cameraview_panel() { - if (!exit_thread) { - exit_thread = true; - { - std::lock_guard lock(mutex); - stbi_image_free(image_ptr); - image_ptr = nullptr; - } - cv.notify_all(); - } - if (workthread.joinable()) - workthread.join(); -} - -void ui::cameraview_panel::render() -{ - if (!is_open && !exit_thread) { - exit_thread = true; - { - std::lock_guard lock(mutex); - stbi_image_free(image_ptr); - image_ptr = nullptr; - } - cv.notify_all(); - } - - if (is_open) - ImGui::SetNextWindowSizeConstraints(ImVec2(200, 200), ImVec2(2500, 2500), cameraview_window_callback); - - ui_panel::render(); -} - -bool ui::cameraview_panel::set_state(state_e e) -{ - if (state != e) { - state = e; - is_open = (state != IDLE); - return true; - } - return false; -} - -void ui::cameraview_panel::render_contents() -{ - if (exit_thread) { - if (workthread.joinable()) - workthread.join(); - exit_thread = false; - workthread = std::thread(&cameraview_panel::workthread_func, this); - } - - if (!texture) { - texture.emplace(); - texture->make_stub(); - } - - texture->bind(0); - - { - std::lock_guard lock(mutex); - if (image_ptr) { - - glActiveTexture(GL_TEXTURE0); - - glTexImage2D( - GL_TEXTURE_2D, 0, - GL_SRGB8_ALPHA8, - image_w, image_h, 0, - GL_RGBA, GL_UNSIGNED_BYTE, image_ptr); - - stbi_image_free(image_ptr); - - if (Global.python_mipmaps) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glGenerateMipmap(GL_TEXTURE_2D); - } - else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } - - image_ptr = nullptr; - } - } - cv.notify_all(); - - ImVec2 surface_size = ImGui::GetContentRegionAvail(); - ImGui::Image(reinterpret_cast(texture->id), surface_size); -} - -void ui::cameraview_panel::workthread_func() -{ - if (!device) - device = std::make_unique(); - - while (!exit_thread) { - uint8_t *buffer = nullptr; - size_t len = device->GetFrameFromStream((char**)&buffer); - - if (buffer) { - int w, h; - stbi_set_flip_vertically_on_load(0); - uint8_t *image = stbi_load_from_memory(buffer, len, &w, &h, nullptr, 4); - if (!image) - ErrorLog(std::string(stbi_failure_reason())); - - device->FreeFrameBuffer((char*)buffer); - - std::unique_lock lock(mutex); - if (image_ptr) - cv.wait(lock, [this]{return !image_ptr;}); - - image_w = w; - image_h = h; - image_ptr = image; - } - else - std::this_thread::sleep_for(std::chrono::milliseconds(5)); - } -} diff --git a/widgets/cameraview_vsdev.h b/widgets/cameraview_vsdev.h deleted file mode 100644 index d49b1798..00000000 --- a/widgets/cameraview_vsdev.h +++ /dev/null @@ -1,41 +0,0 @@ -#include "stdafx.h" -#include "uilayer.h" -#include "translation.h" -#include "extras/VS_Dev.h" - -namespace ui -{ -class cameraview_panel : public ui_panel -{ -public: - enum state_e { - IDLE, - PREVIEW, - RECORDING - }; - -private: - std::atomic_bool exit_thread = true; - std::thread workthread; - - uint8_t* image_ptr = nullptr; - int image_w, image_h; - - std::mutex mutex; - std::condition_variable cv; - - std::optional texture; - - std::unique_ptr device; - - void workthread_func(); - - public: - cameraview_panel(); - ~cameraview_panel(); - - void render() override; - void render_contents() override; - bool set_state(state_e e); -}; -} // namespace ui