Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
datang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaoyunfei
datang
Commits
e1126306
Commit
e1126306
authored
Mar 01, 2021
by
wanghailong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决初始化失败的问题
parent
26243a88
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
72 additions
and
71 deletions
+72
-71
CBM_model.cpp
CBM_model.cpp
+6
-6
CBM_model.h
CBM_model.h
+4
-4
CMakeLists.txt
CMakeLists.txt
+1
-1
DetectAnomaly.cpp
DetectAnomaly.cpp
+23
-21
DetectAnomaly.h
DetectAnomaly.h
+3
-4
ObjLeftDetect.cpp
ObjLeftDetect.cpp
+0
-0
ObjLeftDetect.h
ObjLeftDetect.h
+6
-6
main.cpp
main.cpp
+28
-28
CMakeLists.txt
yolov3/CMakeLists.txt
+1
-1
No files found.
CBM_model.cpp
View file @
e1126306
...
...
@@ -57,9 +57,9 @@ void CBM_model::Initialize()
// _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
);
mog_fg2
=
cv
::
Mat
::
zeros
(
cv
::
Size
(
new_width
,
new_height
),
CV_8UC1
);
imgStatic
=
cv
::
Mat
::
zeros
(
cv
::
Size
(
new_width
,
new_height
),
CV_8UC3
);
//
mog_fg = cv::Mat::zeros(cv::Size(new_width, new_height), CV_8UC1);
//
mog_fg2 = cv::Mat::zeros(cv::Size(new_width, new_height), CV_8UC1);
//
imgStatic = cv::Mat::zeros(cv::Size(new_width, new_height), CV_8UC3);
my_mog_fg
=
myCreateImage
(
new_width
,
new_height
,
1
);
my_mog_fg2
=
myCreateImage
(
new_width
,
new_height
,
1
);
...
...
@@ -196,9 +196,9 @@ bool CBM_model::Motion_Detection(myImage *img)
staticFG_pixel_num_pre
=
staticFG_pixel_num_now
;
staticFG_pixel_num_now
=
check_foreground2
(
my_imgStatic
);
myImage_2_opencv
(
my_imgStatic
,
imgStatic
);
myImage_2_opencv
(
my_mog_fg
,
mog_fg
);
myImage_2_opencv
(
my_mog_fg2
,
mog_fg2
);
//
myImage_2_opencv(my_imgStatic,imgStatic);
//
myImage_2_opencv(my_mog_fg,mog_fg);
//
myImage_2_opencv(my_mog_fg2,mog_fg2);
// cv::imwrite("static_obj.jpg", imgStatic);
// cv::imwrite("Long-term.jpg", mog_fg);
// cv::imwrite("Short-term.jpg", mog_fg2);
...
...
CBM_model.h
View file @
e1126306
...
...
@@ -91,7 +91,7 @@ public:
int
TEMPORAL_RULE
;
//VideoDetails *_video;//input video
cv
::
VideoWriter
_writer6
,
_writer7
,
_writer8
,
_writer9
,
_writer10
;
//
cv::VideoWriter _writer6, _writer7, _writer8, _writer9, _writer10;
CBM_model
(
myImage
*
input
,
int
set_MOG_LearnFrame
,
int
set_min_area
,
int
set_buffer_len
,
float
set_resize
,
myImage
*
mask
);
~
CBM_model
();
void
Initialize
();
...
...
@@ -143,9 +143,9 @@ public:
myImage
*
maskROI
;
myImage
*
input_temp
;
private
:
cv
::
Mat
mog_fg
;
//long term
cv
::
Mat
mog_fg2
;
//short term
cv
::
Mat
imgStatic
;
//
cv::Mat mog_fg;//long term
//
cv::Mat mog_fg2;//short term
//
cv::Mat imgStatic;
myImage
*
my_mog_fg
;
//long term
...
...
CMakeLists.txt
View file @
e1126306
cmake_minimum_required
(
VERSION 2.8
)
project
(
ObjLeft
)
find_package
(
OpenCV
4.1.1
REQUIRED
)
find_package
(
OpenCV REQUIRED
)
link_directories
(
${
MYPROJECT_DIR
}
)
...
...
DetectAnomaly.cpp
View file @
e1126306
...
...
@@ -28,13 +28,13 @@ double INPUT_RESIZE;
bool
DetectAnomaly
::
detectAnomaly
(
cv
::
Mat
img
,
vector
<
vector
<
int
>>*
resultLocation
)
{
yolo_test
=
img
.
clone
();
cv
::
Rect
rect
(
0
,
610
,
2400
,
910
);
img
=
img
(
rect
);
cv
::
resize
(
img
,
img
,
cv
::
Size
(
2400
*
0.25
,
910
*
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
//img.copyTo(*myimg);
myimg
=
&
img
;
medianBlur
(
*
mat_myimg
,
*
mat_myimg
,
3
);
opencv_2_myImage
(
*
myimg
,
myimg1
);
//transfer opencv data to myimage data
/************************************************************************/
/* abandoned object detection algorithm */
...
...
@@ -51,9 +51,9 @@ bool DetectAnomaly::detectAnomaly(config cfg, cv::Mat img, vector<vector<int>>*
img
=
img
(
rect
);
//cv::resize(img, img,cv::Size(2400*0.25, 910*0.25), cv::INTER_CUBIC);
cv
::
resize
(
img
,
img
,
cv
::
Size
(
cfg
.
image_width
*
cfg
.
input_resize
,
cfg
.
image_height
*
cfg
.
input_resize
),
cv
::
INTER_CUBIC
);
img
.
copyTo
(
myimg
)
;
medianBlur
(
mat_myimg
,
mat_myimg
,
3
);
opencv_2_myImage
(
myimg
,
myimg1
);
//transfer opencv data to myimage data
myimg
=
&
img
;
medianBlur
(
*
mat_myimg
,
*
mat_myimg
,
3
);
opencv_2_myImage
(
*
myimg
,
myimg1
);
//transfer opencv data to myimage data
/************************************************************************/
/* abandoned object detection algorithm */
...
...
@@ -142,8 +142,9 @@ DetectAnomaly::DetectAnomaly()
mymask
=
myCreateImage
(
cfgAnomaly
.
image_width
,
cfgAnomaly
.
image_height
,
3
);
myInverse
(
mymask
,
mymask
);
myimg1
=
myCreateImage
(
cfgAnomaly
.
image_width
,
cfgAnomaly
.
image_height
,
3
);
myimg
=
cv
::
Mat
(
cv
::
Size
(
cfgAnomaly
.
image_width
,
cfgAnomaly
.
image_height
),
CV_8UC3
);
myimg
.
copyTo
(
mat_myimg
);
myimg
=
new
cv
::
Mat
(
cv
::
Size
(
cfgAnomaly
.
image_width
,
cfgAnomaly
.
image_height
),
CV_8UC3
);
//*myimg.copyTo(*mat_myimg);
mat_myimg
=
myimg
;
// mat_myimg(myimg, 0);
// set roi
...
...
@@ -163,15 +164,15 @@ DetectAnomaly::DetectAnomaly()
cv
::
polylines
(
Image1
,
PointArray
,
arr
,
1
,
true
,
cv
::
Scalar
(
255
,
255
,
255
),
5
,
8
,
0
);
cv
::
fillPoly
(
Image1
,
ppt
,
arr
,
1
,
cv
::
Scalar
(
255
,
255
,
255
),
0
);
cv
::
threshold
(
Image1
,
Image1
,
254
,
255
,
THRESH_BINARY
);
mask
=
Image1
.
clone
()
;
mask
=
&
Image1
;
opencv_2_myImage
(
mask
,
mymask
);
opencv_2_myImage
(
*
mask
,
mymask
);
#ifdef DEBUG
//cv::imwrite("mask.jpg",
Image1
);
cv
::
waitKey
(
1
);
//cv::imwrite("mask.jpg",
*mask
);
//
cv::waitKey(1);
//cvReleaseImage(&Image1);
#endif
_objleft
.
ObjLeftSet
(
myimg1
,
cfgAnomaly
.
gmm_learn_frame
,
cfgAnomaly
.
min_fg
,
cfgAnomaly
.
buffer_length
,
mymask
);
_objleft
.
ObjLeftSet
(
myimg1
,
cfgAnomaly
.
gmm_learn_frame
,
cfgAnomaly
.
min_fg
,
cfgAnomaly
.
buffer_length
,
mymask
,
mask
);
#ifdef DEBUG
printf
(
"Finished initialization.
\n
"
);
#endif
...
...
@@ -220,8 +221,9 @@ DetectAnomaly::DetectAnomaly(config cfg) : cfgAnomaly(cfg)
mymask
=
myCreateImage
(
cfgAnomaly
.
image_width
,
cfgAnomaly
.
image_height
,
3
);
myInverse
(
mymask
,
mymask
);
myimg1
=
myCreateImage
(
cfgAnomaly
.
image_width
,
cfgAnomaly
.
image_height
,
3
);
myimg
=
cv
::
Mat
(
cv
::
Size
(
cfgAnomaly
.
image_width
,
cfgAnomaly
.
image_height
),
CV_8UC3
);
myimg
.
copyTo
(
mat_myimg
);
myimg
=
new
cv
::
Mat
(
cv
::
Size
(
cfgAnomaly
.
image_width
,
cfgAnomaly
.
image_height
),
CV_8UC3
);
//myimg.copyTo(mat_myimg);
mat_myimg
=
myimg
;
// mat_myimg(myimg, 0);
// set roi
...
...
@@ -251,15 +253,15 @@ DetectAnomaly::DetectAnomaly(config cfg) : cfgAnomaly(cfg)
cv
::
polylines
(
Image1
,
PointArray
,
arr
,
1
,
true
,
cv
::
Scalar
(
255
,
255
,
255
),
5
,
8
,
0
);
cv
::
fillPoly
(
Image1
,
ppt
,
arr
,
1
,
cv
::
Scalar
(
255
,
255
,
255
),
0
);
cv
::
threshold
(
Image1
,
Image1
,
254
,
255
,
THRESH_BINARY
);
mask
=
Image1
.
clone
()
;
mask
=
&
Image1
;
opencv_2_myImage
(
mask
,
mymask
);
opencv_2_myImage
(
*
mask
,
mymask
);
#ifdef DEBUG
//
cv::imwrite("mask.jpg", Image1);
cv
::
waitKey
(
1
);
cv
::
imwrite
(
"mask.jpg"
,
Image1
);
//
cv::waitKey(1);
//cvReleaseImage(&Image1);
#endif
_objleft
.
ObjLeftSet
(
myimg1
,
cfgAnomaly
.
gmm_learn_frame
,
cfgAnomaly
.
min_fg
,
cfgAnomaly
.
buffer_length
,
mymask
);
_objleft
.
ObjLeftSet
(
myimg1
,
cfgAnomaly
.
gmm_learn_frame
,
cfgAnomaly
.
min_fg
,
cfgAnomaly
.
buffer_length
,
mymask
,
mask
);
#ifdef DEBUG
printf
(
"Finished initialization.
\n
"
);
#endif
...
...
DetectAnomaly.h
View file @
e1126306
...
...
@@ -44,13 +44,13 @@ private:
cv
::
Point
PointArray1
[
4
];
cv
::
Point
*
PointArray
[
2
]
=
{
&
PointArray1
[
0
],
&
PointArray1
[
2
]};
cv
::
Mat
mask
;
cv
::
Mat
*
mask
;
myImage
*
mymask
;
cv
::
Mat
myimg
;
cv
::
Mat
*
myimg
;
myImage
*
myimg1
;
cv
::
Mat
mat_myimg
;
cv
::
Mat
*
mat_myimg
;
ObjLeftDetect
_objleft
;
bool
obj_left
;
...
...
@@ -63,7 +63,6 @@ public:
DetectAnomaly
();
DetectAnomaly
(
config
cfg
);
cv
::
Mat
yolo_test
;
~
DetectAnomaly
();
};
...
...
ObjLeftDetect.cpp
View file @
e1126306
This diff is collapsed.
Click to expand it.
ObjLeftDetect.h
View file @
e1126306
...
...
@@ -31,11 +31,11 @@ public:
bool
process
(
myImage
*
input
,
vector
<
vector
<
int
>>*
resultLocation
);
CBM_model
*
_CBM_model
;
//cv::VideoWriter _writer1, _writer2;
cv
::
Mat
A
,
B
;
//
cv::Mat A, B;
int
**
image
;
myFloatColor
*
connect_colors
;
void
ObjLeftSet
(
myImage
*
input
,
int
set_MOG_LearnFrame
,
int
set_min_area
,
int
set_buffer_len
,
myImage
*
mask
);
void
ObjLeftSet
(
myImage
*
input
,
int
set_MOG_LearnFrame
,
int
set_min_area
,
int
set_buffer_len
,
myImage
*
mask
,
cv
::
Mat
*
cvmask
);
private
:
//SYSTEMTIME st;
...
...
@@ -55,9 +55,9 @@ private:
int
new_width
,
new_height
;
vector
<
Obj_info
*>
alarmList
;
myImage
*
myimg1
,
*
myimg2
;
cv
::
Mat
ImgSynopsis
;
myImage
*
_ImgSynopsis
;
//
myImage * myimg1, * myimg2;
//
cv::Mat ImgSynopsis;
//
myImage * _ImgSynopsis;
int
Spatial_Temporal_Search
(
int
**
Image
,
int
i
,
int
j
,
myFloatColor
*
colors
,
int
time_stamp
,
int
my_label
);
int
spatial_flood
(
bool
**
foreground
,
int
i
,
int
j
);
...
...
@@ -70,7 +70,7 @@ private:
int
pic_num
=
0
;
//get mask points
cv
::
Mat
objmask
;
cv
::
Mat
*
objmask
;
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
contours
;
};
...
...
main.cpp
View file @
e1126306
...
...
@@ -40,8 +40,8 @@ int main()
opt
.
bottom_left_y
=
853
;
opt
.
bottom_right_x
=
2168
;
opt
.
bottom_right_y
=
842
;
//
DetectAnomaly* detect = new DetectAnomaly(opt);
DetectAnomaly
*
detect
=
new
DetectAnomaly
();
DetectAnomaly
*
detect
=
new
DetectAnomaly
(
opt
);
//
DetectAnomaly* detect = new DetectAnomaly();
int
pic_num
=
0
;
#ifdef DEBUG
//cv::VideoWriter _writer;
...
...
@@ -65,8 +65,8 @@ int main()
// continue;
// }
//
obj_left = detect->detectAnomaly(opt,qImg,&resultLocation);
obj_left
=
detect
->
detectAnomaly
(
qImg
,
&
resultLocation
);
obj_left
=
detect
->
detectAnomaly
(
opt
,
qImg
,
&
resultLocation
);
//
obj_left = detect->detectAnomaly(qImg,&resultLocation);
...
...
@@ -80,32 +80,32 @@ int main()
delete
results_map
[
0
];
delete
input_mats
;
#ifdef DEBUG
//
if (obj_left == true)
//
{
if
(
obj_left
==
true
)
{
//
printf("alram!!\n");
printf
(
"alram!!
\n
"
);
//
for(int i = 0; i < resultLocation.size();i++){
//
int x0 = resultLocation[i][0] * 4;
//
int y0 = resultLocation[i][1] * 4 + 610;
//
int x1 = resultLocation[i][2] * 4;
//
int y1 = resultLocation[i][3] * 4 + 610;
for
(
int
i
=
0
;
i
<
resultLocation
.
size
();
i
++
){
int
x0
=
resultLocation
[
i
][
0
]
*
4
;
int
y0
=
resultLocation
[
i
][
1
]
*
4
+
610
;
int
x1
=
resultLocation
[
i
][
2
]
*
4
;
int
y1
=
resultLocation
[
i
][
3
]
*
4
+
610
;
//
cv::Point p1(x0, y0);
//
cv::Point p2(x1, y1);
//
cv::rectangle(qImg, p1, p2, cv::Scalar(0, 255, 0), 2);
//
}
//
stringstream ss1;
//
string outFile;
//
ss1 << "abanoned_"
//
<< "show"
//
<< count
//
<< ".jpg";
//
ss1 >> outFile;
//
cv::imwrite(outFile.c_str(), qImg);
//
count++;
//
}
cv
::
Point
p1
(
x0
,
y0
);
cv
::
Point
p2
(
x1
,
y1
);
cv
::
rectangle
(
qImg
,
p1
,
p2
,
cv
::
Scalar
(
0
,
255
,
0
),
2
);
}
stringstream
ss1
;
string
outFile
;
ss1
<<
"abanoned_"
<<
"show"
<<
count
<<
".jpg"
;
ss1
>>
outFile
;
cv
::
imwrite
(
outFile
.
c_str
(),
qImg
);
count
++
;
}
#endif
}
gettimeofday
(
&
end
,
NULL
);
...
...
@@ -116,7 +116,7 @@ int main()
printf
(
"Finished detec, then release ...
\n
"
);
#endif
delete
detect
;
//
delete detect;
//system("pause");
return
0
;
}
yolov3/CMakeLists.txt
View file @
e1126306
...
...
@@ -9,7 +9,7 @@ project(yolo-trt VERSION 1.0)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -Wno-write-strings")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,$ORIGIN")
find_package
(
OpenCV
4.1.1
REQUIRED
)
find_package
(
OpenCV REQUIRED
)
#cuda
#export PATH=/usr/local/cuda-10.2/bin:$PATH
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment