Skip to main content

tools for using Blender for cv

Project description

Blender for cv

This library helps CV researchers to generate data using blender.

Library tutorial

This repo provides a simple package blcv that can put models into scene and get images from different viewpoints.

Install

You can use pip install blcv to install the package.

Note that we should use blcv in Blender's bundled Python, so you need to install the package in Blender's Python environment.

Use the following commands:

$ cd /blender-path/2.xx/python/bin/

/blender-path/2.xx/python/bin$ python.exe get-pip.py

/blender-path/2.xx/python/bin$ python.exe -m pip install blcv

If you encounter more problems installing blcv in Blender environment, you can refer to this answer.

If there is problems using pip, you can simply clone this repo, and use the files in blcv folder.

Functions

blcv

  • call_blender(render_code, blender_executable_path, blank_blend_file_path, io_redirect='', background=True): activate Blender and call the script
    • render_code: directory to Blender script
    • blender_executable_path: directory to Blender.exe
    • blank_blend_file_path: Blender file
    • io_redirect: redirect the output into a file, use '' to show the output in command lines
    • background: whether run the Blender in background, default as 'True'

blcv.tools

  • BcObject: operate an existed object in the scene
    • init(self, id): input the name of the object
    • destroy(self): delete the object
    • set_loc(self, x, y, z): set the object's location
    • get_loc(self, x, y, z): get the object's location
    • set_rot(self, x, y, z, w=None, mode='XYZ'): set the object's rotation; the mode includes 'AXIS_ANGLE', 'QUATERNION' and 'XYZ'
    • get_rot(self, mode='XYZ', w=None): set the object's rotation; the mode includes 'AXIS_ANGLE', 'QUATERNION' and 'XYZ'
    • set_scale(self, x, y, z): set the object's scale
    • get_scale(self, ): get the object's scale
  • BcCamera(BcObject): operate an camera in the scene
    • init(self, id): input the name of the camera
    • set_camera_to_center(self, dist, azimuth_deg, elevation_deg, theta_deg): given the camera's rotation, set the camera in the position towards the center point [0, 0, 0]
  • BcScene:
    • init(self)
    • set_render_mode(self, mode): set the background mode
    • get_img(self, filepath): save image crop in filaepath
  • import_obj(shape_file): import a new model into the scene and return its name

Demo

You can modify the configurations and run start_blender.py to call blender_script in Blender.

The demo generates airplane images from circle viewpoints using the models in examples folder, the results will be saved in images folder.

Contact

If you have any questions or encounter any problems, feel free to contact me by sarahwei0210@gmail.com.

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.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

blcv-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file blcv-0.1.0.tar.gz.

File metadata

  • Download URL: blcv-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.4

File hashes

Hashes for blcv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c309c09322ac7eec59f4da28d56950f7bdf57e572878db71b03d4b8421341fc
MD5 c21a8fc547d674116c2e15f3658b14d0
BLAKE2b-256 7a80bff51cd060172583e12ae8292ab52769bb946cff905efe8f3ae673a4eee2

See more details on using hashes here.

File details

Details for the file blcv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: blcv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.4

File hashes

Hashes for blcv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 053df7d636c35ce7a6fb031fec945d42b1e2fd035d1a8ecf572006c3d5343a5e
MD5 663600ba4daa0875b8b21518ae5fe591
BLAKE2b-256 a4afffce6be64467eebdb23fc6dce4774c9bae1479b4bc980090539844e9e6fd

See more details on using hashes here.

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