OpenGL 3D旋转的木箱

2023-10-12 00:20
文章标签 3d 旋转 opengl 木箱

本文主要是介绍OpenGL 3D旋转的木箱,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

学习自:

https://learnopengl-cn.github.io/01%20Getting%20started/08%20Coordinate%20Systems/#3d

0,首先添加glm库文件

相关方法可以参照我指定的那篇随便

1,顶点着色器shader.vs

#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;out vec2 TexCoord;uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;void main()
{gl_Position = projection * view * model * vec4(aPos, 1.0f);TexCoord = vec2(aTexCoord.x, aTexCoord.y);
}

 

2,片段着色器shader.fs

#version 330 core
out vec4 FragColor;in vec2 TexCoord;// texture samplers
uniform sampler2D texture1;
uniform sampler2D texture2;void main()
{// linearly interpolate between both textures (80% container, 20% awesomeface)FragColor = mix(texture(texture1, TexCoord), texture(texture2, TexCoord), 0.2);
}

3,主程序

  1 #include <glad/glad.h>
  2 #include <GLFW/glfw3.h>
  3   
  4 #include <glm/glm.hpp>
  5 #include <glm/gtc/matrix_transform.hpp>
  6 #include <glm/gtc/type_ptr.hpp>
  7 
  8 #include "stb_image.h"
  9 #include "shader_s.h"
 10 #include <iostream>
 11 
 12 void framebuffer_size_callback(GLFWwindow* window, int width, int height);
 13 void processInput(GLFWwindow *window);
 14 
 15 // settings
 16 const unsigned int SCR_WIDTH = 800;
 17 const unsigned int SCR_HEIGHT = 600;
 18 
 19 int main()
 20 {
 21     // glfw: initialize and configure
 22     // ------------------------------
 23     glfwInit();
 24     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
 25     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
 26     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
 27 
 28 #ifdef __APPLE__
 29     glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
 30 #endif
 31 
 32     // glfw window creation
 33     // --------------------
 34     GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
 35     if (window == NULL)
 36     {
 37         std::cout << "Failed to create GLFW window" << std::endl;
 38         glfwTerminate();
 39         return -1;
 40     }
 41     glfwMakeContextCurrent(window);
 42     glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
 43 
 44     // glad: load all OpenGL function pointers
 45     // ---------------------------------------
 46     if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
 47     {
 48         std::cout << "Failed to initialize GLAD" << std::endl;
 49         return -1;
 50     }
 51 
 52     // configure global opengl state
 53     // -----------------------------
 54     glEnable(GL_DEPTH_TEST);
 55 
 56     // build and compile our shader zprogram
 57     // ------------------------------------
 58     Shader ourShader("../res/textures/texture.vs", "../res/textures/texture.fs");
 59 
 60     // set up vertex data (and buffer(s)) and configure vertex attributes
 61     // ------------------------------------------------------------------
 62     /*
 63     float vertices[] = {
 64         // 位置信息          // 颜色信息           // 纹理 coords
 65          0.5f,  0.5f, 0.0f,   1.0f, 0.0f, 0.0f,   1.0f, 1.0f, // 右上
 66          0.5f, -0.5f, 0.0f,   0.0f, 1.0f, 0.0f,   1.0f, 0.0f, // 右下
 67         -0.5f, -0.5f, 0.0f,   0.0f, 0.0f, 1.0f,   0.0f, 0.0f, // 左下
 68         -0.5f,  0.5f, 0.0f,   1.0f, 1.0f, 0.0f,   0.0f, 1.0f  // 左上
 69     };
 70     unsigned int indices[] = {
 71         0, 1, 3, // 第一个三角形
 72         1, 2, 3  // 第二个三角形
 73     };
 74     */
 75     float vertices[] = {
 76     -0.5f, -0.5f, -0.5f,  0.0f, 0.0f,
 77      0.5f, -0.5f, -0.5f,  1.0f, 0.0f,
 78      0.5f,  0.5f, -0.5f,  1.0f, 1.0f,
 79      0.5f,  0.5f, -0.5f,  1.0f, 1.0f,
 80     -0.5f,  0.5f, -0.5f,  0.0f, 1.0f,
 81     -0.5f, -0.5f, -0.5f,  0.0f, 0.0f,
 82 
 83     -0.5f, -0.5f,  0.5f,  0.0f, 0.0f,
 84      0.5f, -0.5f,  0.5f,  1.0f, 0.0f,
 85      0.5f,  0.5f,  0.5f,  1.0f, 1.0f,
 86      0.5f,  0.5f,  0.5f,  1.0f, 1.0f,
 87     -0.5f,  0.5f,  0.5f,  0.0f, 1.0f,
 88     -0.5f, -0.5f,  0.5f,  0.0f, 0.0f,
 89 
 90     -0.5f,  0.5f,  0.5f,  1.0f, 0.0f,
 91     -0.5f,  0.5f, -0.5f,  1.0f, 1.0f,
 92     -0.5f, -0.5f, -0.5f,  0.0f, 1.0f,
 93     -0.5f, -0.5f, -0.5f,  0.0f, 1.0f,
 94     -0.5f, -0.5f,  0.5f,  0.0f, 0.0f,
 95     -0.5f,  0.5f,  0.5f,  1.0f, 0.0f,
 96 
 97      0.5f,  0.5f,  0.5f,  1.0f, 0.0f,
 98      0.5f,  0.5f, -0.5f,  1.0f, 1.0f,
 99      0.5f, -0.5f, -0.5f,  0.0f, 1.0f,
100      0.5f, -0.5f, -0.5f,  0.0f, 1.0f,
101      0.5f, -0.5f,  0.5f,  0.0f, 0.0f,
102      0.5f,  0.5f,  0.5f,  1.0f, 0.0f,
103 
104     -0.5f, -0.5f, -0.5f,  0.0f, 1.0f,
105      0.5f, -0.5f, -0.5f,  1.0f, 1.0f,
106      0.5f, -0.5f,  0.5f,  1.0f, 0.0f,
107      0.5f, -0.5f,  0.5f,  1.0f, 0.0f,
108     -0.5f, -0.5f,  0.5f,  0.0f, 0.0f,
109     -0.5f, -0.5f, -0.5f,  0.0f, 1.0f,
110 
111     -0.5f,  0.5f, -0.5f,  0.0f, 1.0f,
112      0.5f,  0.5f, -0.5f,  1.0f, 1.0f,
113      0.5f,  0.5f,  0.5f,  1.0f, 0.0f,
114      0.5f,  0.5f,  0.5f,  1.0f, 0.0f,
115     -0.5f,  0.5f,  0.5f,  0.0f, 0.0f,
116     -0.5f,  0.5f, -0.5f,  0.0f, 1.0f
117     };
118     
119     unsigned int VBO, VAO;
120     glGenVertexArrays(1, &VAO);
121     glGenBuffers(1, &VBO);
122 
123     glBindVertexArray(VAO);
124 
125     glBindBuffer(GL_ARRAY_BUFFER, VBO);
126     glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
127 
128     // position attribute
129     glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
130     glEnableVertexAttribArray(0);
131     // texture coord attribute
132     glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
133     glEnableVertexAttribArray(1);
134 
135     //    加载并创建纹理
136     // -------------------------
137     unsigned int texture1, texture2;
138     //    第一张纹理
139 
140     glGenTextures(1, &texture1);
141     glBindTexture(GL_TEXTURE_2D, texture1);
142     //    为当前绑定的纹理对象设置环绕、过滤方式
143     //    将纹理包装设置为GL_REPEAT(默认包装方法)
144     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);    
145     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
146     //    设置纹理过滤参数
147     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
148     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
149     // 加载并生成纹理
150     int width, height, nrChannels;
151     stbi_set_flip_vertically_on_load(true); //告诉stb_image.h在y轴上翻转加载的纹理。
152 
153     unsigned char *data = stbi_load("../res/textures/container.jpg", &width, &height, &nrChannels, 0);
154     if (data)
155     {
156         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
157         glGenerateMipmap(GL_TEXTURE_2D);
158     }
159     else
160     {
161         std::cout << "Failed to load texture" << std::endl;
162     }
163     stbi_image_free(data);
164 
165 
166     // texture 2
167     glGenTextures(1, &texture2);
168     glBindTexture(GL_TEXTURE_2D, texture2);
169     // set the texture wrapping parameters
170     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);    // set texture wrapping to GL_REPEAT (default wrapping method)
171     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
172     // set texture filtering parameters
173     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
174     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
175     // load image, create texture and generate mipmaps
176     data = stbi_load("../res/textures/awesomeface.png", &width, &height, &nrChannels, 0);
177     if (data)
178     {
179         //请注意,awesomeface.png具有透明度,因此具有alpha通道,
180         //因此请务必告诉OpenGL数据类型为GL_RGBA        
181         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
182         glGenerateMipmap(GL_TEXTURE_2D);
183     }
184     else
185     {
186         std::cout << "Failed to load texture" << std::endl;
187     }
188     stbi_image_free(data);
189 
190     //告诉每个采样器的opengl它属于哪个纹理单元(只需要做一次)    
191     ourShader.use(); //激活着色器
192     // either set it manually like so:
193     glUniform1i(glGetUniformLocation(ourShader.ID, "texture1"), 0);
194     // or set it via the texture class
195     ourShader.setInt("texture2", 1);
196 
197 
198 
199     // render loop
200     // -----------
201     while (!glfwWindowShouldClose(window))
202     {
203         // input
204        // -----
205         processInput(window);
206 
207         // render
208         // ------
209         glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
210         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // also clear the depth buffer now!
211 
212         // bind textures on corresponding texture units
213         glActiveTexture(GL_TEXTURE0);
214         glBindTexture(GL_TEXTURE_2D, texture1);
215         glActiveTexture(GL_TEXTURE1);
216         glBindTexture(GL_TEXTURE_2D, texture2);
217 
218         // activate shader
219         ourShader.use();
220 
221         // create transformations
222         glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
223         glm::mat4 view = glm::mat4(1.0f);
224         glm::mat4 projection = glm::mat4(1.0f);
225         model = glm::rotate(model, (float)glfwGetTime(), glm::vec3(0.5f, 1.0f, 0.0f));
226         view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f));
227         projection = glm::perspective(glm::radians(45.0f), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
228         // retrieve the matrix uniform locations
229         unsigned int modelLoc = glGetUniformLocation(ourShader.ID, "model");
230         unsigned int viewLoc = glGetUniformLocation(ourShader.ID, "view");
231         // pass them to the shaders (3 different ways)
232         glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));
233         glUniformMatrix4fv(viewLoc, 1, GL_FALSE, &view[0][0]);
234         // note: currently we set the projection matrix each frame, but since the projection matrix rarely changes it's often best practice to set it outside the main loop only once.
235         ourShader.setMat4("projection", projection);
236 
237         // render box
238         glBindVertexArray(VAO);
239         glDrawArrays(GL_TRIANGLES, 0, 36);
240 
241 
242         // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
243         // -------------------------------------------------------------------------------
244         glfwSwapBuffers(window);
245         glfwPollEvents();
246     }
247 
248     // optional: de-allocate all resources once they've outlived their purpose:
249     // ------------------------------------------------------------------------
250     glDeleteVertexArrays(1, &VAO);
251     glDeleteBuffers(1, &VBO);
252     //glDeleteBuffers(1, &EBO);
253 
254     // glfw: terminate, clearing all previously allocated GLFW resources.
255     // ------------------------------------------------------------------
256     glfwTerminate();
257     return 0;
258 }
259 
260 // process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
261 // ---------------------------------------------------------------------------------------------------------
262 void processInput(GLFWwindow *window)
263 {
264     if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
265         glfwSetWindowShouldClose(window, true);
266 }
267 
268 // glfw: whenever the window size changed (by OS or user resize) this callback function executes
269 // ---------------------------------------------------------------------------------------------
270 void framebuffer_size_callback(GLFWwindow* window, int width, int height)
271 {
272     // make sure the viewport matches the new window dimensions; note that width and 
273     // height will be significantly larger than specified on retina displays.
274     glViewport(0, 0, width, height);
275 }
TestShader.cpp

