temp_max = hist1[i];
}
}
//画直方图
CvPoint p1, p2;
double bin_width = (double)pic_hist->width / 4096;
double bin_unith = (double)pic_hist->height / temp_max;
for (i = 0; i < 4096; i++)
{
p1.x = i * bin_width;
p1.y = pic_hist->height;
p2.x = (i + 1)*bin_width;
p2.y = pic_hist->height - hist1[i] * bin_unith;
cvRectangle(pic_hist, p1, p2, cvScalar(0, 255, 0), -1, 8, 0);
}
cvSaveImage("hist1.jpg", pic_hist);
cvReleaseImage(&pic_hist);
}
void MeanShift_Tracking(IplImage *current)
{
int num = 0, i = 0, j = 0;
int t_w = 0, t_h = 0, t_x = 0, t_y = 0;
double *w = 0, *hist2 = 0;
double sum_w = 0, x1 = 0, x2 = 0, y1 = 2.0, y2 = 2.0;
int q_r, q_g, q_b;
int *q_temp;
IplImage *pic_hist = 0;
t_w = drawing_box.width;
t_h = drawing_box.height;
pic_hist = cvCreateImage(cvSize(300, 200), IPL_DEPTH_8U, 3);
hist2 = (double *)malloc(sizeof(double) * 4096);
w = (double *)malloc(sizeof(double) * 4096);
q_temp = (int *)malloc(sizeof(int)*t_w*t_h);
while ((pow(y2, 2) + pow(y1, 2) > 0.5) && (num < NUM))