CvMat.load(source_image) classifier = CvHaarClassifierCascade.load(cascade_xml) # Draw red rectangle for each match classifier.detect_objects(image).each do |rect| image.rectangle! rect.top_left, rect.bottom_right, color: CvColor::Red end # Write resulting image to a new file image.save(output_file)