Blenderproc渲染6D位姿估计数据集

https://github.com/DLR-RM/BlenderProc/tree/main/examples/datasets/bop_challenge

目录

1.3d渲染原理

2.步骤

3.代码

生成mask_all

4.难例渲染

物体高反光​编辑​编辑强弱灯光(明暗)​编辑​编辑​编辑物体xyz范围缩小

物体重复

干扰物(自定义干扰物遮挡)​

物体添加dust

指定遮挡

模糊


1.3d渲染原理

https://zhuanlan.zhihu.com/p/616649293

1.几何计算

将3D模型转化为计算机可处理的数据结构,例如三角网格,为后续计算做准备

2.光照计算

根据光源的位置、颜色和光照强度等参数,计算每个像素的颜色和亮度。这个过程需要考虑光照的反射、漫反射、高光反射等多种因素,以模拟真实世界的光照效果

3.映射: 将2D纹理贴到3D模型表面上,使其更加真实。这个过程需要将2D 纹理坐标与3D模型表面坐标进行映射,以便将纹理正确地贴到3D模型表面上。

4.像素渲染:

将计算得到的颜色和亮度信息应用到每个像素上,生成最终的2D 图像。这个过程需要将计算得到的颜色值经过抗锯齿等处理,以消除锯齿和模糊等现象,使得图像更加真实。

2.步骤

  1. 使用 3D 建模软件创建 3D 对象或模型。

有多种方法可以创建 3D 模型或整个场景。一些雕刻应用程序允许您创建和塑造多边形,最终形成 3D 资产。例如,这种类型的建模可能特别适合创建有机资产(例如植物或人物),因为它非常适合对有些不规则的形状进行艺术诠释。

存在这种方法的替代方法。其他建模工具专注于在三维空间中创建边和表面,而不是多边形。以这种方式创建 3D 资产可实现极高的数学精度,此类工具通常用于工业设计或计算机辅助设计 (CAD) 建模。

或者,您可能会选择使用专用工具“扫描”现有的现实生活中的对象——从此类扫描中捕获的数据将使您能够在 3D 空间中重新创建对象。或者您可能更喜欢走程序生成路线,在这种路线中,您的软件会根据一组先前建立的数学规则为您塑造一个模型。

无论您如何创建 3D 模型,下一步都是纹理化。

2.为3D物体添加材质。

多边形定义 3D 对象的形状,但它们本身缺乏颜色或表面细节。艺术家能够为 3D 对象中的每个多边形分配纹理。纹理可以是简单的单色,也可以模拟任何表面的外观,从岩石或木材等天然材料到工业金属或塑料表面。

一个 3D 对象可以由数千个(如果不是数百万个)多边形组成。该对象可能看起来具有厨房搅拌机的现代工业光滑度或大象的粗糙皮肤,但其核心仍然是一个由多边形和有些空白的表面组成的对象。然而,使用正确的 3D 材料,可以创建 3D 深度的错觉。这些纹理远不止简单地为物体添加反射率或颜色——纹理可以添加精细的细节,例如服装面料的缝合,或工业金属表面边缘的铆钉排。如果您要手动将它们添加到对象的几何体中,那么创建这些细节将非常耗时。

3. 为 3D 环境添加照明。

3D 对象需要看起来像是存在于现实世界中。对于建筑渲染和建筑可视化等常见用例尤其如此,它们可以将基本的平面图变成对未来的清晰愿景。

逼真的光源在将多边形对象的集合变成看起来真实的空间方面发挥着重要作用。但是 3D 艺术家通常不会自己在光线或阴影中作画。相反,3D 场景包括照亮各种对象的方向、强度和光源类型的设置。

  1. 渲染 3D 图像。

一旦创建了 3D 对象并对其进行了纹理处理,并且照亮了环境,3D 渲染过程就开始了。这是一个计算机驱动的过程,本质上是从您定义的角度拍摄场景的“快照”。结果是 3D 场景的 2D 图像。

渲染软件可以创建单个图像,也可以快速连续地渲染多个图像以创建实时运动的错觉。

渲染不是一个统一的过程——有许多方法可以使用,例如实时、光线追踪等,它们会影响渲染的质量。、

3.代码

blenderproc run examples/datasets/bop_challenge/main_lm_upright.py 
/media/px_dataset1/fuzhao_datasets/paxini_model 
/home/fuzhao/poseEstimate/FFB6D/ffb6d/blender_project/BlenderProc/cc_texture_dataset 
/home/fuzhao/blender/out2 --num_scenes=500

生成mask_all

需要指定场景,修改bop渲染后数据的目录,和模型文件名id对应的图片名id

Write mask: https://github.com/DLR-RM/BlenderProc/blob/main/blenderproc/python/writer/BopWriterUtility.py

https://github.com/thodan/bop_toolkit/blob/master/scripts/calc_gt_masks.py

if calc_mask_info_coco:# Set up the bop toolkitSetupUtility.setup_pip(["git+https://github.com/thodan/bop_toolkit", "PyOpenGL==3.1.0"])# determine which objects to add to the vsipy renderer# for numpy>=1.20, np.float is deprecated: https://numpy.org/doc/stable/release/1.20.0-notes.html#deprecationsnp.float = float# Determine for which directories mask_info_coco has to be calculatedchunk_dirs = sorted(glob.glob(os.path.join(chunks_dir, '*')))chunk_dirs = [d for d in chunk_dirs if os.path.isdir(d)]chunk_dir_ids = [d.split('/')[-1] for d in chunk_dirs]chunk_dirs = chunk_dirs[chunk_dir_ids.index(f"{starting_chunk_id:06d}"):]# convert all objects to trimesh objectstrimesh_objects = {}for obj in dataset_objects:if obj.get_cp('category_id') in trimesh_objects:continueif isinstance(obj, Link):if not obj.visuals:continueif len(obj.visuals) > 1:warnings.warn('BOP Writer only supports saving annotations of one visual mesh per Link')trimesh_obj = obj.mesh_as_trimesh()# we need to create a double-sided material to be able to render non-watertight meshes# the other parameters are defaults, see# https://github.com/mmatl/pyrender/blob/master/pyrender/mesh.py#L216-L223material = pyrender.MetallicRoughnessMaterial(alphaMode='BLEND', baseColorFactor=[0.3, 0.3, 0.3, 1.0],metallicFactor=0.2, roughnessFactor=0.8, doubleSided=True)# here we also add the scale factor of the objects. the position of the pyrender camera will change based# on the initial scale factor of the objects and the saved annotation formatif not np.all(np.isclose(np.array(obj.blender_obj.scale), obj.blender_obj.scale[0])):print("WARNING: the scale is not the same across all dimensions, writing bop_toolkit annotations with ""the bop writer will fail!")trimesh_objects[obj.get_cp('category_id')] = pyrender.Mesh.from_trimesh(mesh=trimesh_obj, material=material)_BopWriterUtility.calc_gt_masks(chunk_dirs=chunk_dirs, starting_frame_id=starting_frame_id,dataset_objects=trimesh_objects, annotation_scale=annotation_scale,delta=delta)_BopWriterUtility.calc_gt_info(chunk_dirs=chunk_dirs, starting_frame_id=starting_frame_id,dataset_objects=trimesh_objects, annotation_scale=annotation_scale,delta=delta)_BopWriterUtility.calc_gt_coco(chunk_dirs=chunk_dirs, dataset_objects=dataset_objects,starting_frame_id=starting_frame_id)
def calc_gt_masks(chunk_dirs: List[str], dataset_objects: Dict[int, pyrender.Mesh], starting_frame_id: int = 0,annotation_scale: float = 1000., delta: float = 0.015):""" Calculates the ground truth masks.From the BOP toolkit (https://github.com/thodan/bop_toolkit), with the difference of using pyrender for depthrendering.:param chunk_dirs: List of directories to calculate the gt masks for.:param dataset_objects: Dict containing all objects to save the annotations for.:param starting_frame_id: The first frame id the writer has written during this run.:param annotation_scale: The scale factor applied to the calculated annotations (in [m]) to get them into thespecified format (see `annotation_format` in `write_bop` for further details).:param delta: Tolerance used for estimation of the visibility masks."""# This import is done inside to avoid having the requirement that BlenderProc depends on the bop_toolkit# pylint: disable=import-outside-toplevelfrom bop_toolkit_lib import inout, misc, visibility# pylint: enable=import-outside-toplevelwidth = bpy.context.scene.render.resolution_xheight = bpy.context.scene.render.resolution_yrenderer = pyrender.OffscreenRenderer(viewport_width=width, viewport_height=height)for dir_counter, chunk_dir in enumerate(chunk_dirs):last_chunk_gt_fpath = os.path.join(chunk_dir, 'scene_gt.json')last_chunk_camera_fpath = os.path.join(chunk_dir, 'scene_camera.json')scene_gt = _BopWriterUtility.load_json(last_chunk_gt_fpath, keys_to_int=True)scene_camera = _BopWriterUtility.load_json(last_chunk_camera_fpath, keys_to_int=True)# Create folders for the output masks (if they do not exist yet).mask_dir_path = os.path.dirname(os.path.join(chunk_dir, 'mask', '000000_000000.png'))misc.ensure_dir(mask_dir_path)mask_visib_dir_path = os.path.dirname(os.path.join(chunk_dir, 'mask_visib', '000000_000000.png'))misc.ensure_dir(mask_visib_dir_path)im_ids = sorted(scene_gt.keys())# append to existing outputif dir_counter == 0:im_ids = im_ids[starting_frame_id:]for im_counter, im_id in enumerate(im_ids):if im_counter % 100 == 0:misc.log(f'Calculating GT masks - {chunk_dir}, {im_counter}')K = np.array(scene_camera[im_id]['cam_K']).reshape(3, 3)fx, fy, cx, cy = K[0, 0], K[1, 1], K[0, 2], K[1, 2]camera = pyrender.IntrinsicsCamera(fx=fx, fy=fy, cx=cx, cy=cy, znear=0.1, zfar=100000)# Load depth image.depth_path = os.path.join(chunk_dir, 'depth', '{im_id:06d}.png').format(im_id=im_id)depth_im = inout.load_depth(depth_path)depth_im *= scene_camera[im_id]['depth_scale']  # to [mm]depth_im /= 1000.  # to [m]dist_im = misc.depth_im_to_dist_im_fast(depth_im, K)for gt_id, gt in enumerate(scene_gt[im_id]):# create a new scenescene = pyrender.Scene()# add camera and current objectscene.add(camera)t = np.array(gt['cam_t_m2c'])# rescale translation depending on initial saving formatt /= annotation_scalepose = bop_pose_to_pyrender_coordinate_system(cam_R_m2c=np.array(gt['cam_R_m2c']).reshape(3, 3),cam_t_m2c=t)scene.add(dataset_objects[gt['obj_id']], pose=pose)# Render the depth image._, depth_gt = renderer.render(scene=scene)# Convert depth image to distance image.dist_gt = misc.depth_im_to_dist_im_fast(depth_gt, K)# Mask of the full object silhouette.mask = dist_gt > 0# Mask of the visible part of the object silhouette.mask_visib = visibility.estimate_visib_mask_gt(dist_im, dist_gt, delta, visib_mode='bop19')# Save the calculated masks.mask_path = os.path.join(chunk_dir, 'mask', '{im_id:06d}_{gt_id:06d}.png').format(im_id=im_id, gt_id=gt_id)inout.save_im(mask_path, 255 * mask.astype(np.uint8))mask_visib_path = os.path.join(chunk_dir, 'mask_visib','{im_id:06d}_{gt_id:06d}.png').format(im_id=im_id, gt_id=gt_id)inout.save_im(mask_visib_path, 255 * mask_visib.astype(np.uint8))

