how do i convert this c code block into lisp/cffi

Discussion of Common Lisp
Post Reply
joeish80829
Posts: 153
Joined: Tue Sep 03, 2013 5:32 am

how do i convert this c code block into lisp/cffi

Post by joeish80829 » Thu Oct 24, 2013 6:38 pm

CvHistogram* hist;
{
int hist_size[] = { h_bins, s_bins };
float h_ranges[] = { 0, 180 };
float s_ranges[] = { 0, 255 };
float* ranges[] = { h_ranges, s_ranges };
hist = cvCreateHist( 2, hist_size, CV_HIST_ARRAY, ranges, 1 );
}

and here is my attempt

(setf hist (let* ((hist-size (cffi:foreign-alloc :int :initial-contents
(list h-bins s-bins)))
(h-ranges (cffi:foreign-alloc :float :initial-contents '(0.0 180.0)))
(s-ranges (cffi:foreign-alloc :float :initial-contents '(0.0 255.0)))
(ranges (cffi:foreign-alloc :initial-contents
(list h-ranges s-ranges))))
(create-hist 2 hist-size +hist-array+ ranges 1)))

cvCreateHist info is here



Im getting this error in inferior lisp....i got it to move out of lisp but it gets stuck in c. The rest of the program seems negligible so didnt post....this block i attempted to convert gets error...I tried only a few ways to write these array declarations because this is ALWAYS how i successfully do array declarations...I would be grateful for guidance and any extra info i can provide i will

OpenCV Error: Unknown error code -19 (Number of dimensions is out of range) in cvCreateHist,

Post Reply