[racket] FFI & pointers
At Sat, 29 Oct 2011 14:32:42 +0400, Aleksei Pastutsan wrote:
> I try to use computer vision library with racket.
>
> ;; API
> (define libhighgui (ffi-lib "libhighgui" '("2.1" "4")))
> (define-cpointer-type _cv-capture)
>
> ;; /* start capturing frames from camera: index = camera_index +
> domain_offset (CV_CAP_*) */
> ;; CVAPI(CvCapture*) cvCreateCameraCapture( int index );
> (define cvCreateCameraCapture
> (get-ffi-obj "cvCreateCameraCapture" libhighgui (_fun _int -> (_or-null
> _cv-capture))))
>
> ;; /* stop capturing/reading and free resources */
> ;; CVAPI(void) cvReleaseCapture( CvCapture** capture );
> (define cvReleaseCapture
> (get-ffi-obj "cvReleaseCapture" libhighgui (_fun _pointer -> _void)))
>
> ;;application
> (define capture (cvCreateCameraCapture 0)
>
> How I can release the capture (how to emulate CvCapture** for
> cvReleaseCapture)?
(define cvReleaseCapture
(get-ffi-obj "cvReleaseCapture" libhighgui
(_fun (_ptr i _cv-capture) -> _void)))