Open wtnan2003 opened 4 years ago
I change main.cpp as you described in this Line | From | To |
---|---|---|
142 | CAP_PROP_FPS | CV_CAP_PROP_FPS |
143 | CAP_PROP_BUFFERSIZE | CV_CAP_PROP_BUFFERSIZE |
158 | CAP_PROP_FPS | CV_CAP_PROP_FPS |
159 | CAP_PROP_FRAME_COUNT | CV_CAP_PROP_FRAME_COUNT |
184 | VideoWriter::fourcc('M', 'P', '4', 'V') | CV_FOURCC('M', 'P', '4', 'V') |
@wtnan2003
I think cv::VideoWriter
in OpenCV 2.4 doesn't support mp4v
format.
Try below changes.
Line | From | To |
---|---|---|
184 | CV_FOURCC('M', 'P', '4', 'V') | CV_FOURCC('X', 'V', 'I', 'D') OR CV_FOURCC('M', 'P', '2', 'V') |
/*
opencv/modules/highgui/src/cap_gstreamer.cpp#L462-L479
*/
void CvVideoWriter_GStreamer::init()
{
encs[CV_FOURCC('D','R','A','C')]=(char*)"diracenc";
encs[CV_FOURCC('H','F','Y','U')]=(char*)"ffenc_huffyuv";
encs[CV_FOURCC('J','P','E','G')]=(char*)"jpegenc";
encs[CV_FOURCC('M','J','P','G')]=(char*)"jpegenc";
encs[CV_FOURCC('M','P','1','V')]=(char*)"mpeg2enc";
encs[CV_FOURCC('M','P','2','V')]=(char*)"mpeg2enc";
encs[CV_FOURCC('T','H','E','O')]=(char*)"theoraenc";
encs[CV_FOURCC('V','P','8','0')]=(char*)"vp8enc";
encs[CV_FOURCC('H','2','6','4')]=(char*)"x264enc";
encs[CV_FOURCC('X','2','6','4')]=(char*)"x264enc";
encs[CV_FOURCC('X','V','I','D')]=(char*)"xvidenc";
encs[CV_FOURCC('F','F','Y','U')]=(char*)"y4menc";
//encs[CV_FOURCC('H','F','Y','U')]=(char*)"y4menc";
pipeline=0;
buffer=0;
}
@imsoo thanks for giving respond I change to Opencv 3.1 solve it, but still gets some problem:
I have open four terminals and run: ./sink ./ventilator ./worker cfg/fight.cfg weight/fight.weight -gpu 0 -pose ./darknet_client -addr 127.0.0.1 -vid kick.mp4 -out_vid -dont_show
sink work like this:
ventilator:
worker :
darknet_client, keep running all the time :
the output video and json is empty :
what should I do to fix it?
@wtnan2003
In this repo, we need to make below pipeline.
Client → Ventilator → Worker → (Sink ⇄ Action) → Client
So, you need to run action.py
additionally. Try below command.
./sink
./ventilator
./worker cfg/openpose.cfg weight/openpose.weight -gpu 0 -pose
./action.py
./darknet_client ...
fight.weight
is for YOLO. You need to use openpose.weight
If you want to run this(fight detection based on YOLO object detection), try below command using darknet_server not this repo.
./sink
./ventilator
./worker cfg/fight.cfg weights/fight.weights names/fight.names -gpu 0 -thresh 0.2
./darknet_client ...
If this is confusing, let me know and I will try to explain.
@imsoo thanks for your reply!
I want to run this:
There are not "openpose.weight" in weight file , only action.h5
I see I will download it in https://drive.google.com/file/d/1BfY0Hx2d2nm3I4JFh0W1cK2aHD1FSGea/view
when I run
python3 action.py
my keras version is 2.2.4 tensorflow.keras version is 2.1.6-tf tensorflow version is 1.9.0
what should I do?
thx
@imsoo Would you tell me your Keras and TensorFlow version?
I am really interested in this repo
@wtnan2003
Sorry for my late reply. I was late finding the cause of the problem.
First, I've tested the same environment on my computer and got a same error.
import tensorflow as tf
print(tf.__version__)
>>> 1.9.0
from tensorflow import keras
print(keras.__version__)
>>> 2.1.6-tf
I've found this issue. So I've upgrade tensorflow to 2.1.0 and retry it. and it works fine.
import tensorflow as tf
print(tf.__version__)
>>> 2.1.0
from tensorflow import keras
print(keras.__version__)
>>> 2.2.4-tf
Please upgrade tensorflow and try again.
@imsoo TensorFlow 2.1.0 seems to be incompatible with my system environment: Cuda 9.0.
I worried about the global environment if I change to Cuda 10.1
Is there any easier way to fix it?
@wtnan2003
I understand it well.
Could you try changed code below?
This code create a standard model with the same architecture and load weights files.
@imsoo It works ! thanks!
But It seems only got one result, then broken:
./ventilator and ./worker seems to work fine
./sink broken
@wtnan2003
Could you change MSG_BUF_LEN( 76800 -> 102400)
and try again? (need to rebuild all)
@imsoo thanks for your quick reply!!
Sink doesn't break now after rebuild all
But: *** Error in `./darknet_client': free(): corrupted unsorted chunks: 0xR : 0 | C : 542 | F : 0 | T : 543 : 1 R : 0 | C : 542 | F : 0 | T : R : 0 | C : 542 | F : 0 | T : 543 : 1 Aborted (core dumped)
@wtnan2003
Sorry, a client needs change too.
@imsoo Thanks for your help! Now Everything works fine, not Error any more but output_video file_size is increasing very slowly I will check it when finished
@wtnan2003
Thanks for your help! Now Everything works fine, not Error any more
:+1:
but output_video file_size increasing very slowly
Did you set GPU option when you build a darknet library?
# AlexeyAB/darknet/Makefile
GPU=1
CUDNN=1
CUDNN_HALF=0
OPENCV=1
AVX=0
OPENMP=1
LIBSO=1
ZED_CAMERA=0 # ZED SDK 3.0 and above
ZED_CAMERA_v2_8=0 # ZED SDK 2.X
@imsoo oh... I forgot to do that 😂
@imsoo I check the video output (ignore the wrong pixel, which caused by gif recorder):
there are not "kick" detected, anything wrong?
@wtnan2003
Sorry, action recognition performance is not good especially kick action.
I think it needs more train. (with dataset and add more feature vector)
But try below thing to improve result.
width, height
and try again. (200 -> 400)action2.h5
. (action.h5 -> action2.h5)thx a lot🤝
I will try it later
@imsoo
Everything works fine when I run ./darknet_client ... video1.mp4 ...
But I get empty output_video file_size when I want to continue to detect another video (by simply run ./darknet_client ... video2.mp4 ...
without restart other servers)
It seems to disconnect between client and action when I finish a video?
thx!
@wtnan2003
Oh sorry, I forgot to tell you.
After one video is over, we need to re-run sink.
The sink retains the track_frame to send frames of the video to the client in order.
So after one video is over, track_frame be a total number of frames.
But sink doesn't know if it's the end. This causes a problem.
If the client starts sending frames of another video, sink think that this frame is not the right order.
To solve this problem, I think we need to add something to mark the end of the video.
This is my TODO but I haven't done it yet.
@imsoo thx anyway
By the way,what is the meaning of the number of bounding boxes?
It's an ID given as a result of object(person) tracking.
hi @imsoo ,I notice that fight detection is base on:
This stage check that person who kick or punch is hitting someone. if some person has hit other, those people set enemy each other. System count it as fight and then track them until they exist in frame.
I have some questions:
until they exist in frame.
,It seems to track many frames。Is it track them until tracker loses one of the fighters?I would be appreciated if you help me out of these
@wtnan2003
1.how to define which person is being punched or kicked (If there are many people in one frame)?
In Sink process, We run this pipeline.
Tracking (Tracker) -> Action Recogintion (Action) -> Fight Detection (In Sink)
Tracker receive bounding boxes (is produced which is a result of pose estimation) and produces object unique IDs. Plus, Tracker manage time series data about each person.
So we can get unique data (joint time series data) about each person. This data is used to recognize the action of each person.
For instance, (not the actual outcome.)
Stage |
Frame 12 |
Frame 32 |
---|---|---|
Input | ||
Pose | ||
Track | ||
Action |
2.what is meaning of until they exist in frame.,It seems to track many frames。Is it track them until tracker loses one of the fighters?
Yes, It's when a tracker misses them or they disappear.
@imsoo
Thank you for your explanation.
how Crash detention work? (maybe bounding box IOU?)
@wtnan2003
Compare the position of the wrist and elbow with the other person's bounding box. If the wrist and elbow are located in the bounding box, it's a crash. (set as an enemy to each other) For kick action, use the position of the ankles and knees.
In Sink process, The comparison is a simply nested for loop.
For instance,
ID1: walking、ID2:standing、ID3:punching.
ID1 : Walking (Do not check) ID2 : Standing (Do not check) ID3 : Punching ----> Check (comparison with ID1) ----> Check (comparison with ID2)
Server and client make successfully
But Something gets wrong when I run ./darknet_client:
Is that OpenCV version problem? any help would be appreciated