Commit 72b18292 authored by wanghailong's avatar wanghailong

change params

parent 0257daa9
......@@ -54,7 +54,7 @@ void CBM_model::Initialize()
//_writer6.open("long.avi",cv::VideoWriter::fourcc('X','V','I','D'),30,cv::Size(new_width,new_height),0);
//_writer7.open("short.avi",cv::VideoWriter::fourcc('X','V','I','D'),30,cv::Size(new_width,new_height),0);
//_writer8.open("static.avi",cv::VideoWriter::fourcc('X','V','I','D'),30,cv::Size(new_width,new_height),1);
_writer10.open("DPM.avi",cv::VideoWriter::fourcc('X','V','I','D'),30,cv::Size(new_width,new_height),1);
//_writer10.open("DPM.avi",cv::VideoWriter::fourcc('X','V','I','D'),30,cv::Size(new_width,new_height),1);
mog_fg = cv::Mat::zeros(cv::Size(new_width, new_height), CV_8UC1);
......@@ -109,7 +109,7 @@ void CBM_model::Uninitialize()
//_writer6.release();
//_writer7.release();
//_writer8.release();
_writer10.release();
//_writer10.release();
#endif
// cvReleaseImage(&mog_fg);
......@@ -136,7 +136,7 @@ void CBM_model::Uninitialize()
void CBM_model::System_Reset()
{
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < new_width; i++){
for (int j = 0; j < new_height; j++){
imageFSM[i][j].state_now = 0;
......@@ -154,7 +154,7 @@ bool CBM_model::Motion_Detection(myImage *img)
if( frame_count < MOG_LEARN_FRAMES){
#ifdef DEBUG
//printf("update mog %d\n",MOG_LEARN_FRAMES-frame_count);
printf("update mog %d\n",MOG_LEARN_FRAMES-frame_count);
#endif
if (frame_count==0){
......@@ -293,13 +293,17 @@ int CBM_model::GetLabeling2( myImage *pImg1, int areaThreshold, int option)
// temp->pixelData[i + pImg1->width*pImg1->height*2] = out[i]*20;
// }
bool constant_template[256]={false};
bool constant_template[2474]={false}; //change 256->448
vector<int> color_labels;
color_labels.clear();
for (int i = 0; i < pImg1->width*pImg1->height; i++){
// if(out[i] > 2473){
// std::cout << "error number : " << out[i] <<std::endl;
// continue;
// }
constant_template[out[i]] = true;
}
for (int i = 0; i < 256; i++){
for (int i = 0; i < 2474; i++){
if (constant_template[i]==true){
found_objnum++;
color_labels.push_back(i);
......@@ -573,7 +577,7 @@ bool ** CBM_model::GetPrevious_nForeground( int n)
void CBM_model::myFSM(myImage *short_term, myImage *long_term, pixelFSM ** imageFSM, bool *** Previous_FG)
{
myColor buffer[2];
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < new_width; i++){
for (int j = 0; j < new_height; j++){
buffer[0] = myGet2D(short_term,i,j);
......@@ -626,7 +630,7 @@ void CBM_model::myFSM(myImage *short_term, myImage *long_term, pixelFSM ** image
void CBM_model::myConvert2Img(bool **Array, myImage *output)
{
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < new_width; i++){
for (int j = 0; j < new_height; j++){
if ( Array[i][j] == true ){
......@@ -646,7 +650,7 @@ void CBM_model::myConvertFSM2Img(pixelFSM **Array, myImage *Candidate_Fg, myImag
myColor color1, color2;
color1.B = 0; color1.G = 0; color1.R = 255;
color2.B = 0; color2.G = 200; color2.R = 255;
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < new_width; i++){
for (int j = 0; j < new_height; j++){
if ( Array[i][j].staticFG_candidate == true )
......
......@@ -29,7 +29,7 @@ double INPUT_RESIZE;
bool DetectAnomaly::detectAnomaly(cv::Mat img, vector<vector<int>>* resultLocation)
{
yolo_test = img.clone();
cv::resize(img, img,cv::Size(2448*0.25, 2048*0.25), cv::INTER_CUBIC);
cv::resize(img, img,cv::Size(2688*0.25, 1520*0.25), cv::INTER_CUBIC);
img.copyTo(myimg);
medianBlur(mat_myimg, mat_myimg, 3);
opencv_2_myImage(myimg, myimg1); //transfer opencv data to myimage data
......@@ -83,14 +83,14 @@ DetectAnomaly::DetectAnomaly()
// // INPUT_RESIZE = 0.25;
cfgAnomaly.input_resize = 0.25;
cfgAnomaly.owner_search_roi = 10;
cfgAnomaly.gmm_learn_frame = 100;
cfgAnomaly.gmm_learn_frame = 1000;
cfgAnomaly.max_sfg = 15625;
cfgAnomaly.min_sfg = 50;
cfgAnomaly.max_fg = 75000;
cfgAnomaly.min_fg = 100;
cfgAnomaly.buffer_length = 100;
cfgAnomaly.image_height = 2048 * cfgAnomaly.input_resize;
cfgAnomaly.image_width = 2448 * cfgAnomaly.input_resize;
cfgAnomaly.buffer_length = 300;
cfgAnomaly.image_height = 1520 * cfgAnomaly.input_resize;
cfgAnomaly.image_width = 2688 * cfgAnomaly.input_resize;
cfgAnomaly.gmm_long_learn_rate = 0.0001;
cfgAnomaly.gmm_short_learn_rate = 0.002;
......@@ -99,24 +99,24 @@ DetectAnomaly::DetectAnomaly()
// set gloabl var
INPUT_RESIZE = 1.0;
OWNER_SEARCH_ROI = 10;
GMM_LEARN_FRAME = 100; //frame number for GMM initialization
GMM_LEARN_FRAME = 1000; //frame number for GMM initialization
MAX_SFG = 15625;
MIN_SFG = 50;
MAX_FG = 75000;
MIN_FG = 100;
BUFFER_LENGTH = 100;
BUFFER_LENGTH = 300;
GMM_LONG_LEARN_RATE = 0.0001;
GMM_SHORT_LEARN_RATE = 0.002;
// INPUT_RESIZE = 0.25;
cfgAnomaly.top_left_x = 1080 * cfgAnomaly.input_resize;
cfgAnomaly.top_left_y = 540 * cfgAnomaly.input_resize;
cfgAnomaly.top_right_x = 1680 * cfgAnomaly.input_resize;
cfgAnomaly.top_right_y = 820 * cfgAnomaly.input_resize;
cfgAnomaly.bottom_left_x = 847 * cfgAnomaly.input_resize;
cfgAnomaly.bottom_left_y = 1015 * cfgAnomaly.input_resize;
cfgAnomaly.bottom_right_x = 1489 * cfgAnomaly.input_resize;
cfgAnomaly.bottom_right_y = 1255 * cfgAnomaly.input_resize;
cfgAnomaly.top_left_x = 759 * cfgAnomaly.input_resize;
cfgAnomaly.top_left_y = 785 * cfgAnomaly.input_resize;
cfgAnomaly.top_right_x = 1581 * cfgAnomaly.input_resize;
cfgAnomaly.top_right_y = 771 * cfgAnomaly.input_resize;
cfgAnomaly.bottom_left_x = 73 * cfgAnomaly.input_resize;
cfgAnomaly.bottom_left_y = 1489 * cfgAnomaly.input_resize;
cfgAnomaly.bottom_right_x = 2376 * cfgAnomaly.input_resize;
cfgAnomaly.bottom_right_y = 1411 * cfgAnomaly.input_resize;
obj_left = false;
arr[0] = 4;
......@@ -148,7 +148,7 @@ DetectAnomaly::DetectAnomaly()
opencv_2_myImage(mask, mymask);
#ifdef DEBUG
//cv::imwrite("mask.jpg", Image1);
cv::imwrite("mask.jpg", Image1);
cv::waitKey(1);
//cvReleaseImage(&Image1);
#endif
......@@ -210,10 +210,15 @@ DetectAnomaly::DetectAnomaly(config cfg) : cfgAnomaly(cfg)
// PointArray[0][1] = cv::Point(1009, 625);
// PointArray[1][1] = cv::Point(9, 859);
// PointArray[1][0] = cv::Point(1427, 1069);
PointArray[0][0] = cv::Point(1080, 540);
PointArray[0][1] = cv::Point(1680, 820);
PointArray[1][1] = cv::Point(847, 1015);
PointArray[1][0] = cv::Point(1489, 1255);
// PointArray[0][0] = cv::Point(1080, 540);
// PointArray[0][1] = cv::Point(1680, 820);
// PointArray[1][1] = cv::Point(847, 1015);
// PointArray[1][0] = cv::Point(1489, 1255);
PointArray[0][0] = cv::Point(759, 785);
PointArray[0][1] = cv::Point(1581, 771);
PointArray[1][1] = cv::Point(73, 1489);
PointArray[1][0] = cv::Point(2375, 1411);
const Point* ppt[2] = {PointArray[0], PointArray[1]};
......@@ -226,7 +231,7 @@ DetectAnomaly::DetectAnomaly(config cfg) : cfgAnomaly(cfg)
opencv_2_myImage(mask, mymask);
#ifdef DEBUG
cv::imwrite("mask.jpg", Image1);
//cv::imwrite("mask.jpg", Image1);
cv::waitKey(1);
//cvReleaseImage(&Image1);
#endif
......
......@@ -208,7 +208,7 @@ bool ObjLeftDetect::soft_validation3( myImage * ImgSynopsis, vector<Obj_info*> o
/************************************************************************/
foreground = _CBM_model->GetPrevious_nForeground(retreval_time-1);//the moment the bag dropped (need to check!!)
bool foreground_found = false;
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int j = 0; j < new_width; j++)
{
for (int k = 0; k < new_height; k++)
......@@ -281,7 +281,7 @@ bool ObjLeftDetect::soft_validation3( myImage * ImgSynopsis, vector<Obj_info*> o
cv::Mat img = cv::Mat(cv::Size(new_width,new_height),CV_8UC3);
cv::Mat fg = cv::Mat(cv::Size(new_width,new_height),CV_8UC1);
foreground = _CBM_model->GetPrevious_nForeground(i);
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int j = 0; j < new_width; j++)
{
for (int k = 0; k < new_height; k++)
......
......@@ -5,6 +5,7 @@
#include <iostream>
#include "yolov3/extra/api.hpp"
#include <sys/time.h>
using namespace std;
......@@ -41,7 +42,7 @@ int main()
int count = 0;
// char test_video[200] = "zhao.mp4";
char test_video[200] = "../test_video/temp-12252020164103.avi";
char test_video[200] = "../test_video/out.avi";
VideoDetails *_video;
_video = new VideoDetails(test_video);
//VideoCapture capture;
......@@ -64,7 +65,17 @@ int main()
// cvResize(src_img,des_img,CV_INTER_LINEAR);
vector<vector<int>> resultLocation;
obj_left = detect.detectAnomaly(qImg.clone(),&resultLocation);
//calculate time
struct timeval start, end;
float time = 0;
gettimeofday(&start, NULL);
obj_left = detect.detectAnomaly(qImg,&resultLocation);
gettimeofday(&end, NULL);
time = (1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec) /
(1000.0);
cout << "total time = " << time << "ms" << endl;
//yolo_infer
......
......@@ -78,7 +78,7 @@ void myImageAND(myImage * input1, myImage * input2, myImage * output)
int height = input1->height;
int depth = input1->depth;
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for(int i = 0; i < height; i++)
{
for(int j = 0; j < width; j++)
......@@ -110,7 +110,7 @@ void myRGB2Gray(myImage * input, myImage * output)
if(output->depth == 1)
{
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){
output->pixelData[(j + i*width)] = (input->pixelData[(j + i*width)]*0.3) + (input->pixelData[(j + i*width) + (width*height*1)]*0.3) + (input->pixelData[(j + i*width) + (width*height*2)]*0.3);
......@@ -119,7 +119,7 @@ void myRGB2Gray(myImage * input, myImage * output)
}
else
{
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){
output->pixelData[(j + i*width)] = (input->pixelData[(j + i*width)]*0.3) + (input->pixelData[(j + i*width) + (width*height*1)]*0.3) + (input->pixelData[(j + i*width) + (width*height*2)]*0.3);
......@@ -145,7 +145,7 @@ void myBinary(myImage * input, myImage * output, int threshold)
if(output->depth == 1)
{
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){
if(input->pixelData[(j + i*width)] > threshold)
......@@ -161,7 +161,7 @@ void myBinary(myImage * input, myImage * output, int threshold)
}
else
{
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){
if(input->pixelData[(j + i*width)] > threshold)
......@@ -196,7 +196,7 @@ void myInverse(myImage * input, myImage * output)
if(input->depth == 1)
{
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){
if(input->pixelData[(j + i*width)] == 255)
......@@ -212,7 +212,7 @@ void myInverse(myImage * input, myImage * output)
}
else
{
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){
if(input->pixelData[(j + i*width)] == 255)
......@@ -246,7 +246,7 @@ void myImageCopy(myImage * input, myImage * output)
int height = input->height;
int depth = input->depth;
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < width*height*depth; i++)
output->pixelData[i] = input->pixelData[i];
......@@ -258,7 +258,7 @@ void myImageZero(myImage * input)
int height = input->height;
int depth = input->depth;
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < width*height*depth; i++)
input->pixelData[i] = 0;
}
......@@ -321,7 +321,7 @@ void opencv_2_myImage(cv::Mat input, myImage * output)
int height = input.rows;
int depth = input.channels();
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < width; i++){
for (int j = 0; j < height; j++){
for (int k = 0; k < depth; k++){
......@@ -361,7 +361,7 @@ void myImage_2_opencv(myImage * input, cv::Mat output)
// }
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < width; i++){
for (int j = 0; j < height; j++){
for (int k = 0; k < depth; k++){
......@@ -388,7 +388,7 @@ void myResize(myImage * input, myImage * output)
system("pause");
}
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < output->height; i++){
for (int j = 0; j < output->width; j++){
//myColor colors = myGet2D(input,i*scale1,j*scale1);
......@@ -474,7 +474,7 @@ int myCountNonZero(myImage * input)
int height = input->height;
int counter = 0;
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){
if (input->pixelData[(j + i*input->width)] != 0){
......@@ -499,7 +499,7 @@ void myAbsDiff(myImage * input1, myImage * input2, myImage * output)
int height = input1->height;
int depth = input1->depth;
int temp;
#pragma omp parallel for
#pragma omp parallel for num_threads(12)
for (int i = 0; i < width*height*depth; i++){
temp = input1->pixelData[i] - input2->pixelData[i];
output->pixelData[i] = abs(temp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment