tcamviewer 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. tcamviewer-0.1.0/CMakeLists.txt +64 -0
  2. tcamviewer-0.1.0/LICENSE +176 -0
  3. tcamviewer-0.1.0/MANIFEST.in +11 -0
  4. tcamviewer-0.1.0/PKG-INFO +392 -0
  5. tcamviewer-0.1.0/README.md +361 -0
  6. tcamviewer-0.1.0/include/tcamviewer/decoder.hpp +63 -0
  7. tcamviewer-0.1.0/include/tcamviewer/renderer.hpp +82 -0
  8. tcamviewer-0.1.0/include/tcamviewer/tcamviewer.h +107 -0
  9. tcamviewer-0.1.0/include/tcamviewer/terminal.hpp +44 -0
  10. tcamviewer-0.1.0/pyproject.toml +35 -0
  11. tcamviewer-0.1.0/python/tcamviewer/__init__.py +5 -0
  12. tcamviewer-0.1.0/python/tcamviewer/client.py +200 -0
  13. tcamviewer-0.1.0/python/tcamviewer.egg-info/PKG-INFO +392 -0
  14. tcamviewer-0.1.0/python/tcamviewer.egg-info/SOURCES.txt +63 -0
  15. tcamviewer-0.1.0/python/tcamviewer.egg-info/dependency_links.txt +1 -0
  16. tcamviewer-0.1.0/python/tcamviewer.egg-info/top_level.txt +1 -0
  17. tcamviewer-0.1.0/setup.cfg +4 -0
  18. tcamviewer-0.1.0/setup.py +89 -0
  19. tcamviewer-0.1.0/src/c_api.cpp +181 -0
  20. tcamviewer-0.1.0/src/cli/main.cpp +326 -0
  21. tcamviewer-0.1.0/src/decoder.cpp +250 -0
  22. tcamviewer-0.1.0/src/renderer.cpp +348 -0
  23. tcamviewer-0.1.0/src/terminal.cpp +74 -0
  24. tcamviewer-0.1.0/tests/CMakeLists.txt +18 -0
  25. tcamviewer-0.1.0/tests/test_c_api.cpp +53 -0
  26. tcamviewer-0.1.0/tests/test_decoder.cpp +15 -0
  27. tcamviewer-0.1.0/tests/test_renderer.cpp +222 -0
  28. tcamviewer-0.1.0/tests/test_terminal.cpp +20 -0
  29. tcamviewer-0.1.0/third_party/wcppcli/.github/workflows/ci.yml +54 -0
  30. tcamviewer-0.1.0/third_party/wcppcli/AGENTS.md +88 -0
  31. tcamviewer-0.1.0/third_party/wcppcli/CMakeLists.txt +159 -0
  32. tcamviewer-0.1.0/third_party/wcppcli/LICENSE +21 -0
  33. tcamviewer-0.1.0/third_party/wcppcli/README.md +182 -0
  34. tcamviewer-0.1.0/third_party/wcppcli/cmake/wcppcliConfig.cmake.in +5 -0
  35. tcamviewer-0.1.0/third_party/wcppcli/config.ini +1 -0
  36. tcamviewer-0.1.0/third_party/wcppcli/examples/completion_example.cpp +39 -0
  37. tcamviewer-0.1.0/third_party/wcppcli/examples/config_formats_example.cpp +51 -0
  38. tcamviewer-0.1.0/third_party/wcppcli/examples/ensure_file_example.cpp +32 -0
  39. tcamviewer-0.1.0/third_party/wcppcli/examples/full_example.cpp +59 -0
  40. tcamviewer-0.1.0/third_party/wcppcli/examples/interactive_example.cpp +38 -0
  41. tcamviewer-0.1.0/third_party/wcppcli/examples/log_example.cpp +20 -0
  42. tcamviewer-0.1.0/third_party/wcppcli/examples/nested_config_example.cpp +48 -0
  43. tcamviewer-0.1.0/third_party/wcppcli/examples/priority_merge_example.cpp +66 -0
  44. tcamviewer-0.1.0/third_party/wcppcli/examples/schema_validation_example.cpp +62 -0
  45. tcamviewer-0.1.0/third_party/wcppcli/include/wcppcli/wcli.hpp +53 -0
  46. tcamviewer-0.1.0/third_party/wcppcli/include/wcppcli/wconf.hpp +76 -0
  47. tcamviewer-0.1.0/third_party/wcppcli/include/wcppcli/wlog.hpp +32 -0
  48. tcamviewer-0.1.0/third_party/wcppcli/include/wcppcli/wstyle.hpp +73 -0
  49. tcamviewer-0.1.0/third_party/wcppcli/include/wcppcli/wui.hpp +22 -0
  50. tcamviewer-0.1.0/third_party/wcppcli/ports/wcppcli/portfile.cmake +22 -0
  51. tcamviewer-0.1.0/third_party/wcppcli/ports/wcppcli/vcpkg.json +12 -0
  52. tcamviewer-0.1.0/third_party/wcppcli/src/environment.hpp +25 -0
  53. tcamviewer-0.1.0/third_party/wcppcli/src/wcli.cpp +211 -0
  54. tcamviewer-0.1.0/third_party/wcppcli/src/wcli_main.cpp +785 -0
  55. tcamviewer-0.1.0/third_party/wcppcli/src/wconf.cpp +333 -0
  56. tcamviewer-0.1.0/third_party/wcppcli/src/wlog.cpp +98 -0
  57. tcamviewer-0.1.0/third_party/wcppcli/src/wstyle.cpp +174 -0
  58. tcamviewer-0.1.0/third_party/wcppcli/src/wui.cpp +72 -0
  59. tcamviewer-0.1.0/third_party/wcppcli/tests/test_framework.hpp +115 -0
  60. tcamviewer-0.1.0/third_party/wcppcli/tests/test_main.cpp +5 -0
  61. tcamviewer-0.1.0/third_party/wcppcli/tests/test_wcli.cpp +171 -0
  62. tcamviewer-0.1.0/third_party/wcppcli/tests/test_wconf.cpp +145 -0
  63. tcamviewer-0.1.0/third_party/wcppcli/tests/test_wlog.cpp +63 -0
  64. tcamviewer-0.1.0/third_party/wcppcli/tests/test_wstyle.cpp +25 -0
  65. tcamviewer-0.1.0/third_party/wcppcli/vcpkg.json +8 -0
@@ -0,0 +1,64 @@
1
+ cmake_minimum_required(VERSION 3.16)
2
+ project(tcamviewer VERSION 0.1.0 LANGUAGES C CXX)
3
+
4
+ set(CMAKE_CXX_STANDARD 17)
5
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
6
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
7
+
8
+ find_package(PkgConfig REQUIRED)
9
+ pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec)
10
+ pkg_check_modules(AVFORMAT REQUIRED IMPORTED_TARGET libavformat)
11
+ pkg_check_modules(SWSCALE REQUIRED IMPORTED_TARGET libswscale)
12
+ pkg_check_modules(AVUTIL REQUIRED IMPORTED_TARGET libavutil)
13
+
14
+ # Include wcppcli CLI framework
15
+ add_subdirectory(third_party/wcppcli)
16
+
17
+ # Core Shared Library (C-ABI and C++ API)
18
+ add_library(tcamviewer SHARED
19
+ src/terminal.cpp
20
+ src/renderer.cpp
21
+ src/decoder.cpp
22
+ src/c_api.cpp
23
+ )
24
+
25
+ target_include_directories(tcamviewer PUBLIC
26
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
27
+ $<INSTALL_INTERFACE:include>
28
+ )
29
+
30
+ target_link_libraries(tcamviewer PUBLIC
31
+ PkgConfig::AVCODEC
32
+ PkgConfig::AVFORMAT
33
+ PkgConfig::SWSCALE
34
+ PkgConfig::AVUTIL
35
+ pthread
36
+ )
37
+
38
+ target_compile_definitions(tcamviewer PRIVATE TCAMVIEWER_EXPORT)
39
+
40
+ # Standalone CLI Executable
41
+ add_executable(tcamviewer_cli src/cli/main.cpp)
42
+ set_target_properties(tcamviewer_cli PROPERTIES OUTPUT_NAME "tcamviewer")
43
+ target_link_libraries(tcamviewer_cli PRIVATE
44
+ tcamviewer
45
+ wcppcli
46
+ )
47
+
48
+ # Testing
49
+ option(BUILD_TESTING "Build tests" ON)
50
+ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
51
+ enable_testing()
52
+ add_subdirectory(tests)
53
+ endif()
54
+
55
+ # Installation
56
+ include(GNUInstallDirs)
57
+ install(TARGETS tcamviewer tcamviewer_cli
58
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
59
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
60
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
61
+ )
62
+ install(DIRECTORY include/tcamviewer
63
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
64
+ )
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or exemplary damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,11 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ recursive-include include *.h *.hpp
5
+ recursive-include src *.cpp
6
+ recursive-include third_party *
7
+ include CMakeLists.txt
8
+ include .gitmodules
9
+ recursive-include tests *
10
+
11
+ global-exclude *.py[cod] __pycache__ .git* .DS_Store
@@ -0,0 +1,392 @@
1
+ Metadata-Version: 2.4
2
+ Name: tcamviewer
3
+ Version: 0.1.0
4
+ Summary: High-performance Terminal Video Player & Camera Monitor Library
5
+ Home-page: https://github.com/wkqco33/tcamviewer
6
+ Author: wkqco33
7
+ License: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/wkqco33/tcamviewer
9
+ Project-URL: Repository, https://github.com/wkqco33/tcamviewer.git
10
+ Project-URL: Issues, https://github.com/wkqco33/tcamviewer/issues
11
+ Keywords: terminal,video,truecolor,camera,ros2,ansi
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: C++
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Multimedia :: Video :: Display
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Dynamic: home-page
29
+ Dynamic: license-file
30
+ Dynamic: requires-python
31
+
32
+ # tcamviewer 📹
33
+
34
+ [![CI](https://github.com/wkqco33/tcamviewer/actions/workflows/ci.yml/badge.svg)](https://github.com/wkqco33/tcamviewer/actions)
35
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
36
+ ![C++17](https://img.shields.io/badge/Language-C%2B%2B17-00599C?logo=c%2B%2B)
37
+ ![ROS2](https://img.shields.io/badge/ROS_2-Jazzy%20%7C%20Humble-22314E?logo=ros)
38
+ ![Go](https://img.shields.io/badge/Go-1.22+-00ADD8?logo=go)
39
+ ![Python](https://img.shields.io/badge/Python-3.10+-3776AB?logo=python)
40
+
41
+ > **고성능 터미널 비디오 플레이어 & ROS 2 카메라 토픽 모니터 라이브러리**
42
+ > 파일(MP4/MKV), 실시간 네트워크 스트림(RTSP/RTMP), V4L2 웹캠, 그리고 ROS 2 카메라 토픽을 터미널에서 실시간(30~60+ FPS)으로 렌더링합니다.
43
+
44
+ ---
45
+
46
+ ## ✨ 핵심 기능 (Key Features)
47
+
48
+ - **🎨 Half-Block TrueColor (24-bit ANSI) 렌더링**:
49
+ - 유니코드 상단 반쪽 블록 문자(`▀`, U+2580)의 전경색(FG)과 배경색(BG)을 분리하여 **문자 셀 1개당 세로 2픽셀(1:1 비율)**을 표현합니다.
50
+ - 폰트 왜곡 없이 일반 터미널(예: 80×24)에서 80×48 픽셀 해상도로 비디오를 부드럽게 재생합니다.
51
+ - **⚡ Dirty-Diff 캐시 및 Zero-Allocation 스트리밍**:
52
+ - 이전 프레임과 현재 프레임을 64비트 레지스터 단위로 비교하여 **변경된 영역만 ANSI 커서 점프(`\x1b[Row;ColH`)로 업데이트**합니다.
53
+ - 힙 할당 없는 인라인 10진수 포맷터 및 X-LUT 사전 계산을 적용하여 초당 수만 프레임의 연산 처리 성능을 보장하며, 터미널 I/O를 70% 이상 절감합니다.
54
+ - **🌐 범용 비디오 소스 디코딩 (FFmpeg)**:
55
+ - 로컬 비디오 파일 (MP4, MKV, AVI, WebM 등)
56
+ - 네트워크 스트림 (RTSP low-latency TCP, RTMP, HTTP)
57
+ - V4L2 USB 웹캠 디바이스 (`/dev/video0`)
58
+ - **🔌 제로카피 C-ABI 및 다국어 클라이언트 생태계**:
59
+ - **C++ (C++17)**: 코어 엔진 및 초저지연 ROS 2 C++ 네이티브 노드 (`rclcpp`)
60
+ - **Go**: CGO 기반의 고성능 패키지 (`pkg/tcamviewer`)
61
+ - **Python**: 표준 라이브러리 `ctypes` 기반 바인딩 (`python/tcamviewer`) 및 ROS 2 Python 노드 (`rclpy`)
62
+ - **🖥️ 고성능 CLI 인터페이스**:
63
+ - 경량 C++ CLI 프레임워크 [`wcppcli`](https://github.com/wkqco33/wcppcli) 기반으로 제작되어 명령어, 플래그 파싱 및 정형화된 로깅 지원.
64
+ - **📋 Taskfile 기반 자동화**:
65
+ - 빌드, 테스트(TDD), 클린, 예제 실행을 단일 명령어로 손쉽게 관리.
66
+
67
+ ---
68
+
69
+ ## 🏗️ 시스템 아키텍처
70
+
71
+ ```mermaid
72
+ flowchart TB
73
+ subgraph Sources["입력 데이터 소스"]
74
+ F[비디오 파일\nMP4, MKV, AVI]
75
+ S[네트워크 스트림\nRTSP, RTMP, HTTP]
76
+ W[웹캠 디바이스\nV4L2 /dev/video*]
77
+ R1[ROS 2 C++ 토픽\nsensor_msgs/Image]
78
+ R2[ROS 2 Python 토픽\nsensor_msgs/Image, CompressedImage]
79
+ end
80
+
81
+ subgraph CoreEngine["tcamviewer Core (libtcamviewer.so)"]
82
+ Dec[FFmpeg VideoDecoder\navcodec, avformat]
83
+ Scale[Resizer & SwsContext\nlibswscale RGB24 / BGR24]
84
+ Diff[Dirty-Diff Cache Engine\n이전 프레임 비교 최적화]
85
+ Term[Terminal Controller\nANSI TrueColor & Half-Block ▀]
86
+ CABI[C-ABI Interface\ntcamviewer.h]
87
+ end
88
+
89
+ subgraph Applications["클라이언트 & 애플리케이션"]
90
+ CLI["tcamviewer CLI (wcppcli 기반)"]
91
+ GoPkg["Go Client Package (pkg/tcamviewer)"]
92
+ PyPkg["Python Client Package (python/tcamviewer)"]
93
+ ROSNodeCpp["ROS 2 C++ Node (ros2/)"]
94
+ ROSNodePy["ROS 2 Python Node (python/ros2_node.py)"]
95
+ end
96
+
97
+ F --> Dec
98
+ S --> Dec
99
+ W --> Dec
100
+ Dec --> Scale
101
+ R1 --> CABI
102
+ R2 --> CABI
103
+ Scale --> Diff
104
+ Diff --> Term
105
+ Term --> CABI
106
+ CABI --> CLI
107
+ CABI --> GoPkg
108
+ CABI --> PyPkg
109
+ CABI --> ROSNodeCpp
110
+ CABI --> ROSNodePy
111
+ ```
112
+
113
+ ---
114
+
115
+ ## 📦 요구사항 및 의존성
116
+
117
+ - **운영체제**: Linux (Ubuntu 24.04 / 22.04 권장)
118
+ - **컴파일러**: C++17 지원 컴파일러 (`g++` 또는 `clang++`)
119
+ - **빌드 도구**: `cmake` (3.16+), `pkg-config`, `task` ([go-task](https://taskfile.dev))
120
+ - **필수 라이브러리**:
121
+ ```bash
122
+ sudo apt-get update && sudo apt-get install -y \
123
+ libavcodec-dev libavformat-dev libswscale-dev libavutil-dev \
124
+ libgtest-dev pkg-config cmake build-essential
125
+ ```
126
+ - **선택 사항**:
127
+ - Go 1.22+ (Go 클라이언트 사용 시)
128
+ - Python 3.10+ (Python 바인딩 사용 시)
129
+ - ROS 2 Jazzy 또는 Humble (ROS 2 노드 실행 시)
130
+
131
+ ---
132
+
133
+ ## ⚡ Taskfile 명령어 가이드
134
+
135
+ 프로젝트 루트에 작성된 `Taskfile.yml`을 통해 프로젝트의 모든 작업을 손쉽게 관리할 수 있습니다.
136
+
137
+ ```bash
138
+ # 사용 가능한 전체 태스크 목록 보기
139
+ task
140
+ ```
141
+
142
+ | 명령어 | 설명 |
143
+ | :--- | :--- |
144
+ | **`task build`** | C++ 코어 라이브러리(`libtcamviewer.so`), CLI 실행파일, 테스트 바이너리 빌드 |
145
+ | **`task build:core`** | `libtcamviewer.so` 코어 동적 라이브러리만 빌드 |
146
+ | **`task build:cli`** | 독립형 `tcamviewer` CLI 바이너리만 빌드 |
147
+ | **`task build:ros2`** | `colcon`을 사용하여 ROS 2 Jazzy C++ 노드 패키지 빌드 |
148
+ | **`task build:all`** | C++, CLI, 테스트, ROS 2 패키지를 모두 빌드 |
149
+ | **`task test`** | **C++(GoogleTest), Go, Python 모든 단위 테스트 일괄 실행** |
150
+ | **`task test:cpp`** | C++ GoogleTest 단위 테스트 (17개 항목 + 고해상도 벤치마크) 실행 |
151
+ | **`task test:go`** | Go CGO 패키지 단위 테스트 실행 |
152
+ | **`task test:py`** | Python `ctypes` 단위 테스트 실행 |
153
+ | **`task example:cli`** | CLI 30 FPS 애니메이션 테스트 패턴 실행 (3초간 렌더링) |
154
+ | **`task example:go`** | Go 언어로 구현된 비디오 렌더링 데모 실행 |
155
+ | **`task example:py`** | Python 언어로 구현된 비디오 렌더링 데모 실행 |
156
+ | **`task example:ros2-py`** | Python ROS 2 카메라 토픽 수신 노드 실행 (`/camera/image_raw`) |
157
+ | **`task example:ros2-cpp`**| C++ 네이티브 ROS 2 카메라 토픽 수신 노드 실행 |
158
+ | **`task install`** | 라이브러리, 헤더, CLI를 시스템 디렉토리에 설치 |
159
+ | **`task clean`** | 빌드 산출물(`build/`, `install/`, `log/`, `__pycache__`) 정리 |
160
+
161
+ ---
162
+
163
+ ## 🚀 사용법 (Usage)
164
+
165
+ ### 1. CLI 도구 (`tcamviewer`)
166
+
167
+ `wcppcli` 기반으로 빌드된 CLI 실행파일은 파일 재생, 실시간 스트리밍, 성능 테스트를 지원합니다.
168
+
169
+ ```bash
170
+ # 1. 터미널 TrueColor 및 렌더링 속도 테스트 패턴 실행 (30 FPS)
171
+ ./build/tcamviewer test --duration 5 --fps 30
172
+
173
+ # 2. 로컬 비디오 파일 재생 (반복 재생 옵션)
174
+ ./build/tcamviewer play /path/to/video.mp4 --loop
175
+
176
+ # 3. RTSP 저지연 네트워크 스트림 재생
177
+ ./build/tcamviewer play rtsp://192.168.1.100:554/stream1
178
+
179
+ # 4. USB 웹캠 실시간 모니터링
180
+ ./build/tcamviewer play /dev/video0
181
+
182
+ # 5. 회전 보정 (90도/180도/270도 시계방향 회전)
183
+ # 스마트폰 영상이나 카메라가 90도 기울어져 있을 때
184
+ ./build/tcamviewer play /path/to/video.mp4 --rotate 90
185
+ # 단축 플래그
186
+ ./build/tcamviewer play /path/to/video.mp4 -r 90
187
+
188
+ # 6. 종횡비 유지 (기본 활성화: 화면 크기에 맞춰 비율 자동 유지 및 중앙 정렬)
189
+ # 비율 무시하고 터미널 전체로 늘리기(Stretch) 옵션:
190
+ ./build/tcamviewer play /path/to/video.mp4 --stretch
191
+
192
+ # 7. CLI 옵션 도움말 확인
193
+ ./build/tcamviewer --help
194
+ ./build/tcamviewer play --help
195
+ ```
196
+
197
+ > 💡 **재생 중 인터랙티브 키 제어**:
198
+ > - **`a` 또는 `A`**: **종횡비 유지(Fit) ↔ 터미널 채우기(Stretch)** 실시간 토글!
199
+ > - **`r` 또는 `R`**: 재생 중에 누르면 실시간으로 시계 방향 90도 회전 (+90° → +180° → +270° → 0°)
200
+ > - **`q` 또는 `Q`**: 재생 종료
201
+ > - **`Ctrl+C`**: 안전한 터미널 복구 및 종료
202
+
203
+ ---
204
+
205
+ ### 2. ROS 2 카메라 모니터링
206
+
207
+ #### (1) Python 노드 (`python/ros2_node.py`)
208
+ `rclpy` 환경에서 즉시 실행 가능하며, `sensor_msgs/msg/Image` 및 `sensor_msgs/msg/CompressedImage`를 모두 지원합니다.
209
+
210
+ ```bash
211
+ source /opt/ros/jazzy/setup.bash
212
+
213
+ # 기본 Raw 이미지 토픽 구독 (/camera/image_raw)
214
+ python3 python/ros2_node.py
215
+
216
+ # 특정 토픽 지정 및 90도 회전 보정
217
+ python3 python/ros2_node.py --ros-args -p topic:=/camera/image_raw -p rotation:=90
218
+
219
+ # 압축(Compressed) 토픽 구독
220
+ python3 python/ros2_node.py --ros-args -p topic:=/camera/image_raw/compressed -p compressed:=true
221
+ ```
222
+
223
+ #### (2) C++ 네이티브 노드 (`ros2/`)
224
+ 초저지연과 극도의 CPU 효율이 필요할 때 사용합니다.
225
+
226
+ ```bash
227
+ # 빌드
228
+ task build:ros2
229
+
230
+ # 실행 (90도 회전 보정 예시)
231
+ source /opt/ros/jazzy/setup.bash
232
+ source install/setup.bash
233
+ ros2 run tcamviewer_ros2 tcamviewer_node --ros-args -p topic:=/camera/image_raw -p rotation:=90
234
+ ```
235
+
236
+ ---
237
+
238
+ ### 3. Go 클라이언트 개발 (`pkg/tcamviewer`)
239
+
240
+ CGO를 통해 C-ABI 라이브러리와 네이티브로 연동됩니다.
241
+
242
+ ```go
243
+ package main
244
+
245
+ import (
246
+ "github.com/wkqco33/tcamviewer/pkg/tcamviewer"
247
+ )
248
+
249
+ func main() {
250
+ cols, rows, _ := tcamviewer.GetTerminalSize()
251
+ renderer, _ := tcamviewer.NewRenderer(tcamviewer.Config{
252
+ TargetCols: cols,
253
+ TargetRows: rows,
254
+ UseDiff: true,
255
+ AltScreen: true,
256
+ HideCursor: true,
257
+ })
258
+ defer renderer.Close()
259
+
260
+ // rgbData: []byte (width * height * 3)
261
+ renderer.RenderRGB(rgbData, width, height, stride)
262
+ }
263
+ ```
264
+
265
+ - **예제 실행**:
266
+ ```bash
267
+ task example:go
268
+ ```
269
+
270
+ ---
271
+
272
+ ### 4. Python 클라이언트 개발 (`python/tcamviewer`)
273
+
274
+ `ctypes`를 사용하여 별도의 C-Extension 컴파일 없이 `libtcamviewer.so`를 즉시 로딩합니다. NumPy 배열 및 바이트 버퍼를 모두 지원합니다.
275
+
276
+ ```python
277
+ from tcamviewer import TerminalRenderer, get_terminal_size
278
+ import numpy as np
279
+
280
+ cols, rows = get_terminal_size()
281
+ renderer = TerminalRenderer(cols=cols, rows=rows, use_diff=True)
282
+
283
+ # data: bytes 또는 numpy.ndarray (H x W x 3)
284
+ image = np.zeros((480, 640, 3), dtype=np.uint8)
285
+ renderer.render_rgb(image, width=640, height=480)
286
+ renderer.close()
287
+ ```
288
+
289
+ - **예제 실행**:
290
+ ```bash
291
+ task example:py
292
+ ```
293
+
294
+ ---
295
+
296
+ ## 🧪 TDD (Test-Driven Development) 테스트
297
+
298
+ 모든 컴포넌트는 TDD 원칙에 따라 단위 테스트가 작성되어 있으며, 단일 명령어로 전체 테스트 스위트를 검증할 수 있습니다:
299
+
300
+ ```bash
301
+ task test
302
+ ```
303
+
304
+ - **C++ Tests (`tests/`, 17개 항목)**:
305
+ - `TerminalTest`: ANSI 이스케이프 코드 유효성 검증, 터미널 크기 감지
306
+ - `RendererTest`: RGB/BGR 픽셀 매핑, Half-block 출력, Dirty-diff 최적화, 리사이즈, 종횡비(Fit/Stretch), 회전(0/90/180/270), 초고속 렌더링 벤치마크(`BenchmarkPerformance`)
307
+ - `CApiTest`: C-ABI 메모리 수명주기, 버퍼 렌더링, 널 포인터 안전성
308
+ - `DecoderTest`: 잘못된 소스 방어 및 예외 처리
309
+ - **Go Tests (`pkg/tcamviewer/tcamviewer_test.go`)**:
310
+ - 터미널 크기 조회, 버퍼 렌더링, 수명 주기, 회전 및 종횡비 제어 검증
311
+ - **Python Tests (`python/tests/test_client.py`)**:
312
+ - ctypes 라이브러리 로드, 버퍼 렌더링, 문자열 블록 일치, 회전 및 종횡비 제어 검증
313
+
314
+ ---
315
+
316
+ ## 📁 디렉터리 구조
317
+
318
+ ```
319
+ tcamviewer/
320
+ ├── CMakeLists.txt # 메인 C++ CMake 빌드 파일
321
+ ├── Taskfile.yml # Taskfile 빌드, 테스트, 실행 자동화 명세
322
+ ├── README.md # 프로젝트 사용자 및 개발 가이드 (본 문서)
323
+ ├── AGENTS.md # 시스템 상세 아키텍처 및 개발자 가이드
324
+ ├── ROADMAP.md # 프로젝트 중장기 개발 로드맵 및 마일스톤
325
+ ├── CONTRIBUTING.md # 오픈소스 기여 가이드라인
326
+ ├── SECURITY.md # 보안 취약점 보고 및 지원 정책
327
+ ├── LICENSE # Apache License 2.0 라이선스 전문
328
+ ├── .clang-format # C++ 코드 스타일 포맷터 설정 (Google C++ 기반)
329
+ ├── .editorconfig # 에디터 공통 인덴트 및 개행 설정
330
+ ├── .github/
331
+ │ ├── workflows/ci.yml # GitHub Actions CI 자동화 워크플로우
332
+ │ ├── ISSUE_TEMPLATE/ # 버그 리포트 및 기능 제안 템플릿
333
+ │ └── PULL_REQUEST_TEMPLATE.md # PR 템플릿
334
+ ├── go.mod # Go 모듈 파일
335
+ ├── third_party/
336
+ │ └── wcppcli/ # wcppcli CLI 프레임워크 (서브모듈)
337
+ ├── include/
338
+ │ └── tcamviewer/
339
+ │ ├── tcamviewer.h # C-ABI 공개 헤더 (C, Go, Python FFI)
340
+ │ ├── terminal.hpp # 터미널 창 제어 및 ANSI 이스케이프
341
+ │ ├── renderer.hpp # Half-block TrueColor 및 Diff 렌더러
342
+ │ └── decoder.hpp # FFmpeg 비디오/스트림 디코더
343
+ ├── src/
344
+ │ ├── terminal.cpp # Terminal 구현체
345
+ │ ├── renderer.cpp # Renderer 구현체 (Zero-allocation 최적화)
346
+ │ ├── decoder.cpp # VideoDecoder 구현체
347
+ │ ├── c_api.cpp # C-ABI 구현체
348
+ │ └── cli/
349
+ │ └── main.cpp # wcppcli 연동 CLI 실행파일
350
+ ├── tests/
351
+ │ ├── CMakeLists.txt # 단위 테스트 CMake 파일
352
+ │ ├── test_terminal.cpp # 터미널 단위 테스트
353
+ │ ├── test_renderer.cpp # 렌더러 & Diff 캐시 & 벤치마크 단위 테스트
354
+ │ ├── test_c_api.cpp # C-ABI 인터페이스 단위 테스트
355
+ │ └── test_decoder.cpp # 디코더 단위 테스트
356
+ ├── pkg/
357
+ │ └── tcamviewer/ # Go 클라이언트 패키지 (CGO)
358
+ │ ├── tcamviewer.go
359
+ │ └── tcamviewer_test.go
360
+ ├── python/ # Python 클라이언트 및 ROS 2 노드
361
+ │ ├── tcamviewer/
362
+ │ │ ├── __init__.py
363
+ │ │ └── client.py # ctypes 기반 Python 바인딩
364
+ │ ├── ros2_node.py # ROS 2 Jazzy rclpy 노드
365
+ │ └── tests/
366
+ │ └── test_client.py # Python 단위 테스트
367
+ ├── ros2/ # ROS 2 C++ 네이티브 패키지 (colcon)
368
+ │ ├── CMakeLists.txt
369
+ │ ├── package.xml
370
+ │ └── src/
371
+ │ └── tcamviewer_node.cpp # rclcpp 기반 초저지연 노드
372
+ └── examples/
373
+ ├── go/
374
+ │ └── main.go # Go 클라이언트 데모
375
+ └── python/
376
+ └── demo.py # Python 클라이언트 데모
377
+ ```
378
+
379
+ ---
380
+
381
+ ## 🤝 기여하기 (Contributing) & 보안 정책 (Security)
382
+
383
+ - 프로젝트 기여 방법 및 개발 워크플로우는 [CONTRIBUTING.md](CONTRIBUTING.md)를 참고해 주세요.
384
+ - 향후 개발 계획 및 마일스톤은 [ROADMAP.md](ROADMAP.md)를 참고해 주세요.
385
+ - 보안 취약점 보고 및 정책에 관한 안내는 [SECURITY.md](SECURITY.md)를 참고해 주세요.
386
+
387
+ ---
388
+
389
+ ## 📄 라이선스 (License)
390
+
391
+ 본 프로젝트는 [Apache License 2.0](LICENSE) 라이선스 하에 배포됩니다.
392
+ 자유롭게 수정, 배포 및 상업적 이용이 가능합니다.