当前位置:网站首页>Pangolin Library: subgraph
Pangolin Library: subgraph
2022-07-06 01:47:00 【Jason. Li_ 0012】
Subgraphs
Actual use SLAM When visualizing point cloud information , It is hoped that the current image information of the camera and feature point tracking can be displayed at the same time . At this point, you need to build the subgraph object , Display the point cloud information while displaying the rest of the information .
Build subgraph objects
The sub graph objects are constructed as follows :
pangolin::View& sub_viewer = pangolin::Display(const std::string& name)
.SetBounds(Attach bottom, Attach top, Attach left, Attach right, double aspect)
.SetLock(Lock horizontal, Lock vertical );
name
: Name of the view or subgraphSetBounds
: Used to set the position of the subgraph , Same as interactive viewSetLock
: Set the lock position of the subgraph , When zooming the window , Automatically lock the subgraph to the specified positionhorizontal
: Horizontal locking position , Fill in the following contents :LockLeft
: leftLockCenter
: The centralLockRight
: On the right side
vertical
: Vertical lock position , Fill in the following contents :LockBottom
: BottomLockCenter
: The centralLockTop
: Top
Image container
For the image content to be displayed in the subgraph , You should first create a container for loading :
pangolin::GlTexture imgTexture(GLint width, GLint height, GLint internal_format, bool sampling_linear, int border, GLenum glformat, GLenum gltype, GLvoid* data )
width、height
: Loaded image width 、 Height , Same as the width of the loaded image 、 Highly consistentinternal_format
:Pangolin Internal image storage format , Generally, it is filled in by defaultGL_RGB
sampling_linear
: Whether to start the current sampling , Default fillingfalse
border
: Boundary size ( Pixels ), Default filling0
glformat
:GL Image storage format , It is generally used OpenCV Read the image , Therefore, fill inGL_BGR
gltype
:GL Image data format ,OpenCV The format isUInt
type , Therefore, fill inGL_UNSIGNED_BYTE
data
:GL Image data
Loading images
Load image information into the container
imgTexture.Upload(const void* data, GLenum data_format, GLenum data_type)
data
: Image datadata_format
: Image storage formatdata_type
: Image data format
Show subgraphs
Last , Display subgraph information
// Activate subgraph
sub_viewer.Activate();
// Background color setting of subgraph
glColor3f(1.0f, 1.0f, 1.0f);
// reverse Y Axis , Otherwise, the output is inverted
imgTexture.RenderToViewportFlipY();
here , Because the view origin position is in the lower left corner , and OpenCV The origin is in the upper left corner , Therefore, we need to reverse Y Axis .
comprehensive : Subgraph display
in summary , The whole process of building the subgraph is as follows :
CMake
Due to the use of OpenCV library , Need to introduce CV library :
The root directory CMakeLists.txt The documents are as follows :
# cmake version
cmake_minimum_required(VERSION 3.21)
# project name
project(Study)
# cpp version
set(CMAKE_CXX_STANDARD 14)
# eigen
include_directories("/usr/include/eigen3")
# Sophus
find_package(Sophus REQUIRED)
include_directories(${
Sophus_INCLUDE_DIRS})
# pangolin
find_package(Pangolin REQUIRED)
include_directories(${
Pangolin_INCLUDE_DIRS})
# opencv
find_package(OpenCV REQUIRED)
include_directories(${
OpenCV_INCLUDE_DIRS})
# incldue
include_directories(include)
# src
add_subdirectory(src)
src Next CMakeLists.txt The documents are as follows :
# exec
add_executable(Study main.cpp)
# link pangolin
target_link_libraries(Study ${
Pangolin_LIBRARIES})
# link opencv
target_link_libraries(Study ${
OpenCV_LIBRARIES})
The header file
Include Next file main.h as follows :
#ifndef STUDY_MAIN_H
#define STUDY_MAIN_H
#include <iostream>
#include <cmath>
#include <unistd.h>
// Eigen
#include <Eigen/Core>
#include <Eigen/Dense>
#include <Eigen/Geometry>
// Sophus
#include <sophus/so3.hpp>
#include <sophus/se3.hpp>
// Pangolin
#include <pangolin/pangolin.h>
// OpenCV
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
// namespace
using namespace std;
using namespace Eigen;
#endif //STUDY_MAIN_H
Source code
src Next source file main.cpp as follows :
#include <string>
#include <iostream>
#include "main.h"
int main()
{
/*-------- Pangolin The camera --------*/
// window
pangolin::CreateWindowAndBind("MultiImage", 752, 480);
// Start the depth test
glEnable(GL_DEPTH_TEST);
// The camera
pangolin::OpenGlRenderState s_cam(
pangolin::ProjectionMatrix(752, 480, 420, 420, 320, 320, 0.1, 1000),
pangolin::ModelViewLookAt(-2, 0, -2, 0, 0, 0, pangolin::AxisY)
);
/*-------- View 、 Subgraphs --------*/
// Main view cam, The tensile
pangolin::View& d_cam = pangolin::Display("cam")
.SetBounds(0., 1., 0., 1., -752/480.)
.SetHandler(new pangolin::Handler3D(s_cam));
// Subgraphs 1 image_1, tailoring , Lock the upper left corner
pangolin::View& cv_img_1 = pangolin::Display("image_1")
.SetBounds(2/3.0f, 1.0f, 0., 1/3.0f, 752/480.)
.SetLock(pangolin::LockLeft, pangolin::LockTop);
// Subgraphs 2 image_2, tailoring , Lock the lower right corner
pangolin::View& cv_img_2 = pangolin::Display("image_2")
.SetBounds(0., 1/3.0f, 2/3.0f, 1.0, 752/480.)
.SetLock(pangolin::LockRight, pangolin::LockBottom);
// glTexture Containers , For reading images
pangolin::GlTexture imgTexture1(752, 480, GL_RGB, false, 0, GL_BGR, GL_UNSIGNED_BYTE);
pangolin::GlTexture imgTexture2(752, 480, GL_RGB, false, 0, GL_BGR, GL_UNSIGNED_BYTE);
while(!pangolin::ShouldQuit()){
// Clear color 、 Deep cache
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Background color
glClearColor(0.2, 0.2, 0.2, 0.3);
// Activate the camera
d_cam.Activate(s_cam);
/*-------- Draw the contents of the main view --------*/
// Origin cube
glColor3f(1.0f, 1.0f, 1.0f);
pangolin::glDrawColouredCube();
/*-------- Subgraph information --------*/
// Read images
cv::Mat img1 = cv::imread("/home/jasonli/workspace/Study/pic/01.png");
cv::Mat img2 = cv::imread("/home/jasonli/workspace/Study/pic/02.png");
// Loading images
imgTexture1.Upload(img1.data, GL_BGR, GL_UNSIGNED_BYTE);
imgTexture2.Upload(img2.data, GL_BGR, GL_UNSIGNED_BYTE);
/*-------- Subgraphs 1 To configure --------*/
// Activate subgraph 1
cv_img_1.Activate();
// Subgraphs 1 Background color settings
glColor3f(1.0f, 1.0f, 1.0f);
// reverse Y Axis , Otherwise, the output is inverted
imgTexture1.RenderToViewportFlipY();
/*-------- Subgraphs 2 To configure --------*/
// Activate subgraph 2
cv_img_2.Activate();
// Subgraphs 1 Background color settings
glColor3f(1.0f, 1.0f, 1.0f);
// reverse Y Axis , Otherwise, the output is inverted
imgTexture2.RenderToViewportFlipY();
// Frame cycle
pangolin::FinishFrame();
}
return 0;
}
The effect is as follows :
边栏推荐
- leetcode-2. Palindrome judgment
- ctf. Show PHP feature (89~110)
- XSS learning XSS lab problem solution
- Regular expressions: examples (1)
- 干货!通过软硬件协同设计加速稀疏神经网络
- Unreal browser plug-in
- Comments on flowable source code (XXXV) timer activation process definition processor, process instance migration job processor
- Blue Bridge Cup embedded_ STM32_ New project file_ Explain in detail
- TrueType字体文件提取关键信息
- 使用npm发布自己开发的工具包笔记
猜你喜欢
TrueType字体文件提取关键信息
NLP fourth paradigm: overview of prompt [pre train, prompt, predict] [Liu Pengfei]
Huawei Hrbrid interface and VLAN division based on IP
Redis如何实现多可用区?
Tensorflow customize the whole training process
A picture to understand! Why did the school teach you coding but still not
selenium 等待方式
A Cooperative Approach to Particle Swarm Optimization
Superfluid_ HQ hacked analysis
Redis string type
随机推荐
Leetcode skimming questions_ Invert vowels in a string
Regular expressions: examples (1)
【Flask】获取请求信息、重定向、错误处理
Superfluid_ HQ hacked analysis
[detailed] several ways to quickly realize object mapping
Huawei converged VLAN principle and configuration
【网络攻防实训习题】
Numpy array index slice
[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability
Format code_ What does formatting code mean
通过PHP 获取身份证相关信息 获取生肖,获取星座,获取年龄,获取性别
02. Go language development environment configuration
Open source | Ctrip ticket BDD UI testing framework flybirds
leetcode刷题_平方数之和
How does redis implement multiple zones?
Competition question 2022-6-26
Paddle framework: paddlenlp overview [propeller natural language processing development library]
2022 PMP project management examination agile knowledge points (8)
[network attack and defense training exercises]
Reasonable and sensible