Skip to content

Instantly share code, notes, and snippets.

View hkhojasteh's full-sized avatar
☁️
From the top of the clouds.

Hadi Abdi Khojasteh hkhojasteh

☁️
From the top of the clouds.
View GitHub Profile
Mat img_hlines = img_crop.clone();
//Standard Hough Line Transform
vector<Vec4i> lines; //will hold the results of the detection
HoughLinesP(detected_edges, lines, 1, CV_PI / 180, 50, 30, 10); //runs the actual detection
//Draw the lines
for (size_t i = 0; i < lines.size(); i++){
Vec4i l = lines[i];
line(img_hlines, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 255, 255), 2, CV_AA);
}
Mat detected_edges, img_mask;
int const max_lowThreshold = 255;
int lowThreshold = 210, ratio = 3, kernel_size = 3;
char* window_name = "Edge Map";
//CannyThreshold: Trackbar callback - Canny thresholds input with a ratio 1:3
void CannyThreshold(int, void*){
blur(img_mask, detected_edges, Size(3, 3)); //Reduce noise with a kernel 3x3
Canny(detected_edges, detected_edges, lowThreshold, lowThreshold * ratio, kernel_size); //Canny detector
imshow(window_name, detected_edges); //Using Canny's output as a mask, and display our result
}