Escolar Documentos
Profissional Documentos
Cultura Documentos
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/videoio/videoio.hpp>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// ==========================================Variabel Merah========================
//
Mat src; Mat src_hsv;
int thresh = 100;
int max_thresh = 255;
int h_min = 0, h_max = 220, s_min =37, s_max = 248, v_min = 37, v_max = 255,
conture = 100;
int s = 0;
char str[200];
// ==========================================Hijau======================== //
/*
int h_min2 = 30, h_max2 = 79, s_min2 = 42, s_max2 = 255, v_min2 = 44, v_max2 = 255,
conture2 = 100; */
while (1)
{
src = imread("apelmerah.jpg", CV_LOAD_IMAGE_GRAYSCALE);
// src = imread("apelhijau.jpg", 1);
namedWindow("Trackbar", CV_WINDOW_NORMAL);
createTrackbar("R1_MIN: ", "Trackbar", &h_min, 255);
createTrackbar("R1_MAX: ", "Trackbar", &h_max, 255);
createTrackbar("R2_MIN: ", "Trackbar", &s_min, 255);
createTrackbar("R2_MAX: ", "Trackbar", &s_max, 255);
createTrackbar("R3_MIN: ", "Trackbar", &v_min, 255);
createTrackbar("R3_MAX: ", "Trackbar", &v_max, 255);
createTrackbar("Conture: ", "Trackbar", &conture, 255);
createTrackbar(" Threshold:", "Trackbar", &thresh, max_thresh);
//cap.read(src);
Mat threshold_output, df;
vector<vector<Point> >hull(contours.size());
imshow("asli", src);
imshow("gray", src_hsv);
imshow("filter gray", threshold_output);
imshow("filter gray2", df);
// moveWindow("asli", 10, 400);
if (waitKey(30) == 27)break;
}
return 0;
}