当前位置:网站首页>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 :
边栏推荐
- Poj2315 football games
- Computer graduation design PHP enterprise staff training management system
- Ali test Open face test
- Shutter doctor: Xcode installation is incomplete
- GBase 8c数据库升级报错
- [flask] obtain request information, redirect and error handling
- 插卡4G工业路由器充电桩智能柜专网视频监控4G转以太网转WiFi有线网速测试 软硬件定制
- [technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry
- c#网页打开winform exe
- Basic operations of databases and tables ----- non empty constraints
猜你喜欢
How does the crystal oscillator vibrate?
Initialize MySQL database when docker container starts
A Cooperative Approach to Particle Swarm Optimization
You are using pip version 21.1.1; however, version 22.0.3 is available. You should consider upgradin
Huawei Hrbrid interface and VLAN division based on IP
一圖看懂!為什麼學校教了你Coding但還是不會的原因...
2 power view
Tensorflow customize the whole training process
Basic operations of databases and tables ----- unique constraints
A Cooperative Approach to Particle Swarm Optimization
随机推荐
NLP fourth paradigm: overview of prompt [pre train, prompt, predict] [Liu Pengfei]
Kubernetes stateless application expansion and contraction capacity
安装php-zbarcode扩展时报错,不知道有没有哪位大神帮我解决一下呀 php 环境用的7.3
ClickOnce does not support request execution level 'requireAdministrator'
02. Go language development environment configuration
Huawei Hrbrid interface and VLAN division based on IP
阿裏測開面試題
LeetCode 322. Change exchange (dynamic planning)
[flask] official tutorial -part3: blog blueprint, project installability
Card 4G industrial router charging pile intelligent cabinet private network video monitoring 4G to Ethernet to WiFi wired network speed test software and hardware customization
XSS learning XSS lab problem solution
MUX VLAN configuration
Format code_ What does formatting code mean
02.Go语言开发环境配置
How does the crystal oscillator vibrate?
TrueType字体文件提取关键信息
Sword finger offer 38 Arrangement of strings
【Flask】响应、session与Message Flashing
Initialize MySQL database when docker container starts
Bidding promotion process