[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-81887":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":33,"readmeContent":34,"aiSummary":35,"trendingCount":15,"starSnapshotCount":15,"syncStatus":16,"lastSyncTime":36,"discoverSource":37},81887,"cvcl","kavishka-dot\u002Fcvcl","kavishka-dot","High-performance computer vision primitives in pure C99. Zero dependencies, pluggable allocator, SIMD-ready layout. Built for edge deployment and FFI.","",null,"C",45,8,3,0,2,44.06,"Other",false,"main",true,[23,24,25,26,27,28,29,30,31,32],"c","c99","computer-vision","edge-computing","embedded","high-performance","image-processing","library","signal-processing","simd","2026-06-12 04:01:35","# CVCL - Computer Vision C Library\n\n[![CI](https:\u002F\u002Fgithub.com\u002Fkavishka-dot\u002Fcvcl\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fkavishka-dot\u002Fcvcl\u002Factions\u002Fworkflows\u002Fci.yml)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-Apache%202.0-blue.svg)](LICENSE)\n[![C Standard](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FC-C99-green.svg)]()\n[![Platform](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fplatform-x86%20%7C%20ARM%20%7C%20RISC--V-lightgrey.svg)]()\n\nHigh-performance computer vision primitives in pure C99. Designed for edge deployment, deterministic memory control, and clean FFI consumption from Rust, Python, Go, and Zig.\n\n\n\n---\n\n## Design Philosophy\n\n**Zero hidden costs.** Every allocation goes through a caller-provided allocator. Every function returns an explicit error code. No global state, no exceptions, no RTTI.\n\n**Composable, not monolithic.** CVCL provides a kernel library of CV primitives, not a framework. It sits below OpenCV, not beside it.\n\n**SIMD-ready layout.** Row stride is always 64-byte aligned. This is not aesthetic, it means your AVX-512 \u002F NEON \u002F SVE inner loops never straddle a cache line boundary.\n\n---\n\n## Quick Start\n\n```c\n#include \u003Ccvcl\u002Fcvcl.h>\n\nint main(void) {\n    \u002F\u002F Load an image\n    cvcl_image_t img;\n    cvcl_io_read_ppm(&img, \"photo.ppm\", NULL);\n\n    \u002F\u002F Gaussian blur\n    cvcl_image_t blurred;\n    cvcl_image_create(&blurred, img.width, img.height,\n                      img.channels, CVCL_DEPTH_U8, NULL);\n    cvcl_blur_gaussian(&blurred, &img, 9, 2.0f, CVCL_BORDER_REPLICATE);\n\n    \u002F\u002F Save\n    cvcl_io_write_ppm(&blurred, \"out.ppm\");\n\n    \u002F\u002F Explicit cleanup\n    cvcl_image_free(&img,     NULL);\n    cvcl_image_free(&blurred, NULL);\n    return 0;\n}\n```\n\n---\n\n## Build\n\n### Requirements\n- CMake >= 3.16\n- C99 compiler (GCC, Clang, MSVC, IAR, ARMCC)\n- math library (`-lm`)\n\n### Standard build\n\n```bash\ncmake -B build -DCMAKE_BUILD_TYPE=Release\ncmake --build build\n```\n\n### With tests and sanitizers (development)\n\n```bash\ncmake -B build \\\n  -DCMAKE_BUILD_TYPE=Debug \\\n  -DCVCL_BUILD_TESTS=ON \\\n  -DCVCL_SANITIZE=ON\ncmake --build build\nctest --test-dir build --output-on-failure\n```\n\n### Cross-compile for ARM Cortex-A (bare-metal example)\n\n```bash\ncmake -B build-arm \\\n  -DCMAKE_TOOLCHAIN_FILE=cmake\u002Ftoolchain-arm-none-eabi.cmake \\\n  -DCVCL_NO_SIMD=OFF \\\n  -DCVCL_BUILD_TESTS=OFF\n```\n\n---\n\n## Core API\n\n### Image Descriptor\n\n```c\ntypedef struct {\n    uint8_t      *data;      \u002F\u002F Raw pixel buffer (64-byte aligned rows)\n    int32_t       width;\n    int32_t       height;\n    int32_t       channels;  \u002F\u002F 1=gray, 3=RGB, 4=RGBA\n    int32_t       stride;    \u002F\u002F Bytes per row (>= width*channels*depth)\n    cvcl_depth_t  depth;     \u002F\u002F U8, U16, or F32\n    cvcl_layout_t layout;    \u002F\u002F Interleaved or planar\n} cvcl_image_t;\n```\n\nThe `stride` field decouples logical width from memory layout. This enables:\n- Zero-copy crops and ROI views\n- Camera \u002F DMA buffer wrapping\n- SIMD alignment without padding the public dimensions\n\n### Custom Allocator\n\n```c\n\u002F\u002F Drop-in arena allocator example\nstatic uint8_t arena[1 \u003C\u003C 20];\nstatic size_t  arena_pos = 0;\n\nvoid *arena_alloc(size_t n, void *ctx) {\n    (void)ctx;\n    void *p = &arena[arena_pos];\n    arena_pos = CVCL_ALIGN_UP(arena_pos + n, 16);\n    return p;\n}\nvoid arena_free(void *p, void *ctx) { (void)p; (void)ctx; }\n\ncvcl_allocator_t my_alloc = { arena_alloc, arena_free, NULL };\n\n\u002F\u002F Use it everywhere\ncvcl_image_create(&img, 640, 480, 3, CVCL_DEPTH_U8, &my_alloc);\ncvcl_image_free(&img, &my_alloc);\n```\n\n### Zero-Copy Crop\n\n```c\ncvcl_rect_t roi = {100, 80, 320, 240};\ncvcl_image_t view;\ncvcl_crop(&view, &src, roi);\n\u002F\u002F view.data points into src.data — no allocation, no copy\n\u002F\u002F DO NOT call cvcl_image_free on view\n```\n\n---\n\n## Feature Matrix\n\n| Module       | Function                  | Status |\n|-------------|---------------------------|--------|\n| **Core**     | Image create\u002Ffree\u002Fclone    | Done   |\n|              | Zero-copy ROI view         | Done   |\n|              | Custom allocator interface | Done   |\n| **I\u002FO**      | PPM\u002FPGM read\u002Fwrite         | Done   |\n|              | In-memory PPM encode       | Done   |\n|              | PNG\u002FJPEG (via stb_image)   | Done    |\n| **Transform**| Nearest-neighbor resize    | Done   |\n|              | Bilinear resize (U8)       | Done   |\n|              | Bicubic resize             | Done    |\n|              | Flip H\u002FV                   | Done   |\n|              | Affine transform           | Done    |\n|              | Rotate 90\u002F180\u002F270          | Done    |\n|              | RGB\u002FGray channel convert   | Done   |\n| **Filter**   | Generic 2D convolution     | Done   |\n|              | Separable convolution      | Done   |\n|              | Box blur                   | Done   |\n|              | Gaussian blur              | Done   |\n|              | Median filter              | Done    |\n|              | Sobel X\u002FY                  | Done    |\n|              | Canny edges                | Done    |\n|              | Erode \u002F Dilate \u002F Open \u002F Close | Done    |\n| **Pixel**    | U8 \u002F U16 \u002F F32 accessors   | Done    |\n|              | Otsu threshold             | Done    |\n|              | Histogram equalization     | Done    |\n| **Draw**     | Lines, rects, circles      | Done    |\n|              | Bitmap text                | Done    |\n| **SIMD**     | AVX2 fast paths            | Done    |\n| **v2 Core**  | Integral image (SAT)       | Done    |\n|              | Connected components       | Done    |\n|              | O(1) box blur via SAT      | Done    |\n|              | NEON fast paths            | Done    |\n\n---\n\n## Error Handling\n\nAll functions return `cvcl_result_t`. Errors propagate explicitly:\n\n```c\ncvcl_result_t rc = cvcl_blur_gaussian(&dst, &src, 9, 2.0f, CVCL_BORDER_REPLICATE);\nif (rc != CVCL_OK) {\n    fprintf(stderr, \"Error: %s\\n\", cvcl_strerror(rc));\n}\n\n\u002F\u002F Or use the propagation macro inside library code:\nCVCL_CHECK(cvcl_image_create(&tmp, w, h, ch, depth, alloc));\n```\n\n---\n\n## Compile-Time Flags\n\n| Flag                  | Effect                                      |\n|-----------------------|---------------------------------------------|\n| `CVCL_NO_SIMD`        | Disable all SIMD intrinsics                 |\n| `CVCL_NO_STDLIB`      | Freestanding: disable stdlib includes       |\n| `CVCL_WITH_STB`       | Enable PNG\u002FJPEG I\u002FO via stb_image           |\n| `CVCL_ASSERT_DISABLE` | Strip all internal assertions               |\n\n---\n\n## FFI Usage\n\nCVCL is designed to be a clean FFI target. The C API is stable and has no C++-only constructs.\n\n**Rust (via bindgen):**\n```rust\n\u002F\u002F cvcl-sys generated bindings\nlet mut img = cvcl_image_t { ..Default::default() };\nunsafe { cvcl_image_create(&mut img, 640, 480, 3, CVCL_DEPTH_U8, std::ptr::null()); }\n```\n\n**Python (via ctypes):**\n```python\nlib = ctypes.CDLL(\"libcvcl.a\")\n# ... bind cvcl_image_create, cvcl_io_read_ppm, etc.\n```\n\n---\n\n## Project Structure\n\n```\ncvcl\u002F\n├── include\u002Fcvcl\u002F        # Public headers (install target)\n│   ├── cvcl.h           # Umbrella include\n│   ├── cvcl_types.h     # Fundamental types and platform macros\n│   ├── cvcl_image.h     # Image descriptor and lifecycle\n│   ├── cvcl_alloc.h     # Pluggable allocator interface\n│   ├── cvcl_error.h     # Error codes and CHECK macros\n│   ├── cvcl_io.h        # File I\u002FO\n│   ├── cvcl_transform.h # Resize, flip, crop, affine\n│   ├── cvcl_filter.h    # Convolution, blur, morphology\n│   ├── cvcl_draw.h      # Drawing primitives\n│   ├── cvcl_pixel.h     # Pixel accessors and histogram\n│   └── cvcl_version.h   # Version constants\n├── src\u002F\n│   ├── core\u002F            # alloc.c, error.c, image.c\n│   ├── io\u002F              # io_ppm.c\n│   ├── transform\u002F       # resize.c, affine.c\n│   └── filter\u002F          # blur.c, convolve.c, morph.c\n├── tests\u002F               # Self-contained C unit tests\n├── examples\u002F            # Demo programs\n├── bench\u002F               # Microbenchmarks\n├── cmake\u002F               # Package config helpers\n└── CMakeLists.txt\n```\n\n---\n\n\n## Performance (1920x1080 RGB, Release build, x86-64)\n\n| Operation | Throughput | Notes |\n|-----------|-----------|-------|\n| Gaussian blur k=5 | 47 Mpix\u002Fs | Fixed-point Q15 separable |\n| Gaussian blur k=31 | 12 Mpix\u002Fs | Grows with k (separable) |\n| Box blur k=5 | 169 Mpix\u002Fs | O(1) sliding window |\n| Box blur k=63 | 158 Mpix\u002Fs | Same cost as k=5 |\n| Pixel-wise add | 2924 Mpix\u002Fs | SSE2 saturating adds |\n| Erode\u002FDilate 5x5 | 157 Mpix\u002Fs | Monotonic deque O(n) |\n\nKey design wins:\n- Box blur k=63 costs the same as k=5 -- sliding window is O(w·h) regardless of kernel size\n- Gaussian uses fixed-point Q15 arithmetic -- no float multiply in the inner loop\n- Morphology uses monotonic deque -- O(w·h) vs O(w·h·k) separable naive\n\n---\n\n## Memory Safety\n\nCVCL includes constrained-memory tests using a fixed 64 KB arena allocator to verify graceful failure under limited memory.\n\nThe `test_resource_constraints` suite verifies:\n\n- Every allocation failure returns `CVCL_ERR_ALLOC` -- never a crash or undefined behavior\n- Zero-copy crop (`cvcl_image_view`) produces zero allocations\n- Cleanup after a failed `cvcl_image_create` is always safe\n- Mid-pipeline OOM leaves no dangling or partially-initialized state\n- The arena boundary is exact -- peak usage never exceeds the declared budget\n\nThis makes CVCL suitable for deployment on resource-constrained targets (RTOS, bare-metal Cortex-M) where heap exhaustion must be handled gracefully.\n\n---\n\n## Contributing\n\n1. Fork and branch from `main`\n2. Run tests: `ctest --test-dir build --output-on-failure`\n3. Ensure no new warnings with `-Wall -Wextra -Wpedantic -Werror`\n4. Add a test for any new function\n5. Open a PR with a clear description of what changed and why\n\n---\n\n## License\n\nApache License 2.0 - see [LICENSE](LICENSE).\n","CVCL是一个用纯C99编写的高性能计算机视觉库，专为边缘计算和跨语言调用设计。其核心功能包括零依赖、可插拔的内存分配器以及SIMD就绪的数据布局，确保了在x86、ARM和RISC-V等平台上高效的图像处理能力。通过提供一系列基础的计算机视觉原语而非一个完整的框架，CVCL旨在作为更高级别库如OpenCV的底层支持。它适用于需要直接控制资源使用且对性能有严格要求的场景，例如嵌入式系统或物联网设备中的实时图像分析任务。此外，该库还支持从Rust、Python、Go等多种语言中进行清晰简洁的外部函数接口（FFI）调用。","2026-06-11 04:07:05","CREATED_QUERY"]