Im trying to mimic the below code in lisp:
Code: Select all
#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
int main()
{
int bright=50;
cvNamedWindow("MyWindow");
//create trackbars
cvCreateTrackbar("brightness", "MyWindow", &bright, 100, NULL);
//load the original image
IplImage* img = cvLoadImage("C:/MyPic.jpg");
//create a blank image
IplImage* des = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,3);
while(1){
//change the brightness of the image
cvAddS(img, cvScalar(bright-50,bright-50,bright-50), des);
cvShowImage("MyWindow", des);
int c=cvWaitKey(40);
if(c==27){
//cleaning up
cvDestroyWindow("MyWindow");
cvReleaseImage(&img);
cvReleaseImage(&des);
break;
}
}
return 0;
}
cvCreateTrackbar("brightness", "MyWindow", &bright, 100, NULL);
is the "&bright" part .....I'm sure you can see what the &bright is supposed to ....its supposed to change the bright variable when the trackbar is moved and in my code a trackbar actually shows up in window but brightness of the image doesn't change as its supposed to when trackbar is moved.
i just could use help approximating the correct c opencv behavior in my lisp code.
here is my code so far...i know you can't run it but hopefully looking at it you can give me ideas...
Code: Select all
(defun create-trackbar-example (filename)
"Open the image FILENAME and show it in a window."
(let* ((image (load-image filename 1))
(img-size (get-size image))
(dest (create-image img-size +ipl-depth-8u+ 3))
(window-name "CREATE-TRACKBAR Example"))
(named-window window-name +window-normal+)
(do* ((bright (cffi:foreign-alloc :int :initial-element 50))
(scalar (make-cv-scalar (- (cffi:mem-ref bright :int) 50)
(- (cffi:mem-ref bright :int) 50)
(- (cffi:mem-ref bright :int) 50))))
((plusp (wait-key *millis-per-frame*)) nil)
(create-trackbar "brightness" window-name bright 100 (cffi:null-pointer))
(adds image scalar dest)
(move-window window-name 650 350)
(show-image window-name image))
(release-image image)
(destroy-window window-name)))
Code: Select all
;; int cvCreateTrackbar(const char* trackbar_name, const char* window_name, int* value, int count, CvTrackbarCallback
;; on_change=NULL )
(cffi:defcfun ("cvCreateTrackbar" %create-trackbar) :int
"Creates a trackbar and attaches it to the specified window."
(trackbar-name :string)
(window-name :string)
(value :pointer)
(count :int)
(on-change cv-trackbar-callback))
(defun create-trackbar (trackbar-name window-name value count &optional (on-change (cffi:null-pointer)))
(%create-trackbar trackbar-name window-name value count on-change))
cheerio =)