To use single shot capture (slowly but safety).
;; To load escapi library.
(load-library)
;=> t
;; Check web camera devices.
(get-capture-device-name-list)
;=> ((0 . "TOSHIBA Web Camera - HD") (1 . "Logicool Webcam C930e"))
;; Single shot capture on device 0 (return vector of rgb image).
(single-capture 0)
;=> #(46 32 135 120 56 62 32 43 64 102 200 54 31 31 65 87 ...)
;; To save jpeg file (use cl-jpeg).
(ql:quickload :cl-jpeg)
(cl-jpeg:encode-image "foo.jpg" (single-capture 0) 3 480 640)
Customized use (unsafety but fast).
;; To load escapi library.
(load-library)
;=> t
;; Check web camera devices.
(get-capture-device-name-list)
;=> ((0 . "TOSHIBA Web Camera - HD") (1 . "Logicool Webcam C930e"))
;; Make instance of parameter's structure (height 480, width 640).
(defvar *param* (make-capture-parameter 480 640))
;; Init capture device.
(init-capture 0 *param*)
;=> t
;; Do capture.
(do-capture 0)
;=> t
;; Confirm whether capture is finish.
(wait-capture-done 0)
;=> DONE
;; Get buffer (default is vector of rgb image).
(get-buffer *param*)
;=> #(46 32 135 120 56 62 32 43 64 102 200 54 31 31 65 87 ...)
;; ;;
;; Do something! ;;
;; ;;
;; Close capture dvice.
(deinit-capture 0)
;=> t
;; Do free instance of parameter's structure.
(clear-capture-parameters *param*)
;=> t
-
Download `escapi.dll' and set Path your environment. (http://sol.gfxile.net/zip/escapi3.zip)
-
Clone to your local-projects.
cd $HOME/quicklisp/local-projects
git clone https://github.com/a-nano/cl-webcam.git
- Start your lisp. Then, jsut:
(ql:quickload :cl-webcam)
- If you are running lisp on msys, set the path of escapi.dll in the following way.
(push #P"path/to/your/downloaded/escapi.dll" cl-webcam:*foreign-library-directories*)
- To run test system.
(ql:quickload :prove)
(asdf:test-system :cl-webcam)
- Akihide Nano (an74abc@gmail.com)
Copyright (c) 2018 Akihide Nano (an74abc@gmail.com)
Licensed under the LLGPL License.