4.难例渲染

手抓遮挡,纹理背景复杂

一个场景多个椰汁(【model list】又放回抽样模型)

https://github.com/DLR-RM/BlenderProc/blob/main/examples/basics/camera_sampling/README.md

物体高反光强弱灯光(明暗)物体xyz范围缩小

为了产生遮挡

注意:太小,碰撞检测会不过关,需要很多次采样,但都不一定能成功,耗时

物体重复

干扰物(自定义干扰物遮挡)

需要修改函数,传入obj和干扰物

获取obj的xyz,同时限定干扰物的xyz和obj的xyz高度接近,xy接近,z不接近,避免碰撞检测不过关

物体添加dust

指定遮挡

模糊

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/2905546.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

DP1363F高度集成的非接触读写芯片 13.56M NFC/RFID

DP1363F高度集成的非接触读写芯片 13.56M NFC/RFID读卡器芯片 兼容替代CLRC663 DP1363F是一款高度集成的非接触读写芯片,集强大的多协议支持、最高射频输出功率,以及突破性技术低功耗卡片检测等优势于一身,满足市场对更高集成度、更小外壳和互…

Coursera自然语言处理专项课程03:Natural Language Processing with Sequence Models笔记 Week01

Natural Language Processing with Sequence Models Course Certificate 本文是https://www.coursera.org/learn/sequence-models-in-nlp 这门课程的学习笔记,如有侵权,请联系删除。 文章目录 Natural Language Processing with Sequence ModelsWeek 01…

