Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
753b8f6
Rewrite
weenachuangkud Mar 22, 2026
9c9c54c
Update
weenachuangkud Mar 22, 2026
61a4f65
Rewrite
weenachuangkud Mar 22, 2026
1002fad
Update
weenachuangkud Mar 22, 2026
60641fa
Test OpenCV
weenachuangkud Mar 23, 2026
e6ea23d
Test CMakeList.txt
weenachuangkud Mar 23, 2026
d22cf41
Add OpenCV_DIR
weenachuangkud Mar 23, 2026
a1e3e8d
Update
weenachuangkud Mar 23, 2026
1340dd5
Add .kateproject to gitignore
weenachuangkud Mar 23, 2026
3582a38
Update workflow
weenachuangkud Mar 23, 2026
2661051
Update workflow
weenachuangkud Mar 23, 2026
cd40e0a
Add guarding
weenachuangkud Mar 23, 2026
1da35e2
Update workflow
weenachuangkud Mar 23, 2026
95d305f
Update workflow
weenachuangkud Mar 23, 2026
a0f9f40
Add guarding
weenachuangkud Mar 23, 2026
dc43b46
Update workflow
weenachuangkud Mar 23, 2026
9891c6c
Add configuration/json
weenachuangkud Mar 23, 2026
2128a8d
Add crop_config.h
weenachuangkud Mar 23, 2026
52d9306
Add semicolon
weenachuangkud Mar 23, 2026
dd37438
Update CMakeLists.txt
weenachuangkud Mar 23, 2026
8656a34
Update .clangd
weenachuangkud Mar 23, 2026
2903e36
Update crop_config.h
weenachuangkud Mar 23, 2026
c601ab7
Update crop_config.h
weenachuangkud Mar 23, 2026
e226a34
Type casting
weenachuangkud Mar 23, 2026
d6d5a82
Update
weenachuangkud Mar 23, 2026
9288583
Update parameters
weenachuangkud Mar 23, 2026
de5b36c
Update CMakeLists.txt
weenachuangkud Mar 23, 2026
05ba0e0
Update CMakeLists.txt
weenachuangkud Mar 23, 2026
e32a21a
Update CMakeLists.txt
weenachuangkud Mar 23, 2026
1d28d3d
Add window-build.yml workflow
weenachuangkud Mar 23, 2026
c353ed5
Rename
weenachuangkud Mar 23, 2026
7f01448
Remove cpp-build.yml
weenachuangkud Mar 23, 2026
60e2578
Update CMakeLists.txt
weenachuangkud Mar 23, 2026
6f826b5
Update
weenachuangkud Mar 23, 2026
2c5b90b
Fix Inden
weenachuangkud Mar 23, 2026
dab0a60
Update
weenachuangkud Mar 23, 2026
91e6c68
Fix Inden
weenachuangkud Mar 23, 2026
d87b60a
Update CMakeLists.txt
weenachuangkud Mar 23, 2026
1d343de
Add path flag for window workflow
weenachuangkud Mar 24, 2026
2dff7db
Add spacing for readable
weenachuangkud Mar 24, 2026
9abb079
Fix
weenachuangkud Mar 24, 2026
48cf8b6
Add yaml-schema for better autocomplete
weenachuangkud Mar 24, 2026
98ecdd8
Update
weenachuangkud Mar 24, 2026
9d977f9
Update
weenachuangkud Mar 24, 2026
3959c68
Final
weenachuangkud Mar 24, 2026
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
9 changes: 9 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# yaml-language-server: $schema=https://json.schemastore.org/clangd.json

CompileFlags:
CompilationDatabase: "build/"

Add:
- "-std=c++17"
- "-IC:/libraries/opencv/build/include"
- "-IC:/libraries/nlohmann"
24 changes: 0 additions & 24 deletions .github/workflows/cpp-build.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/ubuntu-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Ubuntu C++ Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install OpenCV
run: |
sudo apt-get update
sudo apt-get install -y --fix-missing libopencv-dev ninja-build

