Class: Naiso::CLI
- Inherits:
-
Object
- Object
- Naiso::CLI
- Defined in:
- lib/naiso/cli.rb
Overview
CLI 인터페이스
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run(args = ARGV) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/naiso/cli.rb', line 8 def initialize = { threshold: 10.0, gap: 50, min_height: nil, max_height: nil, output: nil, check_text: false, json_output: nil, merge: false, merge_only: false } end |
Instance Method Details
#run(args = ARGV) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/naiso/cli.rb', line 22 def run(args = ARGV) parse_args(args) # 병합만 수행하는 경우 if [:merge_only] ImageMerger.merge_sections([:merge_only]) return end config = SplitConfig.new( variance_threshold: [:threshold], min_gap_height: [:gap], min_section_height: [:min_height], max_section_height: [:max_height] ) splitter = ImageSplitter.new(config) result = splitter.split([:image], output_dir: [:output]) # 텍스트 검출 옵션이 활성화된 경우 if [:check_text] && result.output_files.any? detector = TextDetector.new # JSON 경로 결정 (지정하지 않으면 출력 디렉토리에 자동 생성) json_path = [:json_output] if json_path.nil? && [:check_text] output_dir = [:output] || File.join(File.dirname([:image]), 'sections') base_name = File.basename([:image], '.*') json_path = File.join(output_dir, "#{base_name}_text_analysis.json") end detector.analyze_images(result.output_files, json_path: json_path) end # 병합 옵션이 활성화된 경우 if [:merge] && result.output_files.any? output_dir = [:output] || File.join(File.dirname([:image]), 'sections') ImageMerger.merge_sections(output_dir) end end |