Skip to main content

tools for using Blender for cv

Project description

Blender for cv

This repo provides tutorials and a library to help CV researchers to generate data using blender.

Introduction

Blender is good for single image rendering; it provides complete python interface and good support for shapenet models.

Game engine based software (Unreal, Unity) provides a virtual world for simulation, which is better for agents to interact with the environment; a lot of VR assets to buy in the market.

Blender tutorial

panel

The whole interface is divided into several panels, each panel has type and the type can be changed (3D view, Timeline, etc).

pic1

split new panel

To create more panels, drag the triangle on the right top of the main panel, and pull towards left or down, a new panel will appear.

pic2

merge panels

To merge two panels, drag the triangle and pull towards top or right to merge the corresponding panel.

pic3

Navigate

left click - pivot point

right click - select

wheel - zoom in / out

Import object

File -> import -> .obj

Press F12 to render the image (see the objects from camera point)

Press F11 to go back

Change the camera location in the interface

Directly move the camera and point light in the 3D viewpoint scene. Use the options below to change the location, rotation and scale.

pic4

Select the object panel and change the number of these objects.

pic5

Use the view menu to toggle to other views. (The example below shows the top view)

pic6

Add more object to the scene

From the left panel Create to find objects to put into the scene.

All the objects in the scene are shown in the Outliner panel.

pic7

Use python to control the scene

Switch the bottom panel to python console

Try to print hello world

pic8

But how to control objects in the scene by python?

Use the bpy module provided by Blender to access the scene.

Hover over text field to get the object's python value and change it in python console using python grammar.

pic9

Build the automation pipeline

Switch the panel type to text editor, new or open a file and write python script in it.

pic10

Finish your script then click Run script to see the difference.

Be aware that while writing in the file, you need to import bpy first, or there may be error.

pic11

Best way to run the script

In the last section, we introduce the way of running script within Blender, but usually we would like to run it in the command line.

This section tells how to write scripts to achieve generating images automatically.

To start Blender in the command line, we can use blender --script xxx.py to run xxx.py in Blender

Two types of python scripts

  • Outside to call Blender
  • Inside Blender to control Blender

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blcv-0.0.2.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

blcv-0.0.2-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page