可以帮助将此代码转换为 ruby-openvc 吗?
原文 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;
}
翻译
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