当前位置:网站首页>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 :
边栏推荐
- 【Flask】官方教程(Tutorial)-part2:蓝图-视图、模板、静态文件
- [flask] official tutorial -part3: blog blueprint, project installability
- 阿裏測開面試題
- dried food! Accelerating sparse neural network through hardware and software co design
- Sword finger offer 12 Path in matrix
- 晶振是如何起振的?
- Basic operations of databases and tables ----- primary key constraints
- Force buckle 9 palindromes
- leetcode3、实现 strStr()
- Basic process and testing idea of interface automation
猜你喜欢
02.Go语言开发环境配置
[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability
1. Introduction to basic functions of power query
【SSRF-01】服务器端请求伪造漏洞原理及利用实例
晶振是如何起振的?
3D vision - 4 Getting started with gesture recognition - using mediapipe includes single frame and real time video
Basic operations of databases and tables ----- non empty constraints
It's wrong to install PHP zbarcode extension. I don't know if any God can help me solve it. 7.3 for PHP environment
干货!通过软硬件协同设计加速稀疏神经网络
Basic operations of databases and tables ----- unique constraints
随机推荐
Kubernetes stateless application expansion and contraction capacity
leetcode3、实现 strStr()
安装Redis
Thinking about the best practice of dynamics 365 development collaboration
Grabbing and sorting out external articles -- status bar [4]
Folio. Ink is a free, fast and easy-to-use image sharing tool
Gbase 8C database upgrade error
剑指 Offer 38. 字符串的排列
Accelerating spark data access with alluxio in kubernetes
3D视觉——4.手势识别(Gesture Recognition)入门——使用MediaPipe含单帧(Singel Frame)和实时视频(Real-Time Video)
Redis daemon cannot stop the solution
NLP第四范式:Prompt概述【Pre-train,Prompt(提示),Predict】【刘鹏飞】
【网络攻防实训习题】
How to upgrade kubernetes in place
晶振是如何起振的?
【Flask】获取请求信息、重定向、错误处理
GBase 8c数据库升级报错
Basic operations of databases and tables ----- unique constraints
Force buckle 9 palindromes
正则表达式:示例(1)