Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CMakeCache.txt
cmake_install.cmake
Makefile
/CMakeFiles
*.caffemodel
adas_spbu
/build
*.xml
*.example

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)


find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
find_package( OpenPose REQUIRED )
find_package( Threads REQUIRED )

include_directories( ${OpenCV_INCLUDE_DIRS} ${OpenPose_INCLUDE_DIRS})

add_executable(${PROJECT_NAME} main.cpp)
add_executable(${PROJECT_NAME} main.cpp src/falsePositiveFilter.hpp src/falsePositiveFilter.cpp )

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${OpenPose_LIBS})
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 osechkina-masha

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Description
This branch contains a human pose estimation false positive filter based on OpenPose. Also, the scripts for getting the models were taken from [OpenPose](https://github.com/CMU-Perceptual-Computing-Lab/openpose).

## Requirements:
You should first install Cuda version 11 or higher, CuDNN version 8 or higher, gcc version 10 or higher, and cmake version 3 or higher.

## Usage guide
To demonstrate the work of this project, you need to
##### Step №1: Install OpenCV latest version
You need to install opencv using this [guide](https://docs.opencv.org/4.x/d0/d3d/tutorial_general_install.html).
Also if you do it on linux, you should compile OpenCV with a GUI backend and video reader such as GTK and FFmpeg.
##### Step №2: Install OpenPose
You need to install opencv using this [guide](https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation/0_index.md), then go to the build directory of OpenPose and run this command if you are on Linux/Mac OS:
```shell
sudo make install
```
If you are on windows then set the environment variables path to build OpenPose.
##### Step №3: Clone the Project
```shell
git clone https://github.com/osechkina-masha/adas_spbu.git
cd adas_spbu
git checkout pedestrian_detection
```
##### Step №4: Getting models
If you are on Windows run the models/getModels.bat file, if you are on Linux/Mac OS run the models/getModels.sh file.
After that, you must also replace the model in the folder model/body_25 with the model from this [link](https://www.dropbox.com/s/03r8pa8sikrqv62/pose_iter_584000.caffemodel?dl=0), otherwise there will be an error to parse NetParameter file.
##### Step №5: Project Launch
If you are on Windows using cmake-gui, configure the project for Visual Studio, build and run the *.sln file with Visual Studio.
On Linix/Mac OS, build and run the project with these commands:
```shell
cmake .
make
./adas_spbu your_video_file.mp4
```

## Authors
[@Grigory-Aseev](https://github.com/Grigory-Aseev)

## License
Source code of this repository is released under the [MIT license](https://choosealicense.com/licenses/mit/)
55 changes: 32 additions & 23 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,51 +1,60 @@
#include <iostream>

#include <algorithm>

#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/highgui/highgui.hpp"

//sample: ./adas_spbu video_name.mp4
#include "src/falsePositiveFilter.hpp"

int main(int argc, char *argv[])
{
if (argc != 2)
{
return 1;
}

cv::VideoCapture newFrameCap(argv[1]);

if (!newFrameCap.isOpened())
{
return 1;
}
int frame_width = newFrameCap.get(cv::CAP_PROP_FRAME_WIDTH);
//обрезка капота
int cut_height = 300;
int frame_height = newFrameCap.get(cv::CAP_PROP_FRAME_HEIGHT) - cut_height;
double roll = -10.0;

// Configuring OpenPose
op::opLog("Configuring OpenPose...", op::Priority::High);
op::Wrapper opWrapper{op::ThreadManagerMode::Asynchronous};

// Starting OpenPose
op::opLog("Starting thread(s)...", op::Priority::High);
opWrapper.start();

bool empty = false;
while (!empty) {
while (!empty)
{
cv::Mat frame;
newFrameCap >> frame;
empty = frame.rows == 0;
if (empty)
{
break;
}
cv::Point2f center(frame.cols / 2.0, frame.rows / 2.0);
cv::Mat rotation_matix = cv::getRotationMatrix2D(center, roll, 1.0);
cv::Mat rotated_image(frame.rows, frame.cols, CV_8UC3, cv::Scalar(0));
//убираем ролл
cv::warpAffine(frame, rotated_image, rotation_matix, frame.size());
rotated_image = rotated_image(cv::Rect(0, 0, frame_width, frame_height));

cv::imshow("frame", rotated_image);
cv::waitKey(1);

op::Matrix imageToProcess = OP_CV2OPCONSTMAT(frame);
auto datumProcessed = opWrapper.emplaceAndPop(imageToProcess);

if (datumProcessed != nullptr && !datumProcessed->empty())
{

cv::Mat cvMat = OP_OP2CVCONSTMAT(datumProcessed->at(0)->cvOutputData);
PedestrianFilter::falsePositiveFilter::filterizeFrame(datumProcessed, cvMat);
if (!cvMat.empty())
{
cv::imshow("frame", cvMat);
cv::waitKey(1);
}
}
else
{
op::opLog("Image could not be processed.", op::Priority::High);
}
}

newFrameCap.release();
return 0;
}
Loading