From 6db547269cbe14be9e45c7acf28ea20f306d5c04 Mon Sep 17 00:00:00 2001 From: mgjer Date: Sun, 24 Nov 2024 13:43:58 +0100 Subject: [PATCH 01/11] disabled ycbcr shader sampling extension --- include/Viewer/Core/RenderResource.h | 2 +- src/CRLCamera/CameraConnection.cpp | 121 ++++++++++++++------------- src/Core/VulkanDevice.cpp | 3 + src/ImGui/GuiManager.cpp | 2 +- src/ModelLoaders/CRLCameraModels.cpp | 2 +- src/ModelLoaders/CustomModels.cpp | 4 +- src/ModelLoaders/ImageView.cpp | 2 +- 7 files changed, 71 insertions(+), 65 deletions(-) diff --git a/include/Viewer/Core/RenderResource.h b/include/Viewer/Core/RenderResource.h index d4485d6c9..3f4a55742 100644 --- a/include/Viewer/Core/RenderResource.h +++ b/include/Viewer/Core/RenderResource.h @@ -380,7 +380,7 @@ namespace RenderResource { VkResult res = vkCreateGraphicsPipelines(device->m_LogicalDevice, nullptr, 1, &pipelineCI, nullptr, &data.pipeline); if (res != VK_SUCCESS) - throw std::runtime_error("Failed to create graphics m_Pipeline"); + throw std::runtime_error("Failed to create graphics pipeline: RenderResource"); } }; } diff --git a/src/CRLCamera/CameraConnection.cpp b/src/CRLCamera/CameraConnection.cpp index 8d96a02ae..55e6bbd45 100644 --- a/src/CRLCamera/CameraConnection.cpp +++ b/src/CRLCamera/CameraConnection.cpp @@ -833,10 +833,11 @@ namespace VkRender::MultiSense { app->updateUIDataBlock(*dev, app->camPtr); + /* Log::Logger::getInstance()->info("Attempting to restore last session from .ini runtime config file"); if (!isRemoteHead) app->getProfileFromIni(*dev); - + */ // Set the resolution read from config file const auto &info = app->camPtr.getCameraInfo(dev->channelConnections.front()).devInfo; dev->cameraName = info.name; @@ -903,71 +904,73 @@ namespace VkRender::MultiSense { Log::Logger::getInstance()->info("Disconnecting profile {} using camera {}", dev->name.c_str(), dev->cameraName.c_str()); // Save settings to file. Attempt to create a new file if it doesn't exist - CSimpleIniA ini; - ini.SetUnicode(); - auto filePath = (Utils::getSystemCachePath() / "crl.ini"); - SI_Error rc = ini.LoadFile(filePath.c_str()); - if (rc < 0) { - // File doesn't exist error, then create one - if (rc == SI_FILE && errno == ENOENT) { - std::ofstream output(filePath.c_str()); - output.close(); - rc = ini.LoadFile(filePath.c_str()); - } else - Log::Logger::getInstance()->error("Failed to create profile configuration file\n"); - } - std::string CRLSerialNumber = dev->serialName; - // If sidebar is empty or we dont recognize any serial numbers in the crl.ini file then clear it. - // new m_Entry given we have a valid ini file m_Entry - if (rc >= 0 && !CRLSerialNumber.empty()) { - // Profile Data - addIniEntry(&ini, CRLSerialNumber, "ProfileName", dev->name); - addIniEntry(&ini, CRLSerialNumber, "AdapterName", dev->interfaceName); - addIniEntry(&ini, CRLSerialNumber, "CameraName", dev->cameraName); - addIniEntry(&ini, CRLSerialNumber, "IP", dev->IP); - addIniEntry(&ini, CRLSerialNumber, "AdapterIndex", std::to_string(dev->interfaceIndex)); - addIniEntry(&ini, CRLSerialNumber, "State", std::to_string(dev->state)); - // Preview Data per channel - for (const auto &ch: dev->channelConnections) { - std::string mode = "Mode" + std::to_string(ch); - if (dev->channelInfo.empty() || dev->channelInfo[ch].modes.empty()) - continue; - - auto resMode = dev->channelInfo[ch].modes[dev->channelInfo[ch].selectedModeIndex]; - if (Utils::stringToCameraResolution(resMode) == CRL_RESOLUTION_NONE) - resMode = "0"; - - addIniEntry(&ini, CRLSerialNumber, mode, - std::to_string(static_cast(Utils::stringToCameraResolution( - resMode)) - )); - addIniEntry(&ini, CRLSerialNumber, "Layout", std::to_string(static_cast(dev->layout))); - for (int i = 0; i <= CRL_PREVIEW_FOUR; ++i) { - std::string source = dev->win[static_cast(i)].selectedSource; - std::string remoteHead = std::to_string( - dev->win[static_cast(i)].selectedRemoteHeadIndex); - std::string key = "Preview" + std::to_string(i + 1); - std::string value = (source.append(":" + remoteHead)); - addIniEntry(&ini, CRLSerialNumber, key, value); - } - } - } - // delete m_Entry if we gave the disconnect and reset flag Otherwise just normal disconnect - // save the m_DataPtr back to the file - + /* + CSimpleIniA ini; + ini.SetUnicode(); + + auto filePath = (Utils::getSystemCachePath() / "crl.ini"); + SI_Error rc = ini.LoadFile(filePath.c_str()); + if (rc < 0) { + // File doesn't exist error, then create one + if (rc == SI_FILE && errno == ENOENT) { + std::ofstream output(filePath.c_str()); + output.close(); + rc = ini.LoadFile(filePath.c_str()); + } else + Log::Logger::getInstance()->error("Failed to create profile configuration file\n"); + } + std::string CRLSerialNumber = dev->serialName; + // If sidebar is empty or we dont recognize any serial numbers in the crl.ini file then clear it. + // new m_Entry given we have a valid ini file m_Entry + if (rc >= 0 && !CRLSerialNumber.empty()) { + // Profile Data + addIniEntry(&ini, CRLSerialNumber, "ProfileName", dev->name); + addIniEntry(&ini, CRLSerialNumber, "AdapterName", dev->interfaceName); + addIniEntry(&ini, CRLSerialNumber, "CameraName", dev->cameraName); + addIniEntry(&ini, CRLSerialNumber, "IP", dev->IP); + addIniEntry(&ini, CRLSerialNumber, "AdapterIndex", std::to_string(dev->interfaceIndex)); + addIniEntry(&ini, CRLSerialNumber, "State", std::to_string(dev->state)); + // Preview Data per channel + for (const auto &ch: dev->channelConnections) { + std::string mode = "Mode" + std::to_string(ch); + if (dev->channelInfo.empty() || dev->channelInfo[ch].modes.empty()) + continue; + + auto resMode = dev->channelInfo[ch].modes[dev->channelInfo[ch].selectedModeIndex]; + if (Utils::stringToCameraResolution(resMode) == CRL_RESOLUTION_NONE) + resMode = "0"; + + addIniEntry(&ini, CRLSerialNumber, mode, + std::to_string(static_cast(Utils::stringToCameraResolution( + resMode)) + )); + addIniEntry(&ini, CRLSerialNumber, "Layout", std::to_string(static_cast(dev->layout))); + for (int i = 0; i <= CRL_PREVIEW_FOUR; ++i) { + std::string source = dev->win[static_cast(i)].selectedSource; + std::string remoteHead = std::to_string( + dev->win[static_cast(i)].selectedRemoteHeadIndex); + std::string key = "Preview" + std::to_string(i + 1); + std::string value = (source.append(":" + remoteHead)); + addIniEntry(&ini, CRLSerialNumber, key, value); + } + } + } + // delete m_Entry if we gave the disconnect and reset flag Otherwise just normal disconnect + // save the m_DataPtr back to the file +*/ if (dev->state == CRL_STATE_DISCONNECT_AND_FORGET || dev->state == CRL_STATE_INTERRUPT_CONNECTION) { - ini.Delete(CRLSerialNumber.c_str(), nullptr); + //ini.Delete(CRLSerialNumber.c_str(), nullptr); dev->state = CRL_STATE_REMOVE_FROM_LIST; Log::Logger::getInstance()->info("Set dev {}'s state to CRL_STATE_REMOVE_FROM_LIST ", dev->name); - Log::Logger::getInstance()->info("Deleted saved profile for serial: {}", CRLSerialNumber); + //Log::Logger::getInstance()->info("Deleted saved profile for serial: {}", CRLSerialNumber); } else { dev->state = CRL_STATE_DISCONNECTED; Log::Logger::getInstance()->info("Set dev {}'s state to CRL_STATE_DISCONNECTED ", dev->name); } - rc = ini.SaveFile(filePath.c_str()); - if (rc < 0) { - Log::Logger::getInstance()->info("Failed to save crl.ini file. Err: {}", rc); - } + //rc = ini.SaveFile(filePath.c_str()); + //if (rc < 0) { + // Log::Logger::getInstance()->info("Failed to save crl.ini file. Err: {}", rc); + //} dev->channelInfo.clear(); } diff --git a/src/Core/VulkanDevice.cpp b/src/Core/VulkanDevice.cpp index 5e884e515..cf94fa84d 100644 --- a/src/Core/VulkanDevice.cpp +++ b/src/Core/VulkanDevice.cpp @@ -294,6 +294,9 @@ VulkanDevice::createLogicalDevice(VkPhysicalDeviceFeatures enabled, std::vector< * @return True if the extension is supported (present in the list read at m_Device creation time) */ bool VulkanDevice::extensionSupported(std::string extension) const { + if (VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME == extension) + return false; + return (std::find(m_SupportedExtensions.begin(), m_SupportedExtensions.end(), extension) != m_SupportedExtensions.end()); } diff --git a/src/ImGui/GuiManager.cpp b/src/ImGui/GuiManager.cpp index d69f3657a..fe3b0674b 100644 --- a/src/ImGui/GuiManager.cpp +++ b/src/ImGui/GuiManager.cpp @@ -305,7 +305,7 @@ namespace VkRender { if (vkCreateGraphicsPipelines(device->m_LogicalDevice, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipeline) != VK_SUCCESS) - throw std::runtime_error("Failed to create graphics m_Pipeline"); + throw std::runtime_error("Failed to create graphics pipeline: GuiManager"); } diff --git a/src/ModelLoaders/CRLCameraModels.cpp b/src/ModelLoaders/CRLCameraModels.cpp index 2e35e4356..75f662715 100644 --- a/src/ModelLoaders/CRLCameraModels.cpp +++ b/src/ModelLoaders/CRLCameraModels.cpp @@ -679,7 +679,7 @@ CRLCameraModels::createPipeline(VkRenderPass pT, std::vectorm_LogicalDevice, VK_NULL_HANDLE, 1, &pipelineCI, nullptr, pPipelineT); if (res != VK_SUCCESS) - throw std::runtime_error("Failed to create graphics m_Pipeline"); + throw std::runtime_error("Failed to create graphics pipeline: CRLCameraModels"); } diff --git a/src/ModelLoaders/CustomModels.cpp b/src/ModelLoaders/CustomModels.cpp index baf4e46c1..9340839cb 100644 --- a/src/ModelLoaders/CustomModels.cpp +++ b/src/ModelLoaders/CustomModels.cpp @@ -250,13 +250,13 @@ void CustomModels::createGraphicsPipeline(std::vectorm_LogicalDevice, nullptr, 1, &pipelineCI, nullptr, &pipelines[i]); if (res != VK_SUCCESS) - throw std::runtime_error("Failed to create graphics m_Pipeline"); + throw std::runtime_error("Failed to create graphics pipeline: CustomModels 1/2"); pipelineCI.renderPass = (*renderer->secondaryRenderPasses)[0].renderPass; res = vkCreateGraphicsPipelines(vulkanDevice->m_LogicalDevice, nullptr, 1, &pipelineCI, nullptr, &pipelinesSecondary[i]); if (res != VK_SUCCESS) - throw std::runtime_error("Failed to create graphics m_Pipeline"); + throw std::runtime_error("Failed to create graphics pipeline: CustomModels 2/2"); } } diff --git a/src/ModelLoaders/ImageView.cpp b/src/ModelLoaders/ImageView.cpp index bcb17f22d..6468230eb 100644 --- a/src/ModelLoaders/ImageView.cpp +++ b/src/ModelLoaders/ImageView.cpp @@ -348,7 +348,7 @@ void ImageView::createGraphicsPipeline() { nullptr, &m_model->resources[j].pipeline[i]); if (res != VK_SUCCESS) - throw std::runtime_error("Failed to create graphics m_Pipeline"); + throw std::runtime_error("Failed to create graphics pipeline: ImageView"); } } } From 82c75eb084d8c288215f34eb5fc6102dc7859e9e Mon Sep 17 00:00:00 2001 From: mgjer Date: Sun, 24 Nov 2024 14:01:41 +0100 Subject: [PATCH 02/11] Disabled ycbcr extension and added more logging --- .../Tools/Windows/build_installer_locally.ps1 | 28 +++++++++---------- Assets/Tools/Windows/inno_setup_script.iss | 12 ++++---- CMakeLists.txt | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Assets/Tools/Windows/build_installer_locally.ps1 b/Assets/Tools/Windows/build_installer_locally.ps1 index 9b4a5d396..271c63324 100644 --- a/Assets/Tools/Windows/build_installer_locally.ps1 +++ b/Assets/Tools/Windows/build_installer_locally.ps1 @@ -28,19 +28,19 @@ Write-Host "You provided the version: $version" cmake -B . -DCMAKE_BUILD_TYPE=Release -DWARNINGS_AS_ERRORS=FALSE -DGIT_SUBMODULE=OFF $path cmake --build . --config Release --target install -- /m:10 -mkdir files -Copy-Item -Recurse ".\multisense_${version}_amd64\*" .\files\ - -mv .\files\Assets\Tools\Windows\inno_setup_script.iss .\ -mv .\files\Assets\Tools\compile.sh .\ -mv .\files\Assets\Tools\install_spirv_compiler.sh .\ -mv .\files\Assets\Tools\monitor_memory_usage.py .\ -mv .\files\Assets\Tools\Windows\build_installer.ps1 .\ -mv .\files\Assets\Tools\Windows\build_installer_locally.ps1 .\ -mv .\files\Assets\Tools\how_to_release .\ -rm -R .\files\Assets\Tools\Ubuntu -rm -R .\files\bin -rm -R .\files\include -rm -R .\files\lib +mkdir MultiSense-Viewer +Copy-Item -Recurse ".\multisense_${version}_amd64\*" .\MultiSense-Viewer\ + +mv .\MultiSense-Viewer\Assets\Tools\Windows\inno_setup_script.iss .\ -Force +mv .\MultiSense-Viewer\Assets\Tools\compile.sh .\ -Force +mv .\MultiSense-Viewer\Assets\Tools\install_spirv_compiler.sh .\ -Force +mv .\MultiSense-Viewer\Assets\Tools\monitor_memory_usage.py .\ -Force +mv .\MultiSense-Viewer\Assets\Tools\Windows\build_installer.ps1 .\ -Force +mv .\MultiSense-Viewer\Assets\Tools\Windows\build_installer_locally.ps1 .\ -Force +mv .\MultiSense-Viewer\Assets\Tools\how_to_release.md .\ -Force +rm -R .\MultiSense-Viewer\Assets\Tools\Ubuntu +rm -R .\MultiSense-Viewer\bin +rm -R .\MultiSense-Viewer\include +rm -R .\MultiSense-Viewer\lib & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" .\inno_setup_script.iss \ No newline at end of file diff --git a/Assets/Tools/Windows/inno_setup_script.iss b/Assets/Tools/Windows/inno_setup_script.iss index eea85a92e..cbc5079c2 100644 --- a/Assets/Tools/Windows/inno_setup_script.iss +++ b/Assets/Tools/Windows/inno_setup_script.iss @@ -32,8 +32,8 @@ OutputBaseFilename=MultiSenseSetup Compression=lzma SolidCompression=yes WizardStyle=modern -SetupIconFile=.\MultiSense_viewer\Assets\Tools\Windows\{#MyAppSetupIcoName} -UninstallDisplayIcon=.\MultiSense_viewer\Assets\Tools\Windows\{#MyAppSetupIcoName} +SetupIconFile=.\MultiSense-Viewer\Assets\Tools\Windows\{#MyAppSetupIcoName} +UninstallDisplayIcon=.\MultiSense-Viewer\Assets\Tools\Windows\{#MyAppSetupIcoName} UsePreviousAppDir=no [Languages] @@ -43,10 +43,10 @@ Name: "english"; MessagesFile: "compiler:Default.isl" Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] -Source: "MultiSense_viewer\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "MultiSense_viewer\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "MultiSense_viewer\AutoConnect.exe"; DestDir: "{app}"; Flags: ignoreversion -; NOTE: Don't use "Flags: ignoreversion" on any shared system MultiSense_viewer +Source: "MultiSense-Viewer\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: "MultiSense-Viewer\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "MultiSense-Viewer\AutoConnect.exe"; DestDir: "{app}"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system MultiSense-Viewer [Registry] Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue diff --git a/CMakeLists.txt b/CMakeLists.txt index 2152dc1b3..6b6d72ccf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Set application version. Remember that it should always match the pushed tag in the form of v1.*-* set(VERSION_MAJOR "1") set(VERSION_MINOR "1") -set(VERSION_PATCH "5") +set(VERSION_PATCH "6") set(ARCHITECTURE "amd64") # Set install directory. Used to generate installers for both Windows and Ubuntu using their native approaches From 97e23152d547bd6c2946d72c10f3c017cfd792dc Mon Sep 17 00:00:00 2001 From: magnus Date: Sun, 24 Nov 2024 15:22:50 +0100 Subject: [PATCH 03/11] updated windows descriptions --- .github/workflows/workflow.yml | 2 +- .github/workflows/workflow_pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index fa570cc07..6983153a9 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -109,7 +109,7 @@ jobs: BuildWindows: - name: Build For Windows + name: Compile Check for Windows needs: [ReleaseJob, VersionJob] # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. # You can convert this to a matrix build if you need cross-platform coverage. diff --git a/.github/workflows/workflow_pr.yml b/.github/workflows/workflow_pr.yml index d8d2fae83..89878a3fc 100644 --- a/.github/workflows/workflow_pr.yml +++ b/.github/workflows/workflow_pr.yml @@ -61,7 +61,7 @@ jobs: BuildWindows: - name: Build and Create Installer for Windows + name: Compile Check for Windows needs: [VersionJob] runs-on: windows-2022 steps: From 340a139018bc6a71cfee4def57b13af52c295e37 Mon Sep 17 00:00:00 2001 From: mgjerde Date: Tue, 3 Dec 2024 20:58:20 +0100 Subject: [PATCH 04/11] Added more logs to detect color stream crash --- include/Viewer/ImGui/SideBarLayer.h | 16 ++++++---------- .../MultiSenseRenderer/Pointcloud/PointCloud.cpp | 4 +++- src/CRLCamera/CRLPhysicalCamera.cpp | 2 +- src/Core/Texture.cpp | 6 +++--- src/Core/VulkanDevice.cpp | 3 +++ src/ModelLoaders/CRLCameraModels.cpp | 7 +++++-- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/include/Viewer/ImGui/SideBarLayer.h b/include/Viewer/ImGui/SideBarLayer.h index 315f10f52..6a61fcaf0 100644 --- a/include/Viewer/ImGui/SideBarLayer.h +++ b/include/Viewer/ImGui/SideBarLayer.h @@ -101,7 +101,7 @@ class SideBarLayer : public VkRender::Layer { std::vector interfaceIDList; // Windows required std::vector indexList; - int connectMethodSelector = 0; + int connectMethodSelector = MANUAL_CONNECT; ImGuiTextBuffer Buf; ImVector LineOffsets; // Index to lines offset. We maintain this with AddLog() calls. ImVector colors; @@ -695,6 +695,7 @@ class SideBarLayer : public VkRender::Layer { /** SELECT METHOD FOR CONNECTION FIELD */ + /* ImGui::Dummy(ImVec2(20.0f, 0.0f)); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Text, VkRender::Colors::CRLTextGray); @@ -734,21 +735,16 @@ class SideBarLayer : public VkRender::Layer { handles->usageMonitor->userClickAction("Manual", "ImageButtonText", ImGui::GetCurrentWindow()->Name); } ImGui::PopFont(); - /* - ImGui::SameLine(0, 30.0f); - (ImGui::ImageButtonText("Virtual", &connectMethodSelector, VIRTUAL_CONNECT, ImVec2(125.0f, 55.0f), - handles->info->imageButtonTextureDescriptor[5], ImVec2(40.0f, 40.0f), uv0, uv1, - bg_col, - tint_col)); - */ + ImGui::PopStyleVar(); //ImGui::EndChild(); - ImGui::PopStyleColor(); // ImGuiCol_FrameBg ImGui::PopStyleVar(2); // RadioButton - autoDetectCamera(); + */ + ImGui::PopStyleColor(); // ImGuiCol_FrameBg + /** AUTOCONNECT FIELD BEGINS HERE*/ if (connectMethodSelector == AUTO_CONNECT) { adapterUtils.stopAdapterScan(); // Stop scan if we select manual as autoconnect will run its own scan diff --git a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp index d9033aed1..7fcb47991 100644 --- a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp +++ b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp @@ -170,6 +170,8 @@ bool PointCloud::prepareTexture(VkRender::Device &dev) { model->createEmptyTexture(width, height, VkRender::CRL_DISPARITY_IMAGE, true, lumaOrColor); VkPipelineShaderStageCreateInfo vs = loadShader("spv/pointcloud.vert", VK_SHADER_STAGE_VERTEX_BIT); VkPipelineShaderStageCreateInfo fs = loadShader("spv/pointcloud.frag", VK_SHADER_STAGE_FRAGMENT_BIT); + Log::Logger::getInstance()->info("Loading Pointcloud script. Size: {}x{}", width , height); + std::vector shaders = {{vs}, {fs}}; CRLCameraModels::createRenderPipeline(shaders, model.get(), &renderUtils); @@ -186,7 +188,7 @@ bool PointCloud::prepareTexture(VkRender::Device &dev) { buf->scale = renderData.crlCamera->getCameraInfo(0).pointCloudScale; buf->pointSize = pointSize; Log::Logger::getInstance()->info( - "Transforming depth image to point cloud with focal length {} and point cloud scale {}. Image size is ({}, {})", + "Transforming depth image to point cloud with focal length {} and point cloud scale {}. Multisens imgConf size is ({}, {})", renderData.crlCamera->getCameraInfo(0).focalLength, renderData.crlCamera->getCameraInfo(0).pointCloudScale, renderData.crlCamera->getCameraInfo(0).imgConf.width(), renderData.crlCamera->getCameraInfo(0).imgConf.height()); return true; } else { diff --git a/src/CRLCamera/CRLPhysicalCamera.cpp b/src/CRLCamera/CRLPhysicalCamera.cpp index 585a58c0f..13257f730 100644 --- a/src/CRLCamera/CRLPhysicalCamera.cpp +++ b/src/CRLCamera/CRLPhysicalCamera.cpp @@ -71,7 +71,7 @@ namespace VkRender::MultiSense { channelMap[static_cast(0)].get()->ptr()->getDeviceInfo(devInfo); Log::Logger::getInstance()->trace("We got a connection! Device info: {}, {}", devInfo.name, devInfo.buildDate); - setMtu(1500, static_cast(0)); + setMtu(7200, static_cast(0)); if (!updateCameraInfo(const_cast(dev), static_cast(0))) { Log::Logger::getInstance()->error( diff --git a/src/Core/Texture.cpp b/src/Core/Texture.cpp index c137cec86..b57f25cab 100644 --- a/src/Core/Texture.cpp +++ b/src/Core/Texture.cpp @@ -903,7 +903,7 @@ TextureVideo::TextureVideo(uint32_t texWidth, uint32_t texHeight, VulkanDevice * CHECK_RESULT( vkMapMemory(device->m_LogicalDevice, m_TexMem, 0, m_TexSize, 0, reinterpret_cast( &m_DataPtr))) - Log::Logger::getInstance()->info("Allocated Texture GPU memory {} bytes with format {}", m_TexSize, static_cast(format)); + Log::Logger::getInstance()->info("Allocated Texture GPU memory {} bytes size: {}x{} with format {}", m_TexSize, m_Width , m_Height, static_cast(format)); if (m_TexSizeSecondary != 0) { CHECK_RESULT(device->createBuffer( @@ -914,8 +914,8 @@ TextureVideo::TextureVideo(uint32_t texWidth, uint32_t texHeight, VulkanDevice * &m_TexMemSecondary)) CHECK_RESULT(vkMapMemory(device->m_LogicalDevice, m_TexMemSecondary, 0, m_TexSizeSecondary, 0, reinterpret_cast( &m_DataPtrSecondary))) - Log::Logger::getInstance()->info("Allocated Secondary Texture GPU memory {} bytes with format {}", - m_TexSizeSecondary, static_cast(format)); + Log::Logger::getInstance()->info("Allocated Secondary Texture GPU memory {} bytes size: {}x{} with format {}", m_TexSize, m_Width , m_Height, static_cast(format)); + } updateDescriptor(); diff --git a/src/Core/VulkanDevice.cpp b/src/Core/VulkanDevice.cpp index cf94fa84d..4c4306211 100644 --- a/src/Core/VulkanDevice.cpp +++ b/src/Core/VulkanDevice.cpp @@ -262,6 +262,9 @@ VulkanDevice::createLogicalDevice(VkPhysicalDeviceFeatures enabled, std::vector< } + Log::Logger::getInstance()->info("Us ycbcr color extension supported? {}", std::find(m_SupportedExtensions.begin(), m_SupportedExtensions.end(), VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME) != + m_SupportedExtensions.end()); + if (!deviceExtensions.empty()) { for (const char *enabledExtension: deviceExtensions) { if (!extensionSupported(enabledExtension)) { diff --git a/src/ModelLoaders/CRLCameraModels.cpp b/src/ModelLoaders/CRLCameraModels.cpp index 75f662715..25625fcf2 100644 --- a/src/ModelLoaders/CRLCameraModels.cpp +++ b/src/ModelLoaders/CRLCameraModels.cpp @@ -245,8 +245,8 @@ bool CRLCameraModels::Model::getTextureDataPointers(VkRender::TextureData *tex, void CRLCameraModels::Model::createEmptyTexture(uint32_t width, uint32_t height, VkRender::CRLCameraDataType texType, bool forPointCloud, int isColorOrLuma) { - Log::Logger::getInstance()->info("Preparing Texture m_Image {}, {}, with type {}", width, height, - static_cast(texType)); + Log::Logger::getInstance()->info("Preparing Texture m_Image {}, {}, with type {}. Num textures: {}", width, height, + static_cast(texType), m_FramesInFlight); VkFormat format{}; for (uint32_t i = 0; i < m_FramesInFlight; ++i) { @@ -257,6 +257,9 @@ void CRLCameraModels::Model::createEmptyTexture(uint32_t width, uint32_t height, format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM; } else { format = VK_FORMAT_R8_UNORM; + Log::Logger::getInstance()->info("Preparing Textures for manual Ycbcr2RGB conversion {}x{} size to {}x{}", width, height, width/2, height/2, + static_cast(texType), m_FramesInFlight); + m_TextureChromaU[i] = std::make_unique(width / 2, height / 2, m_VulkanDevice, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_FORMAT_R8_UNORM); From 3aeaa02d7e110ea1ad871c02d0f3a1d7e6a291bd Mon Sep 17 00:00:00 2001 From: mgjerde Date: Tue, 3 Dec 2024 21:13:32 +0100 Subject: [PATCH 05/11] Added more logs to detect color stream crash --- .../Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp | 1 + .../MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp index 7fcb47991..0f95ce72d 100644 --- a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp +++ b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp @@ -77,6 +77,7 @@ void PointCloud::update() { auto depthTex = VkRender::TextureData(VkRender::CRL_DISPARITY_IMAGE, conf.width(), conf.height()); model->getTextureDataPointers(&depthTex, renderData.index); if (renderData.crlCamera->getCameraStream("Disparity Left", &depthTex, remoteHeadIndex)) { + Log::Logger::getInstance()->info("Uploading multisense data to GPU: {} for frame index {}. Image size: {}x{}", static_cast(tex.m_Type), renderData.index, tex.m_Width, tex.m_Height); model->updateTexture(depthTex.m_Type, renderData.index); } diff --git a/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp b/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp index e47de224c..b15db5492 100644 --- a/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp +++ b/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp @@ -102,6 +102,7 @@ void SingleLayout::update() { } // If we get MultiSense images then // Update the texture or update the GPU Texture + Log::Logger::getInstance()->info("Uploading multisense data to GPU: {} for frame index {}. Image size: {}x{}", static_cast(tex.m_Type), renderData.index, tex.m_Width, tex.m_Height); if (m_Model->updateTexture(textureType, renderData.index)) { state = DRAW_MULTISENSE; lastPresentedFrameID = tex.m_Id; From d0aa1a9c6cd5a4a73fee3e148d8d844c8fd2cba6 Mon Sep 17 00:00:00 2001 From: mgjerde Date: Tue, 10 Dec 2024 22:11:31 +0100 Subject: [PATCH 06/11] Default mtu setting to 1400 to accomodate disabled jumbo frames --- .../MultiSenseRenderer/Pointcloud/PointCloud.cpp | 2 +- .../Video/Previews/Single/SingleLayout.cpp | 2 +- src/CRLCamera/CRLPhysicalCamera.cpp | 11 ++++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp index 0f95ce72d..702723e6f 100644 --- a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp +++ b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp @@ -77,7 +77,7 @@ void PointCloud::update() { auto depthTex = VkRender::TextureData(VkRender::CRL_DISPARITY_IMAGE, conf.width(), conf.height()); model->getTextureDataPointers(&depthTex, renderData.index); if (renderData.crlCamera->getCameraStream("Disparity Left", &depthTex, remoteHeadIndex)) { - Log::Logger::getInstance()->info("Uploading multisense data to GPU: {} for frame index {}. Image size: {}x{}", static_cast(tex.m_Type), renderData.index, tex.m_Width, tex.m_Height); + //Log::Logger::getInstance()->info("Uploading multisense data to GPU: {} for frame index {}. Image size: {}x{}", static_cast(tex.m_Type), renderData.index, tex.m_Width, tex.m_Height); model->updateTexture(depthTex.m_Type, renderData.index); } diff --git a/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp b/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp index b15db5492..a867e3718 100644 --- a/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp +++ b/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp @@ -102,7 +102,7 @@ void SingleLayout::update() { } // If we get MultiSense images then // Update the texture or update the GPU Texture - Log::Logger::getInstance()->info("Uploading multisense data to GPU: {} for frame index {}. Image size: {}x{}", static_cast(tex.m_Type), renderData.index, tex.m_Width, tex.m_Height); + //Log::Logger::getInstance()->info("Uploading multisense data to GPU: {} for frame index {}. Image size: {}x{}", static_cast(tex.m_Type), renderData.index, tex.m_Width, tex.m_Height); if (m_Model->updateTexture(textureType, renderData.index)) { state = DRAW_MULTISENSE; lastPresentedFrameID = tex.m_Id; diff --git a/src/CRLCamera/CRLPhysicalCamera.cpp b/src/CRLCamera/CRLPhysicalCamera.cpp index 13257f730..52bf5a174 100644 --- a/src/CRLCamera/CRLPhysicalCamera.cpp +++ b/src/CRLCamera/CRLPhysicalCamera.cpp @@ -71,7 +71,7 @@ namespace VkRender::MultiSense { channelMap[static_cast(0)].get()->ptr()->getDeviceInfo(devInfo); Log::Logger::getInstance()->trace("We got a connection! Device info: {}, {}", devInfo.name, devInfo.buildDate); - setMtu(7200, static_cast(0)); + setMtu(1400, static_cast(0)); if (!updateCameraInfo(const_cast(dev), static_cast(0))) { Log::Logger::getInstance()->error( @@ -784,12 +784,9 @@ namespace VkRender::MultiSense { std::this_thread::sleep_for(std::chrono::milliseconds(300)); - if (crl::multisense::Status_Ok != - channelMap[channelID]->ptr()->getMtu(infoMap[channelID].sensorMTU)) { - Log::Logger::getInstance()->error("Failed to verify aux img conf"); - return false; - } - + int32_t getMtu = -1; + channelMap[channelID]->ptr()->getMtu(getMtu); + Log::Logger::getInstance()->info("Current mtu on channel {}", getMtu); if (status != crl::multisense::Status_Ok) { Log::Logger::getInstance()->info("Failed to set MTU {}", mtu); return false; From 70c744fba237209ed956095c5694ed3230df1103 Mon Sep 17 00:00:00 2001 From: magnus Date: Thu, 12 Dec 2024 11:16:25 +0100 Subject: [PATCH 07/11] Included Check_Result in log --- include/Viewer/ImGui/Layer.h | 2 +- include/Viewer/ImGui/SideBarLayer.h | 4 +--- .../Scripts/MultiSenseRenderer/Video/Previews/Quad/One.cpp | 2 -- .../MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp | 2 -- include/Viewer/Tools/Macros.h | 4 +++- src/CRLCamera/CameraConnection.cpp | 1 - 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/include/Viewer/ImGui/Layer.h b/include/Viewer/ImGui/Layer.h index eb0bee962..0efcf62ee 100644 --- a/include/Viewer/ImGui/Layer.h +++ b/include/Viewer/ImGui/Layer.h @@ -146,7 +146,7 @@ namespace VkRender { float addDeviceBottomPadding = 45.0f; float addDeviceWidth = 180.0f, addDeviceHeight = 35.0f; /** @brief Height of popupModal*/ - float popupHeight = 600.0f; + float popupHeight = 350.0f; /** @brief Width of popupModal*/ float popupWidth = 550.0f; /** @brief Width of popupModal*/ diff --git a/include/Viewer/ImGui/SideBarLayer.h b/include/Viewer/ImGui/SideBarLayer.h index 6a61fcaf0..7b76599f7 100644 --- a/include/Viewer/ImGui/SideBarLayer.h +++ b/include/Viewer/ImGui/SideBarLayer.h @@ -682,7 +682,7 @@ class SideBarLayer : public VkRender::Layer { ImGui::Dummy(ImVec2(20.0f, 0.0f)); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Text, VkRender::Colors::CRLTextGray); - ImGui::Text("1. Profile Name:"); + ImGui::Text("Profile Name:"); ImGui::PopStyleColor(); ImGui::PushStyleColor(ImGuiCol_FrameBg, VkRender::Colors::CRLDarkGray425); ImGui::Dummy(ImVec2(0.0f, 5.0f)); @@ -691,8 +691,6 @@ class SideBarLayer : public VkRender::Layer { ImGui::SetNextItemWidth(handles->info->popupWidth - 40.0f); ImGui::CustomInputTextWithHint("##InputProfileName", "MultiSense Profile", &m_Entry.profileName, ImGuiInputTextFlags_AutoSelectAll); - ImGui::Dummy(ImVec2(0.0f, 30.0f)); - /** SELECT METHOD FOR CONNECTION FIELD */ /* diff --git a/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Quad/One.cpp b/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Quad/One.cpp index 3170ae65b..a2538380a 100644 --- a/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Quad/One.cpp +++ b/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Quad/One.cpp @@ -220,8 +220,6 @@ void One::onUIUpdate(VkRender::GuiObjectHandles *uiHandle) { if (src == "Idle") { state = DRAW_NO_SOURCE; - } else if (src == "Compute") { - state = DRAW_MULTISENSE; } else { state = DRAW_NO_DATA; } diff --git a/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp b/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp index a867e3718..e87c6d0b2 100644 --- a/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp +++ b/include/Viewer/Scripts/MultiSenseRenderer/Video/Previews/Single/SingleLayout.cpp @@ -273,8 +273,6 @@ void SingleLayout::onUIUpdate(VkRender::GuiObjectHandles *uiHandle) { if (src == "Idle") { state = DRAW_NO_SOURCE; - } else if (src == "Compute") { - state = DRAW_MULTISENSE; } else { state = DRAW_NO_DATA; } diff --git a/include/Viewer/Tools/Macros.h b/include/Viewer/Tools/Macros.h index 6e85e2138..c9d5c081f 100644 --- a/include/Viewer/Tools/Macros.h +++ b/include/Viewer/Tools/Macros.h @@ -38,6 +38,7 @@ #include #include +#include "Viewer/Tools/Logger.h" #if defined(_MSC_VER) #define DISABLE_WARNING_PUSH __pragma(warning( push )) @@ -110,7 +111,8 @@ DISABLE_WARNING_USELESS_CAST { \ VkResult res = (f); \ if (res != VK_SUCCESS) \ - { \ + { \ + Log::Logger::getInstance()->fatal("Fatal Error: VkResult is {} in {} at {}", Macros::errorString(res) ,__FILE__ , __LINE__ ); \ std::cerr << "Fatal : VkResult is \"" << Macros::errorString(res) << "\" in " << __FILE__ << " at line " << __LINE__ << "\n"; \ assert(res == VK_SUCCESS); \ } \ diff --git a/src/CRLCamera/CameraConnection.cpp b/src/CRLCamera/CameraConnection.cpp index 55e6bbd45..2af5e82d2 100644 --- a/src/CRLCamera/CameraConnection.cpp +++ b/src/CRLCamera/CameraConnection.cpp @@ -894,7 +894,6 @@ namespace VkRender::MultiSense { // If we successfully connect //dev->channelConnections = app->camPtr.connect(dev, dev->interfaceName); Utils::initializeUIDataBlockWithTestData(*dev); - dev->channelInfo.front().availableSources.emplace_back("Compute"); dev->state = CRL_STATE_ACTIVE; Log::Logger::getInstance()->info("Set dev {}'s state to CRL_STATE_ACTIVE ", dev->name); } From 49de8a5f7a3b0d998f6602dbc50602aa24f92625 Mon Sep 17 00:00:00 2001 From: magnus Date: Thu, 12 Dec 2024 11:39:51 +0100 Subject: [PATCH 08/11] Added dependency for ubuntu 20.04 --- .github/workflows/workflow.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 6983153a9..cba3debe2 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -76,27 +76,20 @@ jobs: tag_name: ${{ github.ref_name }} release_name: ${{ github.ref_name }} body: | - # MultiSense Viewer 1.1.1 + # MultiSense Viewer - Not compatible with remote head systems. Revert to 1.0.0 for that purpose. - ### New features: - - Visualize IMU data with corresponding 3D model (MultiSense: KS-21, S27, S30) - - Image enhancements (Normalize disparity, apply colormaps, interpolate) - - Zoom controls in 2D view - - Colorize Point Cloud if the AUX camera is present - - Record point clouds as .ply files - - Record IMU data - - AUX camera exposure control with LibMultiSense 6.0.0 - - Reloadable spirv-shaders (useful for testing various gpu-applied filters) - - Various optimizations and more reliable AutoConnect - - Opt-in for anonymous usage statistics - - Image effects (Edge detection, blurring, embossing, sharpening) - + + ## Installing: + ### Windows users: 1. Install WinPcap_driver.exe to let the viewer configure network settings automatically 2. Download and run the Windows installer: MultiSenseSetup.exe ### Ubuntu users: + Make sure you have updated graphics drivers, ffmpeg and policykit installed. Can be installed via apt pacakge manager: + apt install ffmpeg libvulkan1 policykit-1 + Ubuntu 20.04 Users may also require to install: apt install libdeflate-dev 1. Download and install the multisense_1.1-0_amd64.deb package using your default package manager or type in terminal: $ dpkg --install ~/Downloads/multisense_1.1-0_amd64.deb 2. Launch through start menu or run a start script at From eabc7bdd87bff9ab0cad2fc390c1315c44138b2a Mon Sep 17 00:00:00 2001 From: mgjer Date: Thu, 12 Dec 2024 11:22:34 +0100 Subject: [PATCH 09/11] mtu setting updates --- include/Viewer/CRLCamera/CRLPhysicalCamera.h | 2 +- .../Viewer/Core/MultiSenseDeviceDefinitions.h | 2 +- .../ImGui/MainLayerExt/SensorConfigurationExt.h | 16 +++++++--------- src/CRLCamera/CRLPhysicalCamera.cpp | 2 ++ src/CRLCamera/CameraConnection.cpp | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/Viewer/CRLCamera/CRLPhysicalCamera.h b/include/Viewer/CRLCamera/CRLPhysicalCamera.h index ce23e3a5f..a7cc1ef1c 100644 --- a/include/Viewer/CRLCamera/CRLPhysicalCamera.h +++ b/include/Viewer/CRLCamera/CRLPhysicalCamera.h @@ -291,7 +291,7 @@ namespace VkRender::MultiSense { std::vector supportedDeviceModes{}; crl::multisense::DataSource supportedSources{0}; std::vector rawImages{}; - int sensorMTU = 1500; + int sensorMTU = 1400; crl::multisense::image::Calibration calibration{}; glm::mat4 QMat{}; glm::mat4 KColorMat{}; diff --git a/include/Viewer/Core/MultiSenseDeviceDefinitions.h b/include/Viewer/Core/MultiSenseDeviceDefinitions.h index 5eb00dd5c..e49b43086 100644 --- a/include/Viewer/Core/MultiSenseDeviceDefinitions.h +++ b/include/Viewer/Core/MultiSenseDeviceDefinitions.h @@ -223,7 +223,7 @@ namespace VkRender { float gain = 1.0f; float fps = 30.0f; float stereoPostFilterStrength = 0.5f; - int mtu = 7200; + int mtu = 1400; bool hdrEnabled = false; float gamma = 2.0f; bool hdr = false; diff --git a/include/Viewer/ImGui/MainLayerExt/SensorConfigurationExt.h b/include/Viewer/ImGui/MainLayerExt/SensorConfigurationExt.h index 9c95b8a23..4f490b241 100644 --- a/include/Viewer/ImGui/MainLayerExt/SensorConfigurationExt.h +++ b/include/Viewer/ImGui/MainLayerExt/SensorConfigurationExt.h @@ -816,22 +816,19 @@ class SensorConfigurationExt : public VkRender::Layer { ImGui::SameLine(0, textSpacing - txtSize.x); ImGui::PushStyleColor(ImGuiCol_Text, VkRender::Colors::CRLTextWhite); static int mtuValues[] = {576, 1280, 1400, 1500, 2000, 4000, 7200, 9000}; // common MTU values - static int customMTU = 7200; - static int mtuIndex = 6; // Default index for the slider (1500 as default) - + static int mtuIndex = 2; // Default index for the slider (1500 as default) + auto& customMTU = d.parameters.stereo.mtu; + static bool isCustomValue = false; if (ImGui::SliderInt("##MTU", &mtuIndex, 0, IM_ARRAYSIZE(mtuValues) - 1, - std::to_string(mtuValues[mtuIndex]).c_str())) { - handles->usageMonitor->userClickAction("##MTU setting", "SliderFloat", - ImGui::GetCurrentWindow()->Name); + isCustomValue ? std::to_string(customMTU).c_str() : std::to_string(mtuValues[mtuIndex]).c_str(), ImGuiSliderFlags_NoInput | ImGuiSliderFlags_AlwaysClamp)) { d.parameters.stereo.mtu = mtuValues[mtuIndex]; + isCustomValue = false; } d.parameters.stereo.update |= ImGui::IsItemDeactivatedAfterEdit(); - // Handle right-click context menu to enter custom MTU value if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Right)) { ImGui::OpenPopup("MTU_InputPopup"); // Open the popup when right-clicked } - if (ImGui::BeginPopup("MTU_InputPopup")) { ImGui::Text("Enter custom MTU value:"); if (ImGui::InputInt("##CustomMTUInput", &customMTU)) { @@ -842,8 +839,9 @@ class SensorConfigurationExt : public VkRender::Layer { bool btnClick = ImGui::Button("Set"); if (btnClick) { ImGui::CloseCurrentPopup(); - d.parameters.stereo.mtu = static_cast(customMTU); // Update the MTU with the custom value + d.parameters.stereo.mtu = customMTU; // Update the MTU with the custom value d.parameters.stereo.update |= btnClick; + isCustomValue = true; } ImGui::EndPopup(); } diff --git a/src/CRLCamera/CRLPhysicalCamera.cpp b/src/CRLCamera/CRLPhysicalCamera.cpp index 52bf5a174..845ebfe50 100644 --- a/src/CRLCamera/CRLPhysicalCamera.cpp +++ b/src/CRLCamera/CRLPhysicalCamera.cpp @@ -786,6 +786,8 @@ namespace VkRender::MultiSense { int32_t getMtu = -1; channelMap[channelID]->ptr()->getMtu(getMtu); + updateAndLog([&](auto &data) { return channelMap[channelID]->ptr()->getMtu(data); }, infoMap[channelID].sensorMTU, "sensorMTU"); + Log::Logger::getInstance()->info("Current mtu on channel {}", getMtu); if (status != crl::multisense::Status_Ok) { Log::Logger::getInstance()->info("Failed to set MTU {}", mtu); diff --git a/src/CRLCamera/CameraConnection.cpp b/src/CRLCamera/CameraConnection.cpp index 2af5e82d2..ee5e00c54 100644 --- a/src/CRLCamera/CameraConnection.cpp +++ b/src/CRLCamera/CameraConnection.cpp @@ -103,7 +103,7 @@ namespace VkRender::MultiSense { p->light.flashing = lightConf.getFlash(); p->light.startupTime = static_cast(lightConf.getStartupTime()) / 1000.0f; p->stereo.stereoPostFilterStrength = conf.stereoPostFilterStrength(); - //p->stereo.mtu = camPtr.getCameraInfo(dev->configRemoteHead).sensorMTU; + p->stereo.mtu = camPtr.getCameraInfo(dev->configRemoteHead).sensorMTU; dev->parameters.updateGuiParams = false; } From 5cf26e6a3539e9cb10f7a9f8e823c86c1f5d324c Mon Sep 17 00:00:00 2001 From: Magnus Gjerde Date: Wed, 18 Dec 2024 11:06:53 +0100 Subject: [PATCH 10/11] Fixed a color stream crash on windows pc's that occurs on full res "Color Aux" stream when ycbcr sampler is not present in the graphics driver. Added link to network setup for manual connect --- include/Viewer/Core/Validation.h | 2 +- .../ImGui/MainLayerExt/ControlArea2DExt.h | 3 +- include/Viewer/ImGui/SideBarLayer.h | 573 +++++++++++------- .../Pointcloud/PointCloud.cpp | 47 +- .../Pointcloud/PointCloud.h | 3 +- src/CRLCamera/CRLPhysicalCamera.cpp | 10 +- src/CRLCamera/CameraConnection.cpp | 2 +- src/Core/VulkanDevice.cpp | 3 - 8 files changed, 385 insertions(+), 258 deletions(-) diff --git a/include/Viewer/Core/Validation.h b/include/Viewer/Core/Validation.h index b9db3ad9c..fa532ef12 100644 --- a/include/Viewer/Core/Validation.h +++ b/include/Viewer/Core/Validation.h @@ -87,7 +87,7 @@ namespace Validation { Log::Logger::getInstance()->error("Validation error: {}", pCallbackData->pMessage); } else if (messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) { - Log::Logger::getInstance()->info("Validation info: {}", pCallbackData->pMessage); + Log::Logger::getInstance()->trace("Validation info: {}", pCallbackData->pMessage); } return VK_FALSE; diff --git a/include/Viewer/ImGui/MainLayerExt/ControlArea2DExt.h b/include/Viewer/ImGui/MainLayerExt/ControlArea2DExt.h index 71f12efa4..56f776b24 100644 --- a/include/Viewer/ImGui/MainLayerExt/ControlArea2DExt.h +++ b/include/Viewer/ImGui/MainLayerExt/ControlArea2DExt.h @@ -138,7 +138,8 @@ class ControlArea2DExt : public VkRender::Layer { /** @brief Drop down for compression selection */ { - static std::vector saveFormat = {"Select format:", "tiff", "png", "rosbag"}; + //static std::vector saveFormat = {"Select format:", "tiff", "png", "rosbag"}; + static std::vector saveFormat = {"Select format:", "tiff", "png"}; static size_t selector = 0; ImGui::SetNextItemWidth(ImGui::GetWindowSize().x - ImGui::GetCursorPosX() - 5.0f); diff --git a/include/Viewer/ImGui/SideBarLayer.h b/include/Viewer/ImGui/SideBarLayer.h index 7b76599f7..5d9b2a147 100644 --- a/include/Viewer/ImGui/SideBarLayer.h +++ b/include/Viewer/ImGui/SideBarLayer.h @@ -71,14 +71,16 @@ #endif -class SideBarLayer : public VkRender::Layer { +class SideBarLayer : public VkRender::Layer +{ public: - - typedef enum LOG_COLOR { + typedef enum LOG_COLOR + { LOG_COLOR_GRAY = 0, LOG_COLOR_GREEN = 1, LOG_COLOR_RED = 2 } LOG_COLOR; + VkRender::EntryConnectDevice m_Entry; std::vector entryConnectDeviceList; uint32_t gifFrameIndex = 0; @@ -91,7 +93,9 @@ class SideBarLayer : public VkRender::Layer { std::string dots; bool btnConnect = false; bool enableConnectButton = true; - enum { + + enum + { MANUAL_CONNECT = 1, AUTO_CONNECT = 2 }; @@ -118,15 +122,18 @@ class SideBarLayer : public VkRender::Layer { #endif std::string btnLabel = "Start"; - void onAttach() override { + void onAttach() override + { gifFrameTimer = std::chrono::steady_clock::now(); gifFrameTimer2 = std::chrono::steady_clock::now(); } - void onFinishedRender() override { + void onFinishedRender() override + { } - void onDetach() override { + void onDetach() override + { adapterUtils.stopAdapterScan(); #ifdef __linux__ if (autoConnectProcess != nullptr) { @@ -134,30 +141,35 @@ class SideBarLayer : public VkRender::Layer { reader->sendStopSignal(); pclose(autoConnectProcess); #else - if (shellInfo.hProcess != nullptr) { - if (reader) - reader->sendStopSignal(); - if (TerminateProcess(shellInfo.hProcess, 1) != 0) { - Log::Logger::getInstance()->info("Terminated AutoConnect program"); - } else - Log::Logger::getInstance()->info("Failed to terminate AutoConnect program"); + if (shellInfo.hProcess != nullptr) + { + if (reader) + reader->sendStopSignal(); + if (TerminateProcess(shellInfo.hProcess, 1) != 0) + { + Log::Logger::getInstance()->info("Terminated AutoConnect program"); + } + else + Log::Logger::getInstance()->info("Failed to terminate AutoConnect program"); #endif } auto startTime = std::chrono::steady_clock::now(); // Make sure adapter utils scanning thread is shut down correctly - while (true) { + while (true) + { Log::Logger::getInstance()->traceWithFrequency("shutdown adapterutils: ", 1000, "Waiting for adapterUtils to shutdown"); if (adapterUtils.shutdownReady()) break; } - auto timeSpan = std::chrono::duration_cast>( - std::chrono::steady_clock::now() - startTime); + auto timeSpan = std::chrono::duration_cast>( + std::chrono::steady_clock::now() - startTime); Log::Logger::getInstance()->trace("Adapter utils took {}s to shut down", timeSpan.count()); } - static void openURL(const std::string &url) { + static void openURL(const std::string& url) + { #ifdef _WIN32 ShellExecuteA(nullptr, "open", url.c_str(), nullptr, nullptr, SW_SHOWNORMAL); #elif __linux__ @@ -169,8 +181,10 @@ class SideBarLayer : public VkRender::Layer { #endif } - static void askUsageLoggingPermissionPopUp(VkRender::GuiObjectHandles *handle) { - if (VkRender::RendererConfig::getInstance().getUserSetting().askForUsageLoggingPermissions) { + static void askUsageLoggingPermissionPopUp(VkRender::GuiObjectHandles* handle) + { + if (VkRender::RendererConfig::getInstance().getUserSetting().askForUsageLoggingPermissions) + { ImGui::OpenPopup("Anonymous Usage Statistics"); auto user = VkRender::RendererConfig::getInstance().getUserSetting(); @@ -183,11 +197,15 @@ class SideBarLayer : public VkRender::Layer { ImVec2 anonymousWindowSize(500.0f, 180.0f); ImGui::SetNextWindowPos(ImVec2((handle->info->width / 2) - (anonymousWindowSize.x / 2), (handle->info->height / 2) - (anonymousWindowSize.y / 2) - 50.0f)); - if (ImGui::BeginPopupModal("Anonymous Usage Statistics", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { - std::string url = "https://github.com/carnegierobotics/multisense_viewer/blob/master/Assets/Generated/PrivacyPolicy.md"; + if (ImGui::BeginPopupModal("Anonymous Usage Statistics", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) + { + std::string url = + "https://github.com/carnegierobotics/multisense_viewer/blob/master/Assets/Generated/PrivacyPolicy.md"; static bool isLinkHovered = false; - ImVec4 blueLinkColor = isLinkHovered ? ImVec4(0.17f, 0.579f, 0.893f, 1.0f) : ImVec4(0.0f, 0.439f, 0.753f, - 1.0f); + ImVec4 blueLinkColor = isLinkHovered + ? ImVec4(0.17f, 0.579f, 0.893f, 1.0f) + : ImVec4(0.0f, 0.439f, 0.753f, + 1.0f); ImGui::Text("We would like to collect anonymous usage statistics to help improve our product."); ImGui::Text("Data collected will only be used for product improvement purposes"); @@ -200,7 +218,8 @@ class SideBarLayer : public VkRender::Layer { ImVec4(0, 0, 0, 0)); // Transparent button background when active ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::CalcTextSize("Privacy policy").x); - if (ImGui::Selectable("Privacy policy", false, ImGuiSelectableFlags_DontClosePopups)) { + if (ImGui::Selectable("Privacy policy", false, ImGuiSelectableFlags_DontClosePopups)) + { openURL(url); handle->usageMonitor->userClickAction("Privacy policy", "Selectable", ImGui::GetCurrentWindow()->Name); @@ -216,7 +235,8 @@ class SideBarLayer : public VkRender::Layer { bool update = ImGui::RadioButton("Yes", &radio_value, 1); ImGui::SameLine(); update |= ImGui::RadioButton("No", &radio_value, 0); - if (update) { + if (update) + { user.userConsentToSendLogs = radio_value; VkRender::RendererConfig::getInstance().setUserSetting(user); handle->usageMonitor->setSetting("user_consent_to_collect_statistics", radio_value ? "true" : "false"); @@ -226,7 +246,8 @@ class SideBarLayer : public VkRender::Layer { ImVec2 btnSize(120.0f, 0.0f); ImGui::SetCursorPosX((ImGui::GetWindowWidth() / 2) - (btnSize.x / 2)); - if (ImGui::Button("OK", btnSize)) { + if (ImGui::Button("OK", btnSize)) + { handle->usageMonitor->setSetting("ask_user_consent_to_collect_statistics", "false"); user.userConsentToSendLogs = radio_value; VkRender::RendererConfig::getInstance().setUserSetting(user); @@ -244,17 +265,18 @@ class SideBarLayer : public VkRender::Layer { ImGui::PopStyleVar(2); } - void onUIRender(VkRender::GuiObjectHandles *handles) override { - if (handles->renderer3D){ - - return; - } + void onUIRender(VkRender::GuiObjectHandles* handles) override + { + if (handles->renderer3D) + { + return; + } bool pOpen = true; ImGuiWindowFlags window_flags = 0; window_flags = - ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | - ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollWithMouse; + ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | + ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollWithMouse; ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always); ImGui::SetNextWindowSize(ImVec2(handles->info->sidebarWidth, handles->info->height)); ImGui::PushStyleColor(ImGuiCol_WindowBg, VkRender::Colors::CRLGray424Main); @@ -265,7 +287,8 @@ class SideBarLayer : public VkRender::Layer { askUsageLoggingPermissionPopUp(handles); ImGui::SetCursorPos(ImVec2(0.0f, 0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); - if (ImGui::Button("Settings", ImVec2(handles->info->sidebarWidth, 17.0f))) { + if (ImGui::Button("Settings", ImVec2(handles->info->sidebarWidth, 17.0f))) + { handles->showDebugWindow = !handles->showDebugWindow; handles->usageMonitor->userClickAction("Settings", "button", ImGui::GetCurrentWindow()->Name); } @@ -288,14 +311,15 @@ class SideBarLayer : public VkRender::Layer { } private: - void addLogLine(LOG_COLOR color, const char *fmt, ...) IM_FMTARGS(3) { + void addLogLine(LOG_COLOR color, const char* fmt, ...) IM_FMTARGS(3) { int old_size = Buf.size(); va_list args; va_start(args, fmt); Buf.appendfv(fmt, args); va_end(args); for (int new_size = Buf.size(); old_size < new_size; old_size++) - if (Buf[old_size] == '\n') { + if (Buf[old_size] == '\n') + { LineOffsets.push_back(old_size + 1); } colors.push_back(color); @@ -306,21 +330,26 @@ class SideBarLayer : public VkRender::Layer { * Should run once popup modal is opened * Periodically check the status of connected ethernet devices * */ - void autoDetectCamera() { + void autoDetectCamera() + { // if reader is not opened we don't start autoconnect program if (!reader) return; - if (startedAutoConnect) { + if (startedAutoConnect) + { // Try to open reader. TODO timeout or number of tries for opening if (!reader->isOpen) reader->open(); - else { - if (reader->read()) { + else + { + if (reader->read()) + { std::string str = reader->getLogLine(); if (!str.empty()) addLogLine(LOG_COLOR_GRAY, "%s", str.c_str()); - if (reader->stopRequested) { + if (reader->stopRequested) + { reader->sendStopSignal(); m_Entry.IP.clear(); @@ -337,8 +366,10 @@ class SideBarLayer : public VkRender::Layer { return; } #else - if (shellInfo.hProcess != nullptr) { - if (TerminateProcess(shellInfo.hProcess, 1) != 0) { + if (shellInfo.hProcess != nullptr) + { + if (TerminateProcess(shellInfo.hProcess, 1) != 0) + { Log::Logger::getInstance()->info("Stopped the auto connect process gracefully"); } shellInfo.hProcess = nullptr; @@ -351,17 +382,23 @@ class SideBarLayer : public VkRender::Layer { } // Same IP on same adapter is treated as the same camera std::vector entries = reader->getResult(); - for (const auto &entry: entries) { - if (!entry.cameraName.empty()) { + for (const auto& entry : entries) + { + if (!entry.cameraName.empty()) + { bool cameraExists = false; - for (const auto &e: entryConnectDeviceList) { + for (const auto& e : entryConnectDeviceList) + { if (e.IP == entry.IP && e.interfaceIndex == entry.interfaceIndex) cameraExists = true; } - if (!cameraExists) { - VkRender::EntryConnectDevice e{entry.IP, entry.interfaceName, entry.cameraName, - entry.interfaceIndex, - entry.description}; + if (!cameraExists) + { + VkRender::EntryConnectDevice e{ + entry.IP, entry.interfaceName, entry.cameraName, + entry.interfaceIndex, + entry.description + }; entryConnectDeviceList.push_back(e); } @@ -369,7 +406,9 @@ class SideBarLayer : public VkRender::Layer { } } } - } else { + } + else + { #ifdef __linux__ std::string fileName = "./AutoConnectLauncher.sh"; autoConnectProcess = popen((fileName).c_str(), "r"); @@ -392,26 +431,31 @@ class SideBarLayer : public VkRender::Layer { shellInfo.hInstApp = nullptr; bool instance = ShellExecuteExA(&shellInfo); - if (!instance) { + if (!instance) + { Log::Logger::getInstance()->info("Failed to start new process, error: %zu", GetLastError()); reader.reset(); btnLabel = "Start"; // Reset attempts - } else { + } + else + { startedAutoConnect = true; } #endif } } - static void createDefaultElement(VkRender::GuiObjectHandles *handles, const VkRender::EntryConnectDevice &entry, - bool fromWindowsAutoConnect = false) { + static void createDefaultElement(VkRender::GuiObjectHandles* handles, const VkRender::EntryConnectDevice& entry, + bool fromWindowsAutoConnect = false) + { VkRender::Device el{}; el.name = entry.profileName; el.IP = entry.IP; el.state = fromWindowsAutoConnect ? VkRender::CRL_STATE_JUST_ADDED_WINDOWS : VkRender::CRL_STATE_JUST_ADDED; - Log::Logger::getInstance()->info("Set dev {}'s state to VkRender::CRL_STATE_JUST_ADDED. On Windows? {} ", el.name, + Log::Logger::getInstance()->info("Set dev {}'s state to VkRender::CRL_STATE_JUST_ADDED. On Windows? {} ", + el.name, fromWindowsAutoConnect); el.interfaceName = entry.interfaceName; el.interfaceDescription = entry.description; @@ -426,76 +470,79 @@ class SideBarLayer : public VkRender::Layer { } - void sidebarElements(VkRender::GuiObjectHandles *handles) { - auto &devices = handles->devices; - for (size_t i = 0; i < devices.size(); ++i) { - auto &e = devices.at(i); + void sidebarElements(VkRender::GuiObjectHandles* handles) + { + auto& devices = handles->devices; + for (size_t i = 0; i < devices.size(); ++i) + { + auto& e = devices.at(i); std::string buttonIdentifier; ImVec4 btnColor{}; // Set colors based on state - switch (e.state) { - case VkRender::CRL_STATE_CONNECTED: - break; - case VkRender::CRL_STATE_CONNECTING: - buttonIdentifier = "Connecting"; - ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); - ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLBlueIsh); - btnColor = VkRender::Colors::CRLBlueIsh; - break; - case VkRender::CRL_STATE_ACTIVE: - buttonIdentifier = "Active"; - ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray421); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.26f, 0.42f, 0.31f, 1.0f)); - btnColor = ImVec4(0.26f, 0.42f, 0.31f, 1.0f); - break; - case VkRender::CRL_STATE_INACTIVE: - buttonIdentifier = "Inactive"; - ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); - ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLRed); - btnColor = VkRender::Colors::CRLRed; - break; - case VkRender::CRL_STATE_LOST_CONNECTION: - buttonIdentifier = "Lost connection..."; - ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); - ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLBlueIsh); - btnColor = VkRender::Colors::CRLBlueIsh; - break; - case VkRender::CRL_STATE_DISCONNECTED: - buttonIdentifier = "Disconnected"; - ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); - ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLRed); - btnColor = VkRender::Colors::CRLRed; - break; - case VkRender::CRL_STATE_UNAVAILABLE: - ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); - ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLDarkGray425); - btnColor = VkRender::Colors::CRLDarkGray425; - buttonIdentifier = "Unavailable"; - break; - case VkRender::CRL_STATE_JUST_ADDED : - case VkRender::CRL_STATE_JUST_ADDED_WINDOWS: - ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.03f, 0.07f, 0.1f, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 1.0f)); - btnColor = ImVec4(0.1f, 0.1f, 0.1f, 1.0f); - buttonIdentifier = "Added..."; - break; - case VkRender::CRL_STATE_DISCONNECT_AND_FORGET: - buttonIdentifier = "Disconnecting...cmake"; - ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.03f, 0.07f, 0.1f, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 1.0f)); - break; - case VkRender::CRL_STATE_REMOVE_FROM_LIST: - buttonIdentifier = "Removing..."; - ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.03f, 0.07f, 0.1f, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 1.0f)); - break; - case VkRender::CRL_STATE_RESET: - buttonIdentifier = "Resetting"; - ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.03f, 0.07f, 0.1f, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 1.0f)); - break; - default: - break; + switch (e.state) + { + case VkRender::CRL_STATE_CONNECTED: + break; + case VkRender::CRL_STATE_CONNECTING: + buttonIdentifier = "Connecting"; + ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); + ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLBlueIsh); + btnColor = VkRender::Colors::CRLBlueIsh; + break; + case VkRender::CRL_STATE_ACTIVE: + buttonIdentifier = "Active"; + ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray421); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.26f, 0.42f, 0.31f, 1.0f)); + btnColor = ImVec4(0.26f, 0.42f, 0.31f, 1.0f); + break; + case VkRender::CRL_STATE_INACTIVE: + buttonIdentifier = "Inactive"; + ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); + ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLRed); + btnColor = VkRender::Colors::CRLRed; + break; + case VkRender::CRL_STATE_LOST_CONNECTION: + buttonIdentifier = "Lost connection..."; + ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); + ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLBlueIsh); + btnColor = VkRender::Colors::CRLBlueIsh; + break; + case VkRender::CRL_STATE_DISCONNECTED: + buttonIdentifier = "Disconnected"; + ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); + ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLRed); + btnColor = VkRender::Colors::CRLRed; + break; + case VkRender::CRL_STATE_UNAVAILABLE: + ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLGray424); + ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLDarkGray425); + btnColor = VkRender::Colors::CRLDarkGray425; + buttonIdentifier = "Unavailable"; + break; + case VkRender::CRL_STATE_JUST_ADDED: + case VkRender::CRL_STATE_JUST_ADDED_WINDOWS: + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.03f, 0.07f, 0.1f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 1.0f)); + btnColor = ImVec4(0.1f, 0.1f, 0.1f, 1.0f); + buttonIdentifier = "Added..."; + break; + case VkRender::CRL_STATE_DISCONNECT_AND_FORGET: + buttonIdentifier = "Disconnecting...cmake"; + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.03f, 0.07f, 0.1f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 1.0f)); + break; + case VkRender::CRL_STATE_REMOVE_FROM_LIST: + buttonIdentifier = "Removing..."; + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.03f, 0.07f, 0.1f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 1.0f)); + break; + case VkRender::CRL_STATE_RESET: + buttonIdentifier = "Resetting"; + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.03f, 0.07f, 0.1f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 1.0f)); + break; + default: + break; } ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); @@ -509,8 +556,8 @@ class SideBarLayer : public VkRender::Layer { // Delete a profile { - - if (ImGui::SmallButton("X")) { + if (ImGui::SmallButton("X")) + { // delete and disconnect devices if (handles->devices.at(i).state == VkRender::CRL_STATE_CONNECTING) handles->devices.at(i).state = VkRender::CRL_STATE_INTERRUPT_CONNECTION; @@ -580,33 +627,38 @@ class SideBarLayer : public VkRender::Layer { //buttonIdentifier += "##" + e.IP; //e.clicked = ImGui::Button(buttonIdentifier.c_str(), ImVec2(ImGui::GetFontSize() * 10, ImGui::GetFontSize() * 2)); - ImVec2 uv0 = ImVec2(0.0f, 0.0f); // UV coordinates for lower-left + ImVec2 uv0 = ImVec2(0.0f, 0.0f); // UV coordinates for lower-left ImVec2 uv1 = ImVec2(1.0f, 1.0f); - ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 0.3f); // No tint + ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 0.3f); // No tint // Check if other device is already attempting to connect bool busy = false; - for (const auto &dev: handles->devices) { + for (const auto& dev : handles->devices) + { if (dev.state == VkRender::CRL_STATE_CONNECTING) busy = true; } // Connect button - if (buttonIdentifier == "Connecting") { + if (buttonIdentifier == "Connecting") + { e.clicked = ImGui::ButtonWithGif(buttonIdentifier.c_str(), ImVec2(ImGui::GetFontSize() * 10, 35.0f), handles->info->gif.image[gifFrameIndex2], ImVec2(35.0f, 35.0f), uv0, uv1, tint_col, btnColor) && !busy; - } else { + } + else + { e.clicked = ImGui::Button(buttonIdentifier.c_str(), ImVec2(ImGui::GetFontSize() * 10, ImGui::GetFontSize() * 2)) && !busy; } auto time = std::chrono::steady_clock::now(); auto time_span = - std::chrono::duration_cast>(time - gifFrameTimer2); + std::chrono::duration_cast>(time - gifFrameTimer2); - if (time_span.count() > static_cast(*handles->info->gif.delay) / 1000.0f) { + if (time_span.count() > static_cast(*handles->info->gif.delay) / 1000.0f) + { gifFrameTimer2 = std::chrono::steady_clock::now(); gifFrameIndex2++; } @@ -622,14 +674,15 @@ class SideBarLayer : public VkRender::Layer { } } - static void addDeviceButton(VkRender::GuiObjectHandles *handles) { - + static void addDeviceButton(VkRender::GuiObjectHandles* handles) + { ImGui::SetCursorPos(ImVec2((handles->info->sidebarWidth / 2) - (handles->info->addDeviceWidth / 2), handles->info->height - handles->info->addDeviceBottomPadding)); ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::CRLBlueIsh); if (ImGui::Button("ADD DEVICE", ImVec2(handles->info->addDeviceWidth, handles->info->addDeviceHeight)) || - handles->openAddDevicePopup) { + handles->openAddDevicePopup) + { ImGui::OpenPopup("add_device_modal"); handles->usageMonitor->userClickAction("ADD_DEVICE", "button", ImGui::GetCurrentWindow()->Name); handles->openAddDevicePopup = false; @@ -637,7 +690,8 @@ class SideBarLayer : public VkRender::Layer { ImGui::PopStyleColor(); } - void addPopup(VkRender::GuiObjectHandles *handles) { + void addPopup(VkRender::GuiObjectHandles* handles) + { ImGui::SetNextWindowSize(ImVec2(handles->info->popupWidth, handles->info->popupHeight), ImGuiCond_Always); ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 0); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); @@ -648,8 +702,8 @@ class SideBarLayer : public VkRender::Layer { if (ImGui::BeginPopupModal("add_device_modal", nullptr, - ImGuiWindowFlags_NoDecoration)) { - + ImGuiWindowFlags_NoDecoration)) + { /** HEADER FIELD */ ImVec2 popupDrawPos = ImGui::GetCursorScreenPos(); ImVec2 headerPosMax = popupDrawPos; @@ -665,7 +719,7 @@ class SideBarLayer : public VkRender::Layer { std::string title = "Connect to MultiSense"; ImVec2 size = ImGui::CalcTextSize(title.c_str()); float anchorPoint = - (handles->info->popupWidth - size.x) / 2; // Make a m_Title in center of popup window + (handles->info->popupWidth - size.x) / 2; // Make a m_Title in center of popup window ImGui::Dummy(ImVec2(0.0f, size.y)); @@ -744,20 +798,25 @@ class SideBarLayer : public VkRender::Layer { ImGui::PopStyleColor(); // ImGuiCol_FrameBg /** AUTOCONNECT FIELD BEGINS HERE*/ - if (connectMethodSelector == AUTO_CONNECT) { + if (connectMethodSelector == AUTO_CONNECT) + { adapterUtils.stopAdapterScan(); // Stop scan if we select manual as autoconnect will run its own scan m_Entry.cameraName = "AutoConnect"; ImGui::Dummy(ImVec2(0.0f, 12.0f)); ImGui::Dummy(ImVec2(20.0f, 0.0f)); ImGui::SameLine(); - if (ImGui::Button(btnLabel.c_str(), ImVec2(80.0f, 20.0f))) { + if (ImGui::Button(btnLabel.c_str(), ImVec2(80.0f, 20.0f))) + { Log::Logger::getInstance()->info("User clicked {}", btnLabel); - if (btnLabel == "Start") { + if (btnLabel == "Start") + { handles->usageMonitor->userClickAction("Start", "button", ImGui::GetCurrentWindow()->Name); reader = std::make_unique(); btnLabel = "Reset"; - } else { + } + else + { handles->usageMonitor->userClickAction("Reset", "button", ImGui::GetCurrentWindow()->Name); reader->sendStopSignal(); entryConnectDeviceList.clear(); @@ -780,22 +839,22 @@ class SideBarLayer : public VkRender::Layer { btnLabel = "Start"; } #else - if (shellInfo.hProcess != nullptr) { - if (TerminateProcess(shellInfo.hProcess, 1) != 0) { + if (shellInfo.hProcess != nullptr) + { + if (TerminateProcess(shellInfo.hProcess, 1) != 0) + { Log::Logger::getInstance()->info("Stopped the auto connect process gracefully"); } shellInfo.hProcess = nullptr; reader.reset(); btnLabel = "Start"; startedAutoConnect = false; - } #endif } } - /** STATUS SPINNER */ ImGui::SameLine(); ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 12.0f); @@ -809,46 +868,51 @@ class SideBarLayer : public VkRender::Layer { ImGui::PushStyleColor(ImGuiCol_PopupBg, VkRender::Colors::CRLBlueIsh); ImGui::PushStyleColor(ImGuiCol_Text, VkRender::Colors::CRLTextWhite); ImGui::HelpMarker(" If no packet at adapter is received try the following: \n " - " 1. Reconnect ethernet cables \n " - " 2. Power cycle the camera \n " - " 3. Wait 20-30 seconds. If no packet is received contact support \n\n"); + " 1. Reconnect ethernet cables \n " + " 2. Power cycle the camera \n " + " 3. Wait 20-30 seconds. If no packet is received contact support \n\n"); ImGui::PopStyleColor(2); ImGui::PushStyleColor(ImGuiCol_ChildBg, VkRender::Colors::CRLDarkGray425); - const char *id = "Log Window"; + const char* id = "Log Window"; ImGui::Dummy(ImVec2(0.0f, 5.0f)); ImGui::Dummy(ImVec2(20.0f, 0.0f)); ImGui::SameLine(); ImGui::BeginChild(id, ImVec2(handles->info->popupWidth - 40.0f, 85.0f), false, 0); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0)); - const char *buf = Buf.begin(); - const char *buf_end = Buf.end(); + const char* buf = Buf.begin(); + const char* buf_end = Buf.end(); ImGuiListClipper clipper; clipper.Begin(LineOffsets.Size); - while (clipper.Step()) { - for (int line_no = clipper.DisplayStart; line_no < clipper.DisplayEnd; line_no++) { - const char *line_start = buf + LineOffsets[line_no]; - const char *line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - - 1) - : buf_end; + while (clipper.Step()) + { + for (int line_no = clipper.DisplayStart; line_no < clipper.DisplayEnd; line_no++) + { + const char* line_start = buf + LineOffsets[line_no]; + const char* line_end = (line_no + 1 < LineOffsets.Size) + ? (buf + LineOffsets[line_no + 1] - + 1) + : buf_end; // Weird index magic. colors is an ImGui vector. - if (line_no > 0 && line_no < colors.size() - 1) { + if (line_no > 0 && line_no < colors.size() - 1) + { LOG_COLOR col = colors[line_no + 1]; - switch (col) { - case LOG_COLOR_GRAY: - lastLogTextColor = VkRender::Colors::TextColorGray; - break; - case LOG_COLOR_GREEN: - lastLogTextColor = VkRender::Colors::TextGreenColor; - break; - case LOG_COLOR_RED: - lastLogTextColor = VkRender::Colors::TextRedColor; - break; - default: - lastLogTextColor = VkRender::Colors::TextColorGray; - break; + switch (col) + { + case LOG_COLOR_GRAY: + lastLogTextColor = VkRender::Colors::TextColorGray; + break; + case LOG_COLOR_GREEN: + lastLogTextColor = VkRender::Colors::TextGreenColor; + break; + case LOG_COLOR_RED: + lastLogTextColor = VkRender::Colors::TextRedColor; + break; + default: + lastLogTextColor = VkRender::Colors::TextColorGray; + break; } } ImGui::PushStyleColor(ImGuiCol_Text, lastLogTextColor); @@ -856,7 +920,6 @@ class SideBarLayer : public VkRender::Layer { ImGui::SameLine(); ImGui::TextUnformatted(line_start, line_end); ImGui::PopStyleColor(); - } } clipper.End(); @@ -873,23 +936,27 @@ class SideBarLayer : public VkRender::Layer { auto time = std::chrono::steady_clock::now(); auto time_span = - std::chrono::duration_cast>(time - searchingTextAnimTimer); + std::chrono::duration_cast>(time - searchingTextAnimTimer); - if (time_span.count() > 0.35f && startedAutoConnect) { + if (time_span.count() > 0.35f && startedAutoConnect) + { searchingTextAnimTimer = std::chrono::steady_clock::now(); dots.append("."); if (dots.size() > 4) dots.clear(); - - } else if (!startedAutoConnect) + } + else if (!startedAutoConnect) dots = "."; ImGui::PushStyleColor(ImGuiCol_Text, VkRender::Colors::CRLTextGray); - if (entryConnectDeviceList.empty() && startedAutoConnect) { + if (entryConnectDeviceList.empty() && startedAutoConnect) + { ImGui::Text("%s", ("Searching" + dots).c_str()); - } else { + } + else + { ImGui::Text("Select device:"); } @@ -898,10 +965,13 @@ class SideBarLayer : public VkRender::Layer { static bool selected = false; - if (!selected) { + if (!selected) + { ImGui::PushStyleColor(ImGuiCol_Header, ImVec4()); m_Entry.interfaceName.clear(); - } else { + } + else + { ImGui::PushStyleColor(ImGuiCol_Header, ImGui::GetStyle().Colors[ImGuiCol_Header]); } // Header @@ -913,20 +983,22 @@ class SideBarLayer : public VkRender::Layer { ImGui::SameLine(); ImGui::BeginChild("##ResultsChild", ImVec2(handles->info->popupWidth - (20.0f * 2.0f), 50.0f), true, 0); - for (size_t n = 0; n < entryConnectDeviceList.size(); n++) { + for (size_t n = 0; n < entryConnectDeviceList.size(); n++) + { if (entryConnectDeviceList[n].cameraName.empty()) continue; if (ImGui::Selectable((entryConnectDeviceList[n].cameraName + "##" + std::to_string(n)).c_str(), resultsComboIndex == static_cast(n), ImGuiSelectableFlags_DontClosePopups, - ImVec2(handles->info->popupWidth - (20.0f * 2), 15.0f))) { + ImVec2(handles->info->popupWidth - (20.0f * 2), 15.0f))) + { handles->usageMonitor->userClickAction(entryConnectDeviceList[n].cameraName, "Selectable", ImGui::GetCurrentWindow()->Name); resultsComboIndex = static_cast(n); - entryConnectDeviceList[n].profileName = entryConnectDeviceList[n].cameraName; // Keep profile m_Name if user inputted this before auto-connect is finished + entryConnectDeviceList[n].profileName = entryConnectDeviceList[n].cameraName; + // Keep profile m_Name if user inputted this before auto-connect is finished m_Entry = entryConnectDeviceList[n]; selected = true; - } } ImGui::EndChild(); @@ -946,8 +1018,9 @@ class SideBarLayer : public VkRender::Layer { ImGui::PopStyleColor(3); */ } - /** MANUAL_CONNECT FIELD BEGINS HERE*/ - else if (connectMethodSelector == MANUAL_CONNECT) { + /** MANUAL_CONNECT FIELD BEGINS HERE*/ + else if (connectMethodSelector == MANUAL_CONNECT) + { // AdapterSearch Threaded operation // Threaded adapter search for manual connect #ifdef WIN32 @@ -988,7 +1061,7 @@ class SideBarLayer : public VkRender::Layer { manualConnectAdapters = adapterUtils.getAdaptersList(); interfaceNameList.clear(); indexList.clear(); -// Following three ifdef macros are a bit janky but required since Windows uses a HEX-ID AND Name to describe a network adapter whereas linux only uses a Name + // Following three ifdef macros are a bit janky but required since Windows uses a HEX-ID AND Name to describe a network adapter whereas linux only uses a Name #ifdef WIN32 interfaceIDList.clear(); #endif @@ -998,10 +1071,11 @@ class SideBarLayer : public VkRender::Layer { // Always have a base item in it. // if we push back other items then remove base item // No identical items - for (const auto &a: manualConnectAdapters) { + for (const auto& a : manualConnectAdapters) + { #ifdef WIN32 - if (a.supports && !Utils::isInVector(interfaceNameList, a.description)) { - + if (a.supports && !Utils::isInVector(interfaceNameList, a.description)) + { interfaceNameList.push_back(a.description); interfaceIDList.push_back(a.ifName); #else @@ -1009,13 +1083,15 @@ class SideBarLayer : public VkRender::Layer { interfaceNameList.push_back(a.ifName); #endif indexList.push_back(a.ifIndex); - if (Utils::isInVector(interfaceNameList, "No adapters found")) { + if (Utils::isInVector(interfaceNameList, "No adapters found")) + { Utils::delFromVector(&interfaceNameList, std::string("No adapters found")); } } } if (!Utils::isInVector(interfaceNameList, "No adapters found") && - interfaceNameList.empty()) { + interfaceNameList.empty()) + { interfaceNameList.emplace_back("No adapters found"); indexList.push_back(0); } @@ -1037,14 +1113,16 @@ class SideBarLayer : public VkRender::Layer { ImGui::SameLine(); ImGui::SetNextItemWidth(handles->info->popupWidth - 40.0f); ImGui::PushStyleColor(ImGuiCol_PopupBg, VkRender::Colors::CRLDarkGray425); - if (ImGui::BeginCombo("##SelectAdapter", previewValue.c_str(), flags)) { - for (size_t n = 0; n < interfaceNameList.size(); n++) { + if (ImGui::BeginCombo("##SelectAdapter", previewValue.c_str(), flags)) + { + for (size_t n = 0; n < interfaceNameList.size(); n++) + { const bool is_selected = (ethernetComboIndex == n); - if (ImGui::Selectable(interfaceNameList[n].c_str(), is_selected)) { + if (ImGui::Selectable(interfaceNameList[n].c_str(), is_selected)) + { ethernetComboIndex = static_cast(n); handles->usageMonitor->userClickAction("SelectAdapter", "combo", ImGui::GetCurrentWindow()->Name); - } // Set the initial focus when opening the combo (scrolling + keyboard navigation focus) if (is_selected) @@ -1069,12 +1147,48 @@ class SideBarLayer : public VkRender::Layer { ImGui::HelpMarker("\n Check this if you are connecting to a remote head device \n "); ImGui::PopStyleColor(3); */ - } else { + +#ifdef WIN32 + std::string url = "https://docs.carnegierobotics.com/network/host_configuration/windows.html"; +#else + std::string url = "https://docs.carnegierobotics.com/network/host_configuration/linux.html"; +#endif + + ImGui::Dummy(ImVec2(0.0f, 25.0f)); + ImGui::PushStyleColor(ImGuiCol_Text, VkRender::Colors::CRLTextGray); + ImGui::Dummy(ImVec2(20.0f, 5.0f)); + ImGui::SameLine(); + ImGui::Text("Having trouble connecting to a camera?"); + ImGui::Dummy(ImVec2(20.0f, 5.0f)); + ImGui::SameLine(); + ImGui::Text("Refer to our guide by clicking below for setting up the network configuration."); + ImGui::Dummy(ImVec2(20.0f, 5.0f)); + ImGui::SameLine(); + static bool isLinkHovered = false; + ImVec4 blueLinkColor = isLinkHovered + ? ImVec4(0.17f, 0.579f, 0.893f, 1.0f) + : ImVec4(0.0f, 0.439f, 0.753f, + 1.0f); + ImGui::PushStyleColor(ImGuiCol_Text, blueLinkColor); + std::string selectableTxt = "Network Configuration Guide"; + if (ImGui::Selectable(selectableTxt.c_str(), false, ImGuiSelectableFlags_DontClosePopups, + ImGui::CalcTextSize(selectableTxt.c_str()))) + { + openURL(url); + handles->usageMonitor->userClickAction("Network Configuration", "Selectable", + ImGui::GetCurrentWindow()->Name); + } + ImGui::PopStyleColor(2); + } + else + { adapterUtils.stopAdapterScan(); // Stop it if it was started and we deselect manual connect } - if (handles->configureNetwork) { - if (elevated() && connectMethodSelector == MANUAL_CONNECT) { + if (handles->configureNetwork) + { + if (elevated() && connectMethodSelector == MANUAL_CONNECT) + { ImGui::PushStyleColor(ImGuiCol_Text, VkRender::Colors::CRLRed); ImGui::Dummy(ImVec2(40.0f, 10.0)); ImGui::Dummy(ImVec2(20.0f, 0.0)); @@ -1086,14 +1200,16 @@ class SideBarLayer : public VkRender::Layer { #endif enableConnectButton = false; ImGui::PopStyleColor(); - } else + } + else enableConnectButton = true; - - } else + } + else enableConnectButton = true; - if (connectMethodSelector == AUTO_CONNECT && !reader) { + if (connectMethodSelector == AUTO_CONNECT && !reader) + { enableConnectButton = false; } @@ -1105,7 +1221,8 @@ class SideBarLayer : public VkRender::Layer { ImGui::PushFont(handles->info->font15); bool btnCancel = ImGui::Button("Close", ImVec2(190.0f, 30.0f)); ImGui::SameLine(0, 130.0f); - if (!m_Entry.ready(handles->devices, m_Entry) || !enableConnectButton) { + if (!m_Entry.ready(handles->devices, m_Entry) || !enableConnectButton) + { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleColor(ImGuiCol_Button, VkRender::Colors::TextColorGray); } @@ -1114,13 +1231,15 @@ class SideBarLayer : public VkRender::Layer { // If hovered, and no admin rights while auto config is checked, and a connect method must be selected if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && (!m_Entry.ready(handles->devices, m_Entry) || !enableConnectButton) && - (connectMethodSelector == AUTO_CONNECT || connectMethodSelector == MANUAL_CONNECT)) { + (connectMethodSelector == AUTO_CONNECT || connectMethodSelector == MANUAL_CONNECT)) + { ImGui::PushStyleColor(ImGuiCol_PopupBg, VkRender::Colors::CRLBlueIsh); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.0f, 8.0f)); ImGui::BeginTooltip(); std::vector errors = m_Entry.getNotReadyReasons(handles->devices, m_Entry); ImGui::Text("Please solve the following: "); - if (connectMethodSelector == AUTO_CONNECT) { + if (connectMethodSelector == AUTO_CONNECT) + { if (reader) errors.insert(errors.begin(), "No device selected"); else @@ -1128,15 +1247,16 @@ class SideBarLayer : public VkRender::Layer { Utils::removeFromVector(&errors, "No selected network adapter"); } - if (elevated() && connectMethodSelector == MANUAL_CONNECT && handles->configureNetwork) { + if (elevated() && connectMethodSelector == MANUAL_CONNECT && handles->configureNetwork) + { #ifdef WIN32 errors.emplace_back("Admin rights is needed to auto configure network"); #else errors.emplace_back("Root access is needed to auto configure network"); #endif - } - for (size_t i = 0; i < errors.size(); ++i) { + for (size_t i = 0; i < errors.size(); ++i) + { ImGui::Text("%s", (std::to_string(i + 1) + ". " + errors[i]).c_str()); } @@ -1144,29 +1264,33 @@ class SideBarLayer : public VkRender::Layer { ImGui::PopStyleColor(); ImGui::PopStyleVar(); } - if (!m_Entry.ready(handles->devices, m_Entry) || !enableConnectButton) { + if (!m_Entry.ready(handles->devices, m_Entry) || !enableConnectButton) + { ImGui::PopStyleColor(); ImGui::PopItemFlag(); } ImGui::Dummy(ImVec2(0.0f, 5.0f)); - if (btnCancel) { + if (btnCancel) + { handles->usageMonitor->userClickAction("Cancel", "button", ImGui::GetCurrentWindow()->Name); ImGui::CloseCurrentPopup(); } - if (btnConnect && m_Entry.ready(handles->devices, m_Entry) && enableConnectButton) { + if (btnConnect && m_Entry.ready(handles->devices, m_Entry) && enableConnectButton) + { handles->usageMonitor->userClickAction("Connect", "button", ImGui::GetCurrentWindow()->Name); - if (reader) { + if (reader) + { reader->setIpConfig(resultsComboIndex); reader->sendStopSignal(); } // Stop autoConnect and set IP the found MultiSense device // Next: Create default element, but if this happens on windows we can to connect for ~~8 seconds to allow added ip address to finish configuring #ifdef WIN32 - createDefaultElement(handles, m_Entry, connectMethodSelector == AUTO_CONNECT); + createDefaultElement(handles, m_Entry, connectMethodSelector == AUTO_CONNECT); ImGui::CloseCurrentPopup(); #else createDefaultElement(handles, m_Entry); @@ -1177,15 +1301,17 @@ class SideBarLayer : public VkRender::Layer { } ImGui::EndPopup(); - } else { + } + else + { adapterUtils.stopAdapterScan(); // Stop scan if we close popup } ImGui::PopStyleColor(); ImGui::PopStyleVar(5); // popup style vars } - void addSpinnerGif(VkRender::GuiObjectHandles *handles) { - + void addSpinnerGif(VkRender::GuiObjectHandles* handles) + { ImVec2 size = ImVec2(40.0f, 40.0f); ImVec2 uv0 = ImVec2(0.0f, 0.0f); ImVec2 uv1 = ImVec2(1.0f, 1.0f); @@ -1196,9 +1322,10 @@ class SideBarLayer : public VkRender::Layer { ImGui::Image(handles->info->gif.image[gifFrameIndex], size, uv0, uv1, bg_col, tint_col); auto time = std::chrono::steady_clock::now(); auto time_span = - std::chrono::duration_cast>(time - gifFrameTimer); + std::chrono::duration_cast>(time - gifFrameTimer); - if (time_span.count() > static_cast(*handles->info->gif.delay) / 1000.0f) { + if (time_span.count() > static_cast(*handles->info->gif.delay) / 1000.0f) + { gifFrameTimer = std::chrono::steady_clock::now(); gifFrameIndex++; } @@ -1206,8 +1333,6 @@ class SideBarLayer : public VkRender::Layer { if (gifFrameIndex == handles->info->gif.totalFrames) gifFrameIndex = 0; } - - }; diff --git a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp index 702723e6f..db83cccee 100644 --- a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp +++ b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.cpp @@ -134,7 +134,9 @@ void PointCloud::onUIUpdate(VkRender::GuiObjectHandles *uiHandle) { lumaOrColor = dev.useAuxForPointCloudColor; model->m_Draw = false; auto& device = const_cast(dev); - prepareTexFuture = std::async(std::launch::async, &PointCloud::prepareTexture, this, std::ref(device)); + prepareTexture(device); + prepareTexFuture = std::async(std::launch::async, &PointCloud::updatePointCloudParameters, this, std::ref(device)); + } } } @@ -150,8 +152,29 @@ void PointCloud::draw(CommandBuffer * commandBuffer, uint32_t i, bool b) { } } +bool PointCloud::updatePointCloudParameters(VkRender::Device& dev){ + uint32_t width = 0, height = 0, depth = 0; + Utils::cameraResolutionToValue(res, &width, &height, &depth); -bool PointCloud::prepareTexture(VkRender::Device &dev) { + if (renderData.crlCamera->updateCameraInfo(&dev, 0)){ + auto *buf = ubo[0].pointCloudData.get(); + buf->Q = renderData.crlCamera->getCameraInfo(0).QMat; + buf->height = static_cast(height); + buf->width = static_cast(width); + buf->disparity = static_cast(depth); + buf->focalLength = renderData.crlCamera->getCameraInfo(0).focalLength; + buf->scale = renderData.crlCamera->getCameraInfo(0).pointCloudScale; + buf->pointSize = pointSize; + Log::Logger::getInstance()->info( + "Transforming depth image to point cloud with focal length {} and point cloud scale {}. Multisens imgConf size is ({}, {})", + renderData.crlCamera->getCameraInfo(0).focalLength, renderData.crlCamera->getCameraInfo(0).pointCloudScale, renderData.crlCamera->getCameraInfo(0).imgConf.width(), renderData.crlCamera->getCameraInfo(0).imgConf.height()); + return true; + } else { + Log::Logger::getInstance()->error("Failed to update camera info for pointcloud!"); + } + return false; +} +void PointCloud::prepareTexture(VkRender::Device &dev) { uint32_t width = 0, height = 0, depth = 0; Utils::cameraResolutionToValue(res, &width, &height, &depth); @@ -176,24 +199,4 @@ bool PointCloud::prepareTexture(VkRender::Device &dev) { std::vector shaders = {{vs}, {fs}}; CRLCameraModels::createRenderPipeline(shaders, model.get(), &renderUtils); - - - if (renderData.crlCamera->updateCameraInfo(&dev, 0)){ - - auto *buf = ubo[0].pointCloudData.get(); - buf->Q = renderData.crlCamera->getCameraInfo(0).QMat; - buf->height = static_cast(height); - buf->width = static_cast(width); - buf->disparity = static_cast(depth); - buf->focalLength = renderData.crlCamera->getCameraInfo(0).focalLength; - buf->scale = renderData.crlCamera->getCameraInfo(0).pointCloudScale; - buf->pointSize = pointSize; - Log::Logger::getInstance()->info( - "Transforming depth image to point cloud with focal length {} and point cloud scale {}. Multisens imgConf size is ({}, {})", - renderData.crlCamera->getCameraInfo(0).focalLength, renderData.crlCamera->getCameraInfo(0).pointCloudScale, renderData.crlCamera->getCameraInfo(0).imgConf.width(), renderData.crlCamera->getCameraInfo(0).imgConf.height()); - return true; - } else { - Log::Logger::getInstance()->error("Failed to update camera info for pointcloud!"); - } - return false; } diff --git a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.h b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.h index 834cc279f..b1b5ab5e9 100644 --- a/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.h +++ b/include/Viewer/Scripts/MultiSenseRenderer/Pointcloud/PointCloud.h @@ -90,10 +90,11 @@ class PointCloud: public VkRender::Base, public VkRender::RegisteredInFactorydata().source != src || tex->m_Width != header->data().width || tex->m_Height < header->data().height) { - Log::Logger::getInstance()->error( - "In getCameraStream: Color Source and dimensions did not match expected values"); + //Log::Logger::getInstance()->error( + // "In getCameraStream: Color Source and dimensions did not match expected values"); return false; } tex->m_Id = static_cast(header->data().frameId); @@ -245,8 +245,8 @@ namespace VkRender::MultiSense { if (tex->data3 != nullptr) { size_t diff2 = static_cast((tex->m_Height) / 2) - headerTwo->data().height; - std::memset(tex->data2 + (headerTwo->data().imageLength / 2), 0x00, diff2 * tex->m_Width); - std::memset(tex->data3 + (headerTwo->data().imageLength / 2), 0x00, diff2 * tex->m_Width); + //std::memset(tex->data2 + (headerTwo->data().imageLength / 2), 0x00, diff2 * tex->m_Width); + //std::memset(tex->data3 + (headerTwo->data().imageLength / 2), 0x00, diff2 * tex->m_Width); } else { uint32_t diff2 = tex->m_Height / 2 - headerTwo->data().height; @@ -267,7 +267,7 @@ namespace VkRender::MultiSense { case CRL_POINT_CLOUD: if (header->data().source != src || tex->m_Width != header->data() .width || tex->m_Height < header->data().height) { - Log::Logger::getInstance()->warning( + Log::Logger::getInstance()->trace( "In getCameraStream: Monochrome source and dimensions did not match expected values"); return false; } diff --git a/src/CRLCamera/CameraConnection.cpp b/src/CRLCamera/CameraConnection.cpp index ee5e00c54..d6dc3b5b4 100644 --- a/src/CRLCamera/CameraConnection.cpp +++ b/src/CRLCamera/CameraConnection.cpp @@ -626,7 +626,7 @@ namespace VkRender::MultiSense { const std::vector &maskVec, crl::multisense::RemoteHeadChannel idx, CRLPhysicalCamera &camPtr) { - uint32_t bits = camPtr.getCameraInfo(idx).supportedSources; + crl::multisense::DataSource bits = camPtr.getCameraInfo(idx).supportedSources; for (auto mask: maskVec) { bool enabled = (bits & mask); if (enabled) { diff --git a/src/Core/VulkanDevice.cpp b/src/Core/VulkanDevice.cpp index 4c4306211..650416356 100644 --- a/src/Core/VulkanDevice.cpp +++ b/src/Core/VulkanDevice.cpp @@ -297,9 +297,6 @@ VulkanDevice::createLogicalDevice(VkPhysicalDeviceFeatures enabled, std::vector< * @return True if the extension is supported (present in the list read at m_Device creation time) */ bool VulkanDevice::extensionSupported(std::string extension) const { - if (VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME == extension) - return false; - return (std::find(m_SupportedExtensions.begin(), m_SupportedExtensions.end(), extension) != m_SupportedExtensions.end()); } From dd3eb05e6411ab4497bc4b8ca84f6684f7ee3290 Mon Sep 17 00:00:00 2001 From: magnus Date: Fri, 20 Dec 2024 15:47:44 +0100 Subject: [PATCH 11/11] Reset mtu value in gui if updated was unsuccessful --- .../Viewer/ImGui/MainLayerExt/SensorConfigurationExt.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/Viewer/ImGui/MainLayerExt/SensorConfigurationExt.h b/include/Viewer/ImGui/MainLayerExt/SensorConfigurationExt.h index 4f490b241..8f9f238ed 100644 --- a/include/Viewer/ImGui/MainLayerExt/SensorConfigurationExt.h +++ b/include/Viewer/ImGui/MainLayerExt/SensorConfigurationExt.h @@ -824,6 +824,15 @@ class SensorConfigurationExt : public VkRender::Layer { d.parameters.stereo.mtu = mtuValues[mtuIndex]; isCustomValue = false; } + if (d.parameters.stereo.mtu != mtuValues[mtuIndex] && !isCustomValue){ + // Check if the current MTU matches any of the predefined MTU values + for (int i = 0; i < IM_ARRAYSIZE(mtuValues); ++i) { + if (d.parameters.stereo.mtu == mtuValues[i]) { + mtuIndex = i; // Set the correct index + break; + } + } + } d.parameters.stereo.update |= ImGui::IsItemDeactivatedAfterEdit(); // Handle right-click context menu to enter custom MTU value if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Right)) {