注意一点的是,我们的着色器类,在这里要添加几个方法,我去百度了一下,找到了常用的一些方法,把各个类型的的set函数都加进来了。

  1 #include "shader_s.h"
  2 
  3 Shader::Shader(const GLchar * vertexPath, const GLchar * fragmentPath)
  4 {
  5     // 1. 从文件路径中获取顶点/片段着色器
  6     std::string vertexCode;
  7     std::string fragmentCode;
  8     std::ifstream vShaderFile;
  9     std::ifstream fShaderFile;
 10     // 保证ifstream对象可以抛出异常:
 11     vShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
 12     fShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
 13     try
 14     {
 15         // 打开文件
 16         vShaderFile.open(vertexPath);
 17         fShaderFile.open(fragmentPath);
 18         std::stringstream vShaderStream, fShaderStream;
 19         // 读取文件的缓冲内容到数据流中
 20         vShaderStream << vShaderFile.rdbuf();
 21         fShaderStream << fShaderFile.rdbuf();
 22         // 关闭文件处理器
 23         vShaderFile.close();
 24         fShaderFile.close();
 25         // 转换数据流到string
 26         vertexCode = vShaderStream.str();
 27         fragmentCode = fShaderStream.str();
 28     }
 29     catch (std::ifstream::failure e)
 30     {
 31         std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl;
 32     }
 33     const char* vShaderCode = vertexCode.c_str();
 34     const char * fShaderCode = fragmentCode.c_str();
 35     // 2. 编译着色器
 36     unsigned int vertex, fragment;
 37     // 顶点着色器    vs
 38     vertex = glCreateShader(GL_VERTEX_SHADER);
 39     glShaderSource(vertex, 1, &vShaderCode, NULL);
 40     glCompileShader(vertex);
 41     checkCompileErrors(vertex, "VERTEX");
 42     // 片段着色器    fs
 43     fragment = glCreateShader(GL_FRAGMENT_SHADER);
 44     glShaderSource(fragment, 1, &fShaderCode, NULL);
 45     glCompileShader(fragment);
 46     checkCompileErrors(fragment, "FRAGMENT");
 47     // 着色器程序
 48     ID = glCreateProgram();
 49     glAttachShader(ID, vertex);
 50     glAttachShader(ID, fragment);
 51     glLinkProgram(ID);
 52     checkCompileErrors(ID, "PROGRAM");
 53     // 删除着色器,它们已经链接到我们的程序中了,已经不再需要了    glDeleteShader(vertex);
 54     glDeleteShader(fragment);
 55 }
 56 
 57 void Shader::use()
 58 {
 59     glUseProgram(ID);
 60 }
 61 
 62 void Shader::setBool(const std::string & name, bool value) const
 63 {
 64     glUniform1i(glGetUniformLocation(ID, name.c_str()), (int)value);
 65 }
 66 
 67 void Shader::setInt(const std::string & name, int value) const
 68 {
 69     glUniform1i(glGetUniformLocation(ID, name.c_str()), value);
 70 }
 71 
 72 void Shader::setFloat(const std::string & name, float value) const
 73 {
 74     glUniform1f(glGetUniformLocation(ID, name.c_str()), value);
 75 }
 76 
 77 void Shader::setVec2(const std::string & name, const glm::vec2 & value) const
 78 {
 79     glUniform2fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
 80 }
 81 
 82 void Shader::setVec2(const std::string & name, float x, float y) const
 83 {
 84     glUniform2f(glGetUniformLocation(ID, name.c_str()), x, y);
 85 }
 86 
 87 void Shader::setVec3(const std::string & name, const glm::vec3 & value) const
 88 {
 89     glUniform3fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
 90 }
 91 
 92 void Shader::setVec3(const std::string & name, float x, float y, float z) const
 93 {
 94     glUniform3f(glGetUniformLocation(ID, name.c_str()), x, y, z);
 95 }
 96 
 97 void Shader::setVec4(const std::string & name, const glm::vec4 & value) const
 98 {
 99     glUniform4fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]);
