I calculated normalizehistogram for an old version. And GaussianBlur does not help for circles detection, thats why Size(1,1). My actual code is
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include
#include <math.h>
#include “opencv2/video/background_segm.hpp”
#include “opencv2/video/tracking.hpp”
#include “opencv\cv.hpp”
#include <Windows.h>
#include
using namespace std;
using namespace cv;
int main(int argc, const char** argv) {
VideoCapture video(“burgos.avi”);
//Mat image = imread(“via.jpg”);
if (!video.isOpened()) {
cout << “Error” << endl;
return(0);
}
Mat image0;
char Esq = 0;
int fps = 0;
while (Esq != 27 && video.isOpened()) { // hasta que pulse Esq o el video se acabe
bool nextframe = video.read(image0);
fps = fps + 1;
Mat image;
resize(image0, image, Size(720, 420));
String text = format("Frame %d", fps);
int base = 0;
Size size = getTextSize(text, FONT_HERSHEY_PLAIN, 1.0, 1, &base);
putText(image, text, Point(10, size.height + 10), FONT_HERSHEY_PLAIN, 1.0, Scalar(255, 255, 255), 1, LINE_AA);
float slidingrows = image.rows; // quiero colocar esto fuera del while, pero si lo hago me da error
float slidingcolumns = (image.cols / 2);
int Round(float n);
//cout << n << endl;
int Round(float slidingrows);
//cout << slidingrows << endl;
int Round(float slidincolumns);
//cout << slidingcolumns << endl;
int Round(float step);
//cout << step << endl;
//cout << image0.rows << endl;
Mat sliding = image.clone();
Mat SWimage = image.clone();
Mat grayimage;
cvtColor(sliding, grayimage, CV_BGR2GRAY);
Rect ventana(slidingcolumns, 0, slidingcolumns, slidingrows);
rectangle(grayimage, ventana, (255, 255, 255), 1, 8, 0);
rectangle(SWimage, ventana, (0, 0, 0), 1, 8, 0);
//imshow("Step by Step", sliding);
Mat region = image(ventana);
//imshow("Region de interés", region);
int filas = (slidingrows);
//int Round(float filas);
//rectangle(sliding, ventana2, (0, 0, 255), 1, 8, 0);
Mat region2 = grayimage(ventana);
//imshow("Region de interés", region2);
//GaussianBlur(grayimage(ventana), region2, Size(3, 3), 0);// Efecto Blur
int tamaño = 256;
float rango[] = { 0,256 };
const float* rangos[] = { rango };
//threshold(region2, region2, mediana(normalizehistogram), 255, ADAPTIVE_THRESH_MEAN_C);
GaussianBlur(region2, region2, Size(1, 1), 0);
vector<Vec3f> v3fCircles;
HoughCircles(region2, v3fCircles, CV_HOUGH_GRADIENT, 2, region2.rows/8, 75, 50, 40, 45);
for (int i = 0; i < v3fCircles.size(); i++) {
circle(region2,
Point(v3fCircles[i][0], v3fCircles[i][1]),
v3fCircles[i][2],
Scalar(255, 255, 0),
2);
}
imshow("BYN", grayimage);
//imshow("Bordes", region2);
//imshow("Result", SWimage);
//imshow("LBP", lbpImage);
waitKey(0);
}
Esq = waitKey(1);
destroyAllWindows;
}