docker:在ubuntu中运行docker容器

前言 1 本笔记本电脑运行的ubuntu20.04系统 2 docker运行在ubuntu20.04系统 3 docker镜像使用的是ubuntu18.04,这样拉的 docker pull ubuntu:18.04 4 docker容器中运行的是ubuntu18.04的系统,嗯就是严谨 5 这纯粹是学习笔记,实际上没啥价值。…

经纬恒润AUTOSAR产品成功适配芯来RISC-V车规内核

近日,经纬恒润AUTOSAR基础软件产品INTEWORK-EAS(ECU AUTOSAR Software,以下简称EAS)在芯来提供的HP060开发板上成功适配芯来科技的RISC-V处理器NA内核,双方携手打造了具备灵活、可靠、高性能、强安全性的解决方案。这极…

【分布式】——CAPBASE理论

CAP&BASE理论 ⭐⭐⭐⭐⭐⭐ Github主页👉https://github.com/A-BigTree 笔记链接👉https://github.com/A-BigTree/tree-learning-notes ⭐⭐⭐⭐⭐⭐ Spring专栏👉https://blog.csdn.net/weixin_53580595/category_12279588.html Sprin…

STM32使用USART发送数据包指令点亮板载LED灯

电路连接: 连接显示屏模块,显示屏的SCL在B10,SDA在B11。 程序目的: 发送LED_ON指令打开板载LED灯,发送LED_OFF关闭板载LED灯,与上一个博客不同,这个实际上是实现串口收发文本数据包。 …

ES学习日记(一)-------单节点安装启动

基于ES7.4.1编写,其实一开始用的最新的8.1,但是问题太多了!!!!不稳定,降到7.4 下载好的安装包上传到服务器或虚拟机,创建ES目录,命令mkdir -p /路径xxxx 复制安装包到指定路径并解压: tar zxvf elasticsearch-8.1.0-linux-x86_64.tar.gz -C /usr/local/es/ 进入bin目录安装,命…

边缘计算盒子 | 什么是边缘计算盒子?选型要看哪些参数?

边缘计算(Edge Computing)是一种分布式计算范式,它将计算资源和数据存储位于离网络核心节点较近的地方,以降低延迟、提高传输速度和数据安全性。通常可以把边缘计算盒子(Edge Computing Box)理解成一种集成了边缘计算功能的硬件设备,通常部署…

揭秘’在家答答题,无需经验、无论男女、单号轻松日产200+的一个玩法

项目简介 公众号:老A程序站 这个项目是人人可参与的,无需支付任何费用,只需投入时间即可。每天的任务主要是回答问题。 项目 地 址 : laoa1.cn/1457.html 如果遇到不会的问题,可以直接使用百度进行搜索。我们通过…

NEO 学习之 MLE(最大似然估计)

文章目录 简单题目MLE 在不同的分布的运用正态分布指数分布均匀分布泊松分布 简单题目 此题问的是求丢色子,求得到偶数点的概率 求两次都得到硬币的背面的概率 拿球问题 符合的点数是 1,5,6 MLE 在不同的分布的运用 正态分布 对于给定的数据集 {1, 3, 4, 6, 7}&am…

Autodesk Maya 2025---智能建模与动画创新,重塑创意工作流程

Autodesk Maya 2025是一款顶尖的三维动画软件,广泛应用于影视广告、角色动画、电影特技等领域。新版本在功能上进行了全面升级,新增了对Apple芯片的支持,建模、绑定和角色动画等方面的功能也更加出色。 在功能特色方面,Maya 2025…

深度学习每周学习总结P3(天气识别)

🍨 本文为🔗365天深度学习训练营 中的学习记录博客🍖 原作者:K同学啊 | 接辅导、项目定制 数据链接 提取码:o3ix 目录 0. 总结1. 数据导入部分数据导入部分代码详解:a. 数据读取部分a.1 提问:关…

【Hello,PyQt】控件拖拽

在 PyQt 中实现控件拖拽功能的详细介绍 拖拽功能是现代用户界面设计中常见的交互方式之一,它可以提高用户体验,增加操作的直观性。在 PyQt 中,我们可以很容易地实现控件之间的拖拽功能。本文将介绍如何在 PyQt 中实现控件的拖拽功能。 如何实…

达梦数据库新手上路排坑

数据库安装 这个没啥说的,按照官网教程操作,我使用的是docker进行安装 下载文件docker文件 官方下载地址- load -i dm8****.tar (注意修改为当前下载的文件)达梦官方文档注意修改为当前版本 docker run -d -p 5236:5236 --name dm8 --privilegedtrue -…

第十届蓝桥杯大赛个人赛省赛(软件类)真题- CC++ 研究生组-最短路

6 肉眼观察&#xff0c; 看起来短的几条路对比下来是6~ #include <iostream> using namespace std; int main() {printf("6");return 0; }

<el-table>设置一列为固定字段,其他列为循环生成

<el-table :data"tableData" style"width: 100%"><el-table-columnprop"name"label"固定字段名":formatter"formatter"></el-table-column><el-table-columnv-for"(item, index) in wordsColumns…

四川易点慧电子商务抖音小店:前景无忧,创新引领未来零售风潮

在数字经济高速发展的今天&#xff0c;电子商务已成为推动经济增长的重要引擎。四川易点慧电子商务有限公司紧跟时代步伐&#xff0c;积极布局抖音小店&#xff0c;展现出强劲的发展势头和广阔的前景。 抖音小店作为抖音平台上的重要商业生态&#xff0c;凭借其庞大的用户群体和…

安卓调试桥ADB

Logcat 命令行工具 | Android Studio | Android Developers 什么是ADB ADB 全称为 Android Debug Bridge &#xff0c;是 Android SDK &#xff08;安卓的开发工具&#xff09;中的一个工具&#xff0c;起到调试桥的作用&#xff0c;是一个 客户端 - 服务器端程序 。其中 …

[SpringCloud] Feign Client 的创建 (二) (五)

文章目录 1.自动配置FeignAutoConfiguration2.生成 Feign Client2.1 从Feign Client子容器获取组件2.2 Feign Client子容器的创建2.3 构建Feign Client实例 1.自动配置FeignAutoConfiguration spring-cloud-starter-openfeign 包含了 spring-cloud-openfeign-core FeignAutoCo…

【计算机网络篇】数据链路层(4.2)可靠传输的实现机制

文章目录 &#x1f354;可靠传输的实现机制⭐停止 - 等待协议&#x1f5d2;️注意 &#x1f50e;停止 - 等待协议的信道利用率&#x1f5c3;️练习题 ⭐回退N帧协议&#x1f388;回退N帧协议的基本工作流程&#x1f50e;无传输差错的情况&#x1f50e;超时重传的情况&#x1f5…