diff --git a/pkgs/development/python-modules/bpycv/bpycv-test.py b/pkgs/development/python-modules/bpycv/bpycv-test.py index 94e1bb122c77..1bf2b9f5a8d3 100644 --- a/pkgs/development/python-modules/bpycv/bpycv-test.py +++ b/pkgs/development/python-modules/bpycv/bpycv-test.py @@ -5,8 +5,11 @@ import bpycv import os import glob import random +from pathlib import Path example_data_dir = os.environ['BPY_EXAMPLE_DATA'] +out_dir = Path(os.environ['out']) +out_dir.mkdir(parents=True, exist_ok=True) models = sorted(glob.glob(os.path.join(example_data_dir, "model", "*", "*.obj"))) cat_id_to_model_path = dict(enumerate(sorted(models), 1)) @@ -19,6 +22,7 @@ bpy.context.scene.render.engine = "CYCLES" bpy.context.scene.cycles.samples = 32 bpy.context.scene.render.resolution_y = 1024 bpy.context.scene.render.resolution_x = 1024 +bpy.context.view_layer.cycles.denoising_store_passes = False # A transparency stage for holding rigid body stage = bpycv.add_stage(transparency=True) @@ -69,8 +73,8 @@ for i in range(20): # render image, instance annoatation and depth in one line code result = bpycv.render_data() -dataset_dir = "./dataset" -result.save(dataset_dir=dataset_dir, fname="0", save_blend=True) -print(f'Save to "{dataset_dir}"') -print(f'Open "{dataset_dir}/vis/" to see visualize result.') + +result.save(dataset_dir=str(out_dir.resolve()), fname="0", save_blend=True) +print(f'Save to "{out_dir}"') +print(f'Open "{out_dir}/vis/" to see visualize result.') diff --git a/pkgs/development/python-modules/bpycv/default.nix b/pkgs/development/python-modules/bpycv/default.nix index 03aef9fd6dfe..09c3b4f8283d 100644 --- a/pkgs/development/python-modules/bpycv/default.nix +++ b/pkgs/development/python-modules/bpycv/default.nix @@ -1,16 +1,21 @@ -{ lib -, buildPythonPackage -, fetchPypi -, fetchFromGitHub -, fetchurl -, writeText -, blender -, minexr +{ stdenv +, lib , beautifulsoup4 -, zcs -, requests -, opencv3 +, blender +, blender-with-packages , boxx +, bpycv +, buildPythonPackage +, fetchFromGitHub +, fetchPypi +, fetchurl +, minexr +, opencv3 +, python3Packages +, requests +, runCommand +, writeText +, zcs }: buildPythonPackage rec { @@ -37,27 +42,32 @@ buildPythonPackage rec { ''; # pythonImportsCheck = [ "bpycv" ]; # this import depends on bpy that is only available inside blender - nativeCheckInputs = [ blender ]; - checkPhase = let - bpycv_example_data = fetchFromGitHub { - owner = "DIYer22"; - repo = "bpycv_example_data"; - hash = "sha256-dGb6KvbXTGTu5f4AqhA+i4AwTqBoR5SdXk0vsMEcD3Q="; - rev = "6ce0e65c107d572011394da16ffdf851e988dbb4"; - }; - in '' - TEMPDIR=$(mktemp -d) - pushd $TEMPDIR - cp -r ${bpycv_example_data} example_data - chmod +w -R example_data - BPY_EXAMPLE_DATA=${bpycv_example_data} blender -b -P ${./bpycv-test.py} - popd - ''; + doCheck = false; + + passthru.tests = { + render = runCommand "bpycv-render-test" { + BPY_EXAMPLE_DATA = fetchFromGitHub { + owner = "DIYer22"; + repo = "bpycv_example_data"; + hash = "sha256-dGb6KvbXTGTu5f4AqhA+i4AwTqBoR5SdXk0vsMEcD3Q="; + rev = "6ce0e65c107d572011394da16ffdf851e988dbb4"; + }; + nativeBuildInputs = [ + ((blender-with-packages.override {inherit blender python3Packages;}) { + packages = [ bpycv ]; + }) + ]; + } '' + blender-wrapped -b -P ${./bpycv-test.py} + ''; + }; meta = with lib; { description = "Computer vision utils for Blender"; homepage = "https://github.com/DIYer22/bpycv"; license = licenses.mit; - maintainers = with maintainers; [ lucasew ]; + maintainers = [ maintainers.lucasew ]; + broken = stdenv.isAarch64; + inherit (blender.meta) platforms; }; }