File tree Expand file tree Collapse file tree 5 files changed +42
-5
lines changed Expand file tree Collapse file tree 5 files changed +42
-5
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,7 @@ version = "0.1.0"
44edition = " 2024"
55
66[dependencies ]
7+ targetgen-lib = { path = " targetgen-lib" }
78clap = {version = " 4.5.20" , features = [" default" ]}
9+ simple_logger = " 5.0.0"
10+ log = " 0.4.22"
Original file line number Diff line number Diff line change 1+ use log:: LevelFilter ;
2+ use simple_logger:: SimpleLogger ;
3+ use targetgen_lib:: generator;
4+ use targetgen_lib:: generator:: TargetGenerator ;
5+
16fn main ( ) {
27
8+ }
9+
10+ #[ ignore]
11+ #[ test]
12+ fn create_live_test ( ) {
13+ SimpleLogger :: new ( ) . with_level ( LevelFilter :: Debug ) . init ( ) . unwrap ( ) ;
14+
15+ generator:: util:: cleanup_output ( "output" ) . unwrap ( ) ;
16+
17+ let mut tg = TargetGenerator :: new ( "backgrounds" , "objects" , "output/annotations.json" ) . unwrap ( ) ;
18+ tg. config . permit_collisions = false ;
19+ tg. config . do_random_rotation = true ;
20+ tg. generate_targets ( 1 , ..6 , "output" ) . unwrap ( ) ;
21+
22+ tg. close ( ) ;
323}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ use util::STANDARD_PPM;
2020
2121pub mod coco;
2222pub mod error;
23- pub ( crate ) mod util;
23+ pub mod util;
2424pub mod config;
2525
2626const COLLISION_ATTEMPTS : u32 = 15 ;
@@ -30,7 +30,7 @@ pub struct TargetGenerator {
3030 pub object_manager : ObjectManager ,
3131 background_loader : BackgroundLoader ,
3232 coco_generator : Arc < Mutex < CocoGenerator > > ,
33- pub ( crate ) config : TargetGeneratorConfig ,
33+ pub config : TargetGeneratorConfig ,
3434 resized_cache : Cache < String , DynamicImage > ,
3535}
3636
Original file line number Diff line number Diff line change 1+ use std:: fs;
2+ use std:: path:: Path ;
13use crate :: generator:: error:: GenerationError ;
24use image:: metadata:: Orientation ;
35use image:: DynamicImage ;
@@ -67,6 +69,18 @@ pub fn is_image_type(path: &str) -> bool {
6769 path. ends_with ( ".png" ) || path. ends_with ( ".jpg" ) || path. ends_with ( ".jpeg" )
6870}
6971
72+ pub fn cleanup_output < P : AsRef < Path > > ( folder_path : P ) -> std:: io:: Result < ( ) > {
73+ for entry in fs:: read_dir ( folder_path) ? {
74+ let entry = entry?;
75+ let path = entry. path ( ) ;
76+
77+ if entry. file_type ( ) ?. is_file ( ) && ( is_image_type ( path. to_str ( ) . unwrap ( ) ) || path. extension ( ) . unwrap ( ) == "json" ) {
78+ fs:: remove_file ( entry. path ( ) ) ?;
79+ }
80+ }
81+ Ok ( ( ) )
82+ }
83+
7084#[ test]
7185fn test_is_image_type ( ) {
7286 assert_eq ! ( is_image_type( "test.png" ) , true ) ;
Original file line number Diff line number Diff line change 11#![ allow( dead_code) ] // allows unused struct members
22
3- mod backgrounds;
4- mod objects;
5- mod generator;
3+ pub mod backgrounds;
4+ pub mod objects;
5+ pub mod generator;
You can’t perform that action at this time.
0 commit comments