python3Packages.bpycv: refactor + passthru.tests
Signed-off-by: lucasew <lucas59356@gmail.com>
This commit is contained in:
parent
fd34bc39e4
commit
3acc4aff87
2 changed files with 46 additions and 32 deletions
|
@ -5,8 +5,11 @@ import bpycv
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import random
|
import random
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
example_data_dir = os.environ['BPY_EXAMPLE_DATA']
|
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")))
|
models = sorted(glob.glob(os.path.join(example_data_dir, "model", "*", "*.obj")))
|
||||||
cat_id_to_model_path = dict(enumerate(sorted(models), 1))
|
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.cycles.samples = 32
|
||||||
bpy.context.scene.render.resolution_y = 1024
|
bpy.context.scene.render.resolution_y = 1024
|
||||||
bpy.context.scene.render.resolution_x = 1024
|
bpy.context.scene.render.resolution_x = 1024
|
||||||
|
bpy.context.view_layer.cycles.denoising_store_passes = False
|
||||||
|
|
||||||
# A transparency stage for holding rigid body
|
# A transparency stage for holding rigid body
|
||||||
stage = bpycv.add_stage(transparency=True)
|
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
|
# render image, instance annoatation and depth in one line code
|
||||||
result = bpycv.render_data()
|
result = bpycv.render_data()
|
||||||
|
|
||||||
dataset_dir = "./dataset"
|
|
||||||
result.save(dataset_dir=dataset_dir, fname="0", save_blend=True)
|
result.save(dataset_dir=str(out_dir.resolve()), fname="0", save_blend=True)
|
||||||
print(f'Save to "{dataset_dir}"')
|
print(f'Save to "{out_dir}"')
|
||||||
print(f'Open "{dataset_dir}/vis/" to see visualize result.')
|
print(f'Open "{out_dir}/vis/" to see visualize result.')
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
{ lib
|
{ stdenv
|
||||||
, buildPythonPackage
|
, lib
|
||||||
, fetchPypi
|
|
||||||
, fetchFromGitHub
|
|
||||||
, fetchurl
|
|
||||||
, writeText
|
|
||||||
, blender
|
|
||||||
, minexr
|
|
||||||
, beautifulsoup4
|
, beautifulsoup4
|
||||||
, zcs
|
, blender
|
||||||
, requests
|
, blender-with-packages
|
||||||
, opencv3
|
|
||||||
, boxx
|
, boxx
|
||||||
|
, bpycv
|
||||||
|
, buildPythonPackage
|
||||||
|
, fetchFromGitHub
|
||||||
|
, fetchPypi
|
||||||
|
, fetchurl
|
||||||
|
, minexr
|
||||||
|
, opencv3
|
||||||
|
, python3Packages
|
||||||
|
, requests
|
||||||
|
, runCommand
|
||||||
|
, writeText
|
||||||
|
, zcs
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
|
@ -37,27 +42,32 @@ buildPythonPackage rec {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# pythonImportsCheck = [ "bpycv" ]; # this import depends on bpy that is only available inside blender
|
# pythonImportsCheck = [ "bpycv" ]; # this import depends on bpy that is only available inside blender
|
||||||
nativeCheckInputs = [ blender ];
|
doCheck = false;
|
||||||
checkPhase = let
|
|
||||||
bpycv_example_data = fetchFromGitHub {
|
passthru.tests = {
|
||||||
owner = "DIYer22";
|
render = runCommand "bpycv-render-test" {
|
||||||
repo = "bpycv_example_data";
|
BPY_EXAMPLE_DATA = fetchFromGitHub {
|
||||||
hash = "sha256-dGb6KvbXTGTu5f4AqhA+i4AwTqBoR5SdXk0vsMEcD3Q=";
|
owner = "DIYer22";
|
||||||
rev = "6ce0e65c107d572011394da16ffdf851e988dbb4";
|
repo = "bpycv_example_data";
|
||||||
};
|
hash = "sha256-dGb6KvbXTGTu5f4AqhA+i4AwTqBoR5SdXk0vsMEcD3Q=";
|
||||||
in ''
|
rev = "6ce0e65c107d572011394da16ffdf851e988dbb4";
|
||||||
TEMPDIR=$(mktemp -d)
|
};
|
||||||
pushd $TEMPDIR
|
nativeBuildInputs = [
|
||||||
cp -r ${bpycv_example_data} example_data
|
((blender-with-packages.override {inherit blender python3Packages;}) {
|
||||||
chmod +w -R example_data
|
packages = [ bpycv ];
|
||||||
BPY_EXAMPLE_DATA=${bpycv_example_data} blender -b -P ${./bpycv-test.py}
|
})
|
||||||
popd
|
];
|
||||||
'';
|
} ''
|
||||||
|
blender-wrapped -b -P ${./bpycv-test.py}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Computer vision utils for Blender";
|
description = "Computer vision utils for Blender";
|
||||||
homepage = "https://github.com/DIYer22/bpycv";
|
homepage = "https://github.com/DIYer22/bpycv";
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = with maintainers; [ lucasew ];
|
maintainers = [ maintainers.lucasew ];
|
||||||
|
broken = stdenv.isAarch64;
|
||||||
|
inherit (blender.meta) platforms;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue