Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
17a5169
basic UI integration
MikoMikarro Jan 1, 2025
6f5608f
new mask as source of coordinates, created new brush
MikoMikarro Jan 1, 2025
81688d7
add onnxruntime
MikoMikarro Jan 14, 2025
c3cfe6b
added cmake to include onnx
MikoMikarro Jan 15, 2025
6d8094c
added mask button
MikoMikarro Jan 15, 2025
91ade37
added basic mask creation and loading
MikoMikarro Jan 20, 2025
6300dc6
Merge commit '17a5169284f7908c6b8e98281155b458bfe5ce6a' into object_mask
MikoMikarro Jan 31, 2025
ff417f3
base commit
MikoMikarro Jan 31, 2025
3748f2a
Merge commit '6f5608f690bae97ffaec77ef275d979ddc2501a0' into object_mask
MikoMikarro Jan 31, 2025
b941ff9
Merge commit '81688d728298635ce9998cdd8e9aee9c155635c8' into object_mask
MikoMikarro Jan 31, 2025
8b439e6
Merge commit 'c3cfe6b55462ccbb0530545d9a1e86364c71afc4' into object_mask
MikoMikarro Jan 31, 2025
4496f1b
Merge commit '6d8094c901a5d0244685b61a51676c7a883f191b' into object_mask
MikoMikarro Jan 31, 2025
9f34c77
Merge commit '91ade3730d0abb59ffe9c6dbf0996d8a62c2e520' into object_mask
MikoMikarro Jan 31, 2025
44427fb
reconstruction of commit "8532d72"
MikoMikarro Jan 31, 2025
73255a4
reconstruction of commit ee3db7f "corrected mask loading and scaling …
MikoMikarro Jan 31, 2025
2941b47
update onnxruntime version to last release
MikoMikarro Feb 1, 2025
7c8819a
delete section for AI masks as they will be just a brush
MikoMikarro Feb 1, 2025
03ee389
Cleaned code into separate files
MikoMikarro Feb 1, 2025
79a459a
updated pixepiple cause half merge not well done
MikoMikarro Feb 1, 2025
2c2b21e
recover AI button from previous commit
MikoMikarro Feb 1, 2025
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
[submodule "src/external/lua-scripts"]
path = src/external/lua-scripts
url = https://github.com/darktable-org/lua-scripts.git
[submodule "src/external/onnxruntime"]
path = src/external/onnxruntime
url = https://github.com/microsoft/onnxruntime
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unstable FORK
THIS FORK IS JUST FOR DEVELOPMENT AND TEST PURPOSES
DON'T USE FOR SENSITIVE WORK

[![icon](/data/pixmaps/idbutton.png?raw=true)](https://www.darktable.org/) darktable [![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/darktable-org/darktable/ci.yml?branch=master)](https://github.com/darktable-org/darktable/actions/workflows/ci.yml?query=branch%3Amaster+is%3Acompleted+event%3Apush) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/470/badge)](https://bestpractices.coreinfrastructure.org/projects/470)
=========

Expand Down
1 change: 1 addition & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ src/develop/imageop_gui.c
src/develop/lightroom.c
src/develop/masks/brush.c
src/develop/masks/circle.c
src/develop/masks/point.c
src/develop/masks/ellipse.c
src/develop/masks/gradient.c
src/develop/masks/group.c
Expand Down
29 changes: 28 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
add_subdirectory(external)

set(ONNXRUNTIME_ROOTDIR "/home/miko/Downloads/installers/onnxruntime-linux-x64")

include(CheckCSourceCompiles)
include(CheckCXXSymbolExists)

Expand Down Expand Up @@ -111,13 +113,17 @@ FILE(GLOB SOURCE_FILES
"develop/lightroom.c"
"develop/masks/brush.c"
"develop/masks/circle.c"
"develop/masks/point.c"
"develop/masks/ellipse.c"
"develop/masks/gradient.c"
"develop/masks/group.c"
"develop/masks/masks.c"
"develop/masks/path.c"
"develop/object_detection.c"
"develop/pixelpipe.c"
"develop/tensor_boxes.c"
"develop/tiling.c"
"develop/image_file_libpng.c"
"dtgtk/button.c"
"dtgtk/culling.c"
"dtgtk/drawingarea.c"
Expand Down Expand Up @@ -158,7 +164,7 @@ FILE(GLOB SOURCE_FILES
"views/view.c"
)

FILE(GLOB HEADER_FILES "*.h" "common/*.h" "external/OpenCL/CL/*.h" "control/*.h" "iop/*.h" "libs/*.h" "views/*.h")
FILE(GLOB HEADER_FILES "*.h" "common/*.h" "external/OpenCL/CL/*.h" "external/onnxruntime/include/onnxruntime/core/session/*.h" "control/*.h" "iop/*.h" "libs/*.h" "views/*.h")

if(APPLE)
list(APPEND SOURCE_FILES "osx/osx.mm")
Expand Down Expand Up @@ -226,6 +232,7 @@ endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external)
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/OpenCL)
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/onnxruntime/include/onnxruntime/core/session)

# initial compiler flags
add_definitions("-DHAVE_CONFIG_H")
Expand Down Expand Up @@ -972,6 +979,26 @@ unset(LIB_DEPS)
add_library(lib_darktable_imageio_rawspeed STATIC imageio/imageio_rawspeed.cc)
target_link_libraries(lib_darktable_imageio_rawspeed PRIVATE rawspeed)
target_link_libraries(lib_darktable PRIVATE lib_darktable_imageio_rawspeed)
link_directories(lib_darktable "${ONNXRUNTIME_ROOTDIR}/lib")
target_link_libraries(lib_darktable PRIVATE "${ONNXRUNTIME_ROOTDIR}/lib/libonnxruntime.so")


find_package(JPEG)
if(LIBPNG_ROOTDIR)
set(PNG_FOUND true)
set(PNG_LIBRARIES png16)
set(PNG_INCLUDE_DIRS "${LIBPNG_ROOTDIR}/include")
set(PNG_LIBDIR "${LIBPNG_ROOTDIR}/lib")
else()
find_package(PNG)
endif()

target_include_directories(lib_darktable PRIVATE ${PNG_INCLUDE_DIRS})
target_link_libraries(lib_darktable PRIVATE ${PNG_LIBRARIES})

if(PNG_LIBDIR)
target_link_directories(lib_darktable PRIVATE ${PNG_LIBDIR})
endif()

#
# Install lib_darktable
Expand Down
2 changes: 1 addition & 1 deletion src/develop/blend.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ extern const dt_introspection_type_enum_tuple_t dt_develop_combine_masks_names[]
extern const dt_introspection_type_enum_tuple_t dt_develop_feathering_guide_names[];
extern const dt_introspection_type_enum_tuple_t dt_develop_invert_mask_names[];

#define DEVELOP_MASKS_NB_SHAPES 5
#define DEVELOP_MASKS_NB_SHAPES 6

/** blend gui data */
typedef struct dt_iop_gui_blend_data_t
Expand Down
8 changes: 8 additions & 0 deletions src/develop/blend_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -2831,6 +2831,14 @@ void dt_iop_gui_init_masks(GtkWidget *blendw, dt_iop_module_t *module)
FALSE, 0, 0,
dtgtk_cairo_paint_masks_brush, abox);

bd->masks_type[5] = DT_MASKS_POINT;
bd->masks_shapes[5] = dt_iop_togglebutton_new(module, "blend`shapes",
N_("add point"),
N_("add multiple points"),
G_CALLBACK(_blendop_masks_add_shape),
FALSE, 0, 0,
dtgtk_cairo_paint_masks_ai, abox);

