{"id":18950109,"url":"https://github.com/junker/opencv-jit","last_synced_at":"2026-04-27T22:00:56.756Z","repository":{"id":250587735,"uuid":"834865539","full_name":"Junker/opencv-jit","owner":"Junker","description":"OpenCV 4.x bindings for Common Lisp","archived":false,"fork":false,"pushed_at":"2025-05-15T15:43:15.000Z","size":124,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-05T13:51:27.783Z","etag":null,"topics":["common-lisp","dnn","opencv"],"latest_commit_sha":null,"homepage":"","language":"Common Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Junker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-28T15:45:07.000Z","updated_at":"2025-06-06T19:20:09.000Z","dependencies_parsed_at":"2024-09-13T23:32:42.373Z","dependency_job_id":"e0e52af5-ea19-43e7-b213-e316a02206d3","html_url":"https://github.com/Junker/opencv-jit","commit_stats":null,"previous_names":["junker/opencv-jit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Junker/opencv-jit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2Fopencv-jit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2Fopencv-jit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2Fopencv-jit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2Fopencv-jit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Junker","download_url":"https://codeload.github.com/Junker/opencv-jit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Junker%2Fopencv-jit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32356602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["common-lisp","dnn","opencv"],"created_at":"2024-11-08T13:21:00.468Z","updated_at":"2026-04-27T22:00:56.751Z","avatar_url":"https://github.com/Junker.png","language":"Common Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenCV-JIT\n\nOpenCV 4.x bindings for Common Lisp.\n\nOpenCV-JIT uses [CXXynergy](https://github.com/Junker/cxxynergy) system\nwhich compiles C++ bindings on system load, providing JIT compilation of C++\ncode at load time instead of pre-compiled FFI bindings.\n\n## Requirements\n\n- Installed [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)\n- Installed GCC (g++)\n- Installed OpenCV 4.5+ (with development files)\n\n## Installation\n\nClone the repository and load with Quicklisp:\n\n```common-lisp\n(ql:quickload :opencv-jit)\n```\n\n## API Overview\n\n### Core Classes\n\n#### MAT - Matrix/Image representation\n\n```common-lisp\n;; Create empty matrix\n(make-mat)\n\n;; Create matrix with size and type\n(make-mat-with-size 100 100 :8UC3)  ; 100x100 3-channel BGR\n\n;; Create from file\n(imread #p\"/path/to/image.png\")\n(imread #p\"/path/to/image.png\" :GRAYSCALE)\n\n;; Decode from octets\n(imdecode #(137 80 78 71 ...) :COLOR)\n\n;; Save to file\n(imwrite #p\"/tmp/output.jpg\" mat :JPEG-QUALITY 95)\n```\n\n#### SIZE - Size/Dimensions\n\n```common-lisp\n(make-size 640 480)\n(size-width s)  ; =\u003e 640\n(size-height s) ; =\u003e 480\n```\n\n#### SCALAR - Multi-value (up to 4 channels)\n\n```common-lisp\n(make-scalar 255 0 0)  ; Blue for BGR image\n(make-scalar 104 177 123)  ; Mean values for DNN\n(scalar-val s 0)  ; Get first value\n```\n\n#### POINT - 2D Point\n\n```common-lisp\n(make-point 10 20)\n(point-x p)  ; =\u003e 10\n(point-y p)  ; =\u003e 20\n```\n\n#### RECT - Rectangle\n\n```common-lisp\n(make-rect 10 20 100 50)  ; x y width height\n(rect-x r)      ; =\u003e 10\n(rect-y r)      ; =\u003e 20\n(rect-width r)  ; =\u003e 100\n(rect-height r) ; =\u003e 50\n```\n\n### Image Processing\n\n```common-lisp\n;; Color conversion\n(cvt-color img :BGR2GRAY)     ; BGR to grayscale\n(cvt-color img :BGR2HSV)      ; BGR to HSV\n\n;; Resize\n(resize img (make-size 300 300))\n(resize img (make-size 100 100) :interpolation :CUBIC)\n```\n\n### HighGUI - Window Management\n\n```common-lisp\n;; Create and show\n(named-window \"Preview\")\n(imshow \"Preview\" mat)\n(waitkey 0)  ; Wait for key press\n\n;; Window management\n(destroy-window \"Preview\")\n(move-window \"Preview\" 100 100)\n(resize-window \"Preview\" 640 480)\n(set-window-title \"Preview\" \"My Image\")\n```\n\n### DNN - Deep Neural Networks\n\n```common-lisp\n;; Load network from different formats\n(read-net-from-caffe \"deploy.prototxt\" \"model.caffemodel\")\n(read-net-from-onnx \"model.onnx\")\n(read-net-from-tensorflow \"model.pb\" \"\")\n(read-net-from-darknet \"model.cfg\" \"model.weights\")\n\n;; Prepare input blob\n(let* ((net (read-net-from-caffe \"deploy.prototxt\" \"model.caffemodel\"))\n       (img (imread \"image.jpg\"))\n       (blob (blob-from-image img\n                              :size (make-size 300 300)\n                              :mean (make-scalar 104 177 123)\n                              :scale-factor 1.0)))\n  ;; Run inference\n  (net-set-input net blob)\n  (let ((output (net-forward net)))\n    ;; Process output\n    ))\n```\n\n### Face Detection (YuNet)\n\n```common-lisp\n;; Create face detector\n(let* ((detector (make-face-detector-yn\n                   \"face_detection_yunet.onnx\"\n                   \"\"\n                   (make-size 640 480)\n                   :score-threshold 0.9))\n       (img (imread \"photo.jpg\"))\n       (faces (face-detector-yn-detect detector img)))\n  ;; faces is a MAT where each row is one face:\n  ;; [x, y, w, h, x_re, y_re, x_le, y_le, x_nt, y_nt, x_rcm, y_rcm, x_lcm, y_lcm, score]\n  )\n```\n\n### MAT Access Methods\n\n```common-lisp\n;; Get element at position\n(mat-at mat 10 20)  ; For 2D single-channel, returns value\n(mat-at mat 10 20)  ; For 2D multi-channel, returns VEC\n\n;; VEC operations for multi-channel\n(let ((v (mat-at mat 10 20)))\n  (vec-val v 0)        ; First channel (Blue for BGR)\n  (vec-val v 1)        ; Second channel (Green for BGR)\n  (vec-to-list v)      ; =\u003e (B G R)\n  (vec-to-vector v))   ; =\u003e #(B G R)\n\n;; Matrix properties\n(mat-rows mat)         ; Number of rows\n(mat-cols mat)         ; Number of columns\n(mat-channels mat)     ; Number of channels\n(mat-depth mat)        ; Depth type (:8U, :32F, etc.)\n(mat-type mat)         ; Full type (:8UC3, :32FC1, etc.)\n(mat-dims mat)         ; Number of dimensions\n(mat-total mat)        ; Total elements\n(mat-size mat)         ; SIZE object\n(mat-empty-p mat)      ; Check if empty\n\n;; Convert to Lisp array (single-channel only)\n(mat-to-array mat)\n(mat-data mat)\n```\n\n## Example: Face Detection with DNN\n\n```common-lisp\n(defpackage ocv\n  (:use #:cl\n        #:opencv-jit\n        #:opencv-jit/dnn))\n(in-package :ocv)\n\n(defvar *model-text* \"/path/to/deploy.prototxt\")\n(defvar *model-bin* \"/path/to/res10_300x300_ssd_iter_140000.caffemodel\")\n(defvar *net* (read-net-from-caffe *model-text* *model-bin*))\n\n(defun load-from-file (path)\n  (check-type path (or pathname string))\n  (if (not (uiop:file-exists-p path))\n      (error \"file ~S doesn't exists\" path)\n      (imread path :COLOR)))\n\n(defun get-face-confidences (cvimg)\n  (let* ((net-mean (make-scalar 104 177 123))\n         (net-size (make-size 300 300))\n         (blob (blob-from-image (resize cvimg net-size)\n                                :size net-size\n                                :mean net-mean)))\n    (net-set-input *net* blob)\n    (let ((prob (net-forward *net* \"\")))\n      (loop :for i :from 0 :below (mat-axis-length prob 2)\n            :for confidence := (mat-at prob 0 0 i 2)\n            :when (\u003e confidence 0.7)\n              :collect confidence))))\n```\n\n## Available Color Conversion Codes\n\nCommon codes for `cvt-color`:\n\n- `:BGR2GRAY` - BGR to grayscale\n- `:GRAY2BGR` - Grayscale to BGR\n- `:BGR2HSV` - BGR to HSV\n- `:HSV2BGR` - HSV to BGR\n- `:BGR2RGB` - Swap B and R channels\n- `:RGB2BGR` - Swap R and B channels\n\n## Available Interpolation Methods\n\nFor `resize`:\n\n- `:NEAREST` - Nearest neighbor interpolation\n- `:LINEAR` - Bilinear interpolation (default)\n- `:CUBIC` - Bicubic interpolation\n- `:AREA` - Resampling using pixel area relation\n- `:LANCZOS4` - Lanczos interpolation over 8x8 neighborhood\n\n## MAT Types\n\nMatrix element types:\n\n- `:8UC1`, `:8UC2`, `:8UC3`, `:8UC4` - 8-bit unsigned (uchar)\n- `:8SC1`, `:8SC2`, `:8SC3`, `:8SC4` - 8-bit signed (schar)\n- `:16UC1`, `:16UC2`, `:16UC3`, `:16UC4` - 16-bit unsigned (ushort)\n- `:16SC1`, `:16SC2`, `:16SC3`, `:16SC4` - 16-bit signed (short)\n- `:32SC1`, `:32SC2`, `:32SC3`, `:32SC4` - 32-bit signed (int)\n- `:32FC1`, `:32FC2`, `:32FC3`, `:32FC4` - 32-bit float\n- `:64FC1`, `:64FC2`, `:64FC3`, `:64FC4` - 64-bit double\n\n## Warning\n\nThis software is in active development. The APIs may change.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunker%2Fopencv-jit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunker%2Fopencv-jit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunker%2Fopencv-jit/lists"}