Can s.o help to translate this code to ruby-openvc?
Original
http://aishack.in/tutorials/tracking-colored-objects-in-opencv/
IplImage* GetThresholdedImage(IplImage* img)
{
#Convert the image into an HSV image
IplImage* imgHSV = cvCreateImage(cvGetSize(img), 8, 3);
cvCvtColor(img, imgHSV, CV_BGR2HSV);
#create a new image that will hold the threholded image (which will be returned).
IplImage* imgThreshed = cvCreateImage(cvGetSize(img), 8, 1);
#Now we do the actual thresholding:
cvInRangeS(imgHSV, cvScalar(20, 100, 100), cvScalar(30, 255, 255), imgThreshed)
cvReleaseImage(&imgHSV);
return imgThreshed;
}
Translated
def getThresholdedImage2 (img)
#blur the source image to reduce color noise
img = img.smooth(CV_GAUSSIAN, 7, 7)
#convert the image to hsv(Hue, Saturation, Value) so its
#easier to determine the color to track(hue) imgHSV = IplImage.new(img.width, img.height, 8, 3);
imgHSV = img.BGR2HSV
#create a new image that will hold the threholded image (which will be returned).
imgThreshed = IplImage.new(img.width, img.height, 8, 1);
#Now we do the actual thresholding:
imgThreshed = imgHSV.in_range(CvScalar.new(20, 100, 100), CvScalar.new(30, 255, 255));
return imgThreshed
end
Actally, I don’t know ruby at all but it seems that I found solution to your problem. Ruby-OpenCV seems to be just a library-wrapper.
For example, if you want to find analogue of
cvInRangeSfunction you should do the following.By searching in source files I found ext/opencv/cvmat.h with this content:
And in the cpp file there’s description:
So you should find all needed ruby functions by this way. Good luck!