100 }
101 
102 void Shader::setVec4(const std::string & name, float x, float y, float z, float w)
103 {
104     glUniform4f(glGetUniformLocation(ID, name.c_str()), x, y, z, w);
105 }
106 
107 void Shader::setMat2(const std::string & name, const glm::mat2 & mat) const
108 {
109     glUniformMatrix2fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, &mat[0][0]);
110 }
111 
112 void Shader::setMat3(const std::string & name, const glm::mat3 & mat) const
113 {
114     glUniformMatrix3fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, &mat[0][0]);
115 }
116 
117 void Shader::setMat4(const std::string & name, const glm::mat4 & mat) const
118 {
119     glUniformMatrix4fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, &mat[0][0]);
120 }
121 
122 void Shader::checkCompileErrors(unsigned int shader, std::string type)
123 {
124     int success;
125     char infoLog[1024];
126     if (type != "PROGRAM")
127     {
128         glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
129         if (!success)
130         {
131             glGetShaderInfoLog(shader, 1024, NULL, infoLog);
132             std::cout << "ERROR::SHADER_COMPILATION_ERROR of type: " << type << "\n" << infoLog << "\n -- --------------------------------------------------- -- " << std::endl;
133         }
134     }
135     else
136     {
137         glGetProgramiv(shader, GL_LINK_STATUS, &success);
138         if (!success)
139         {
140             glGetProgramInfoLog(shader, 1024, NULL, infoLog);
141             std::cout << "ERROR::PROGRAM_LINKING_ERROR of type: " << type << "\n" << infoLog << "\n -- --------------------------------------------------- -- " << std::endl;
142         }
143     }
144 }
shader_s.cpp