- name: Configure with CMake
run: cmake -B build -G Ninja

- name: Build
run: cmake --build build
32 changes: 32 additions & 0 deletions .github/workflows/window-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Window C++ build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1

- name: Install Ninja
run: choco install ninja

- name: Install OpenCV
run: choco install opencv -y

- name: Find OpenCV path
run: dir C:\tools\opencv

- name: Configure with CMake (Ninja + MSVC)
run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR="C:/tools/opencv/build"

- name: Build
run: cmake --build build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode
.kateproject
__pycache__/*
input-*
!input/example*.jpg
Expand Down
55 changes: 55 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.10)
project(CropSense-Face-Detection)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# ---- OpenCV setup ----
if(WIN32)
if(NOT DEFINED OpenCV_DIR)
set(OpenCV_DIR "C:/libraries/opencv/build")
message(STATUS "Using default OpenCV_DIR: ${OpenCV_DIR}")
endif()
if(NOT EXISTS "${OpenCV_DIR}/OpenCVConfig.cmake")
message(FATAL_ERROR "OpenCVConfig.cmake not found in ${OpenCV_DIR}")
endif()
find_package(OpenCV QUIET PATHS "${OpenCV_DIR}")
else()
find_package(OpenCV REQUIRED)
endif()

if(NOT OpenCV_FOUND)
message(FATAL_ERROR
"OpenCV not found!\n"
"Check:\n"
"- OpenCV_DIR=${OpenCV_DIR}\n"
"- Make sure x64/vc16/lib exists\n"
)
endif()

# ---- Executable ----
add_executable(main
src/main.cpp
src/user_input.cpp
src/image_processing.cpp
)

# ---- JSON (nlohmann) ----
include(FetchContent)
FetchContent_Declare(json
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
)
FetchContent_MakeAvailable(json)

# ---- Linking ----
target_link_libraries(main
PRIVATE
${OpenCV_LIBS}
nlohmann_json::nlohmann_json
)

# ---- Debug info ----
message(STATUS "OpenCV version: ${OpenCV_VERSION}")
message(STATUS "OpenCV include dirs: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "OpenCV libraries: ${OpenCV_LIBS}")
23 changes: 23 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"confidence_level" : 0.5,


"output_res" : 1080,
"preview_output_res" : 256,
"preview_debug_max_res" : 640,


"min_face_res" : 96,
"min_upperbody_res" : 64,
"min_fullbody_res" : 32,


"input_folder" : "input",
"output_upperbody_folder": "output/upperbody_cropped",
"debug_upperbody_folder": "output/upperbody_debug",
"output_face_folder": "output/face_cropped",
"debug_face_folder": "output/face_debug",
"output_fullbody_folder": "output/fullbody_cropped",
"debug_fullbody_folder": "output/fullbody_debug",
"error_folder": "output/error_images"
}
19 changes: 19 additions & 0 deletions src/crop_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include<string>

enum class CropType {
UpperBody = 1,
Face = 2,
FullBody = 3
};

struct CropConfig
{
std::string error_folder;
std::string debug_folder;
std::string output_folder;
float top_margin;
float bottom_margin;
CropType crop_type;
};
Empty file added src/image_processing.cpp
Empty file.
26 changes: 26 additions & 0 deletions src/image_processing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include<string>
#include "crop_config.h"
#include "user_input.h"

struct ImageProcessConfig {
int output_res;
int preview_output_res;
int preview_debug_max_res;
float confidence_level;
int min_face_res;
int min_upperbody_res;
int min_fullbody_res;
};

void images_error(
const std::string& image_path,
const std::string& error_folder
);
int process_image(
const std::string& image_path,
const CropConfig& crop,
const ImageProcessConfig& process_config,
const PreviewConfig& preview_config
);
Loading
Loading