This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

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

1 post · 2694 views

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,