自己把相关的类定义写道头文件中就可以了。

4,运行结果

 

转载于:https://www.cnblogs.com/icyhusky/p/10738530.html

这篇关于OpenGL 3D旋转的木箱的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/191906

相关文章

基于 HTML5 Canvas 实现图片旋转与下载功能(完整代码展示)

《基于HTML5Canvas实现图片旋转与下载功能(完整代码展示)》本文将深入剖析一段基于HTML5Canvas的代码,该代码实现了图片的旋转(90度和180度)以及旋转后图片的下载... 目录一、引言二、html 结构分析三、css 样式分析四、JavaScript 功能实现一、引言在 Web 开发中,

使用animation.css库快速实现CSS3旋转动画效果

《使用animation.css库快速实现CSS3旋转动画效果》随着Web技术的不断发展,动画效果已经成为了网页设计中不可或缺的一部分,本文将深入探讨animation.css的工作原理,如何使用以及... 目录1. css3动画技术简介2. animation.css库介绍2.1 animation.cs

Python使用Matplotlib绘制3D曲面图详解

《Python使用Matplotlib绘制3D曲面图详解》:本文主要介绍Python使用Matplotlib绘制3D曲面图,在Python中,使用Matplotlib库绘制3D曲面图可以通过mpl... 目录准备工作绘制简单的 3D 曲面图绘制 3D 曲面图添加线框和透明度控制图形视角Matplotlib

css实现图片旋转功能

《css实现图片旋转功能》:本文主要介绍了四种CSS变换效果:图片旋转90度、水平翻转、垂直翻转,并附带了相应的代码示例,详细内容请阅读本文,希望能对你有所帮助... 一 css实现图片旋转90度.icon{ -moz-transform:rotate(-90deg); -webkit-transfo

Qt QWidget实现图片旋转动画

《QtQWidget实现图片旋转动画》这篇文章主要为大家详细介绍了如何使用了Qt和QWidget实现图片旋转动画效果,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 一、效果展示二、源码分享本例程通过QGraphicsView实现svg格式图片旋转。.hpjavascript

无人叉车3d激光slam多房间建图定位异常处理方案-墙体画线地图切分方案

墙体画线地图切分方案 针对问题:墙体两侧特征混淆误匹配,导致建图和定位偏差,表现为过门跳变、外月台走歪等 ·解决思路:预期的根治方案IGICP需要较长时间完成上线,先使用切分地图的工程化方案,即墙体两侧切分为不同地图,在某一侧只使用该侧地图进行定位 方案思路 切分原理:切分地图基于关键帧位置,而非点云。 理论基础:光照是直线的,一帧点云必定只能照射到墙的一侧,无法同时照到两侧实践考虑:关

poj 2187 凸包or旋转qia壳法

题意: 给n(50000)个点,求这些点与点之间距离最大的距离。 解析: 先求凸包然后暴力。 或者旋转卡壳大法。 代码: #include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#include <cstring>#include <cmath>#include <s

MiniGPT-3D, 首个高效的3D点云大语言模型,仅需一张RTX3090显卡,训练一天时间,已开源

项目主页:https://tangyuan96.github.io/minigpt_3d_project_page/ 代码:https://github.com/TangYuan96/MiniGPT-3D 论文:https://arxiv.org/pdf/2405.01413 MiniGPT-3D在多个任务上取得了SoTA,被ACM MM2024接收,只拥有47.8M的可训练参数,在一张RTX

Android 10.0 mtk平板camera2横屏预览旋转90度横屏拍照图片旋转90度功能实现

1.前言 在10.0的系统rom定制化开发中,在进行一些平板等默认横屏的设备开发的过程中,需要在进入camera2的 时候,默认预览图像也是需要横屏显示的,在上一篇已经实现了横屏预览功能,然后发现横屏预览后,拍照保存的图片 依然是竖屏的,所以说同样需要将图片也保存为横屏图标了,所以就需要看下mtk的camera2的相关横屏保存图片功能, 如何实现实现横屏保存图片功能 如图所示: 2.mtk

SAM2POINT:以zero-shot且快速的方式将任何 3D 视频分割为视频

摘要 我们介绍 SAM2POINT,这是一种采用 Segment Anything Model 2 (SAM 2) 进行零样本和快速 3D 分割的初步探索。 SAM2POINT 将任何 3D 数据解释为一系列多向视频,并利用 SAM 2 进行 3D 空间分割,无需进一步训练或 2D-3D 投影。 我们的框架支持各种提示类型,包括 3D 点、框和掩模,并且可以泛化到不同的场景,例如 3D 对象、室