[racket] FFI & pointers

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Oct 31 10:23:23 EDT 2011

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)))



Posted on the users mailing list.