bd->masks_type[1] = DT_MASKS_PATH;
bd->masks_shapes[1] = dt_iop_togglebutton_new(module, "blend`shapes",
N_("add path"),
Expand Down
12 changes: 12 additions & 0 deletions src/develop/image_file.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once
#include "onnxruntime_c_api.h"
#ifdef __cplusplus
extern "C" {
#endif

int write_image_file(_In_ uint8_t* model_output_bytes, unsigned int height,
unsigned int width, _In_z_ const ORTCHAR_T* output_file);

#ifdef __cplusplus
}
#endif
19 changes: 19 additions & 0 deletions src/develop/image_file_libpng.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "image_file.h"
#include <png.h>

int write_image_file(uint8_t* model_output_bytes, unsigned int height,
unsigned int width, const char* output_file){
png_image image;
memset(&image, 0, (sizeof image));
image.version = PNG_IMAGE_VERSION;
image.format = PNG_FORMAT_BGR;
image.height = height;
image.width = width;
int ret = 0;
if (png_image_write_to_file(&image, output_file, 0 /*convert_to_8bit*/, model_output_bytes, 0 /*row_stride*/,
NULL /*colormap*/) == 0) {
printf("write to '%s' failed:%s\n", output_file, image.message);
ret = -1;
}
return ret;
}
5 changes: 4 additions & 1 deletion src/develop/masks.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ typedef enum dt_masks_type_t
DT_MASKS_GRADIENT = 1 << 4,
DT_MASKS_ELLIPSE = 1 << 5,
DT_MASKS_BRUSH = 1 << 6,
DT_MASKS_NON_CLONE = 1 << 7
DT_MASKS_NON_CLONE = 1 << 7,
DT_MASKS_POINT = 1 << 8,
} dt_masks_type_t;

/**masts states */
Expand Down Expand Up @@ -326,6 +327,7 @@ typedef struct dt_masks_functions_t
const int num_points);
} dt_masks_functions_t;


/** structure used to define a form */
typedef struct dt_masks_form_t
{
Expand Down Expand Up @@ -441,6 +443,7 @@ extern const dt_masks_functions_t dt_masks_functions_brush;
extern const dt_masks_functions_t dt_masks_functions_path;
extern const dt_masks_functions_t dt_masks_functions_gradient;
extern const dt_masks_functions_t dt_masks_functions_group;
extern const dt_masks_functions_t dt_masks_functions_point;

/** init dt_masks_form_gui_t struct with default values */
void dt_masks_init_form_gui(dt_masks_form_gui_t *gui);
Expand Down
14 changes: 13 additions & 1 deletion src/develop/masks/masks.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,8 @@ dt_masks_form_t *dt_masks_create(dt_masks_type_t type)
form->functions = &dt_masks_functions_gradient;
else if(type & DT_MASKS_GROUP)
form->functions = &dt_masks_functions_group;
else if(type & DT_MASKS_POINT)
form->functions = &dt_masks_functions_point;

if(form->functions && form->functions->sanitize_config)
form->functions->sanitize_config(type);
Expand Down Expand Up @@ -1263,7 +1265,8 @@ void dt_masks_events_post_expose(dt_iop_module_t *module,
// add preview when creating a circle, ellipse and gradient
if(!(((form->type & DT_MASKS_CIRCLE)
|| (form->type & DT_MASKS_ELLIPSE)
|| (form->type & DT_MASKS_GRADIENT))
|| (form->type & DT_MASKS_GRADIENT)
|| (form->type & DT_MASKS_POINT))
&& gui->creation))
dt_masks_gui_form_test_create(form, gui, module);

Expand Down Expand Up @@ -1711,6 +1714,9 @@ void dt_masks_iop_value_changed_callback(GtkWidget *widget,
// add a brush shape
_menu_add_shape(module, DT_MASKS_BRUSH);
}
else if(val == -2000128) {
_menu_add_shape(module, DT_MASKS_POINT);
}
else if(val < 0)
{
// use same shapes as another iop
Expand Down Expand Up @@ -2561,6 +2567,12 @@ void dt_masks_calculate_source_pos_value(dt_masks_form_gui_t *gui,
x += xpos;
y += ypos;
}
else if(mask_type & DT_MASKS_POINT)
{
dt_masks_functions_point.initial_source_pos(iwidth, iheight, &x, &y);
x += xpos;
y += ypos;
}
#endif
else
dt_print(DT_DEBUG_ALWAYS, "[dt_masks_calculate_source_pos_value]"
Expand Down
Loading