Browse Source

Add magiclantern-tools

master
Pekka Helenius 5 years ago
parent
commit
87cd9f8490
8 changed files with 258 additions and 0 deletions
  1. +14
    -0
      Readme.md
  2. +15
    -0
      magiclantern-tools/01-patch_tcc_makefile-fix.patch
  3. +71
    -0
      magiclantern-tools/02_patch_cr2hdr-source_add-dryrun.patch
  4. +11
    -0
      magiclantern-tools/03_patch_add_baseline-exif.patch
  5. +32
    -0
      magiclantern-tools/04_patch_cr2hdr_disable-strings.patch
  6. +11
    -0
      magiclantern-tools/05_patch_modules-makefile_disable-strings.patch
  7. +1
    -0
      magiclantern-tools/Makefile.user
  8. +103
    -0
      magiclantern-tools/PKGBUILD

+ 14
- 0
Readme.md View File

@ -181,6 +181,20 @@ Usage: once you've inserted a SD card into your computer, use 'ml-bootablecard'
**FORMAT:** Arch Linux PKGBUILD script + custom source files. **FORMAT:** Arch Linux PKGBUILD script + custom source files.
## [magiclantern-tools](magiclantern-tools)
Linux-compatible Magic Lantern image processing tools for pictures taken with Canon DSLR's with Magic Lantern firmware.
Tools: `cr2hdr` (for dual ISO images), `mlvdump` (mlv files)
### Highlights
- Additional dry-run feature added to `cr2hdr` (`--dry-run`). Combine with Linux shell scripts, i.e. 1) to check whether images have been taken with dual ISO setting (without actually processing dual ISO images), and do further analysis for these images 2) to distinguish normal CR2 images from dual ISO ones, 3) etc.
- Adds `baseline` information to EXIF metadata
**FORMAT:** Arch Linux PKGBUILD script + patch files.
## [mlvdump](mlvdump) ## [mlvdump](mlvdump)
Magic Lantern Raw file conversion tool for MLV files. Extract individual DNG frames from MLV files. Magic Lantern Raw file conversion tool for MLV files. Extract individual DNG frames from MLV files.


+ 15
- 0
magiclantern-tools/01-patch_tcc_makefile-fix.patch View File

@ -0,0 +1,15 @@
--- a/magic-lantern/tcc/Makefile
+++ b/magic-lantern/tcc/Makefile
@@ -137,6 +137,12 @@
TCCLIBS+=$(LIBTCC1_CROSS)
endif
+#Very bad workaround for solving compilation issues
+CC=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-gcc-4.8.3
+LD=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-ld
+READELF=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-readelf
+OBJCOPY=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-objcopy
+
#all: $(PROGS) $(TCCLIBS) $(TCCDOCS)
all: libtccx.o

+ 71
- 0
magiclantern-tools/02_patch_cr2hdr-source_add-dryrun.patch View File

@ -0,0 +1,71 @@
--- a/magic-lantern/modules/dual_iso/cr2hdr.c
+++ b/magic-lantern/modules/dual_iso/cr2hdr.c
@@ -60,6 +60,7 @@
/** Command-line interface */
+int process_method = 0;
int interp_method = 0; /* 0:amaze-edge, 1:mean23 */
int chroma_smooth_method = 2;
int fix_pink_dots = 0;
@@ -98,7 +99,13 @@
void check_shortcuts()
{
- if (shortcut_fast)
+ if (process_method == 1)
+ {
+ interp_method = 2;
+ chroma_smooth_method = 1;
+ gray_wb = 5;
+ }
+ else if (shortcut_fast)
{
interp_method = 1;
chroma_smooth_method = 0;
@@ -129,6 +136,13 @@
struct cmd_group options[] = {
{
+ "Processing methods", (struct cmd_option[]) {
+ { &process_method, 0, "--process", "Process Dual ISO compatible file (default)" },
+ { &process_method, 1, "--dry-run", "Only check file for Dual ISO presence" },
+ OPTION_EOL
+ },
+ },
+ {
"Shortcuts", (struct cmd_option []) {
{ &shortcut_fast, 1, "--fast", "disable most postprocessing steps (fast, but low quality)\n"
" (--mean23, --no-cs, --no-fullres, --no-alias-map, --no-stripe-fix, --no-bad-pix)" },
@@ -870,12 +884,12 @@
whites[num_files] = raw_info.white_level;
num_files++;
}
- else
+ else if (process_method != 1)
{
printf("ISO blending didn't work\n");
}
}
- else
+ else if (process_method != 1)
{
printf("Doesn't look like interlaced ISO\n");
}
@@ -2206,7 +2220,15 @@
double corr_ev = 0;
int white_darkened = white_bright;
int ok = match_exposures(&corr_ev, &white_darkened);
- if (!ok) goto err;
+ if (!ok)
+ {
+ goto err;
+ }
+ else if (ok && process_method == 1)
+ {
+ printf("Interlaced ISO detected\n"); /*. File: %s\n", filename);*/
+ return 0;
+ }
/* run a second black subtract pass, to fix whatever our funky processing may do to blacks */
black_subtract_simple(raw_info.active_area.x1, raw_info.active_area.y1);

+ 11
- 0
magiclantern-tools/03_patch_add_baseline-exif.patch View File

@ -0,0 +1,11 @@
--- a/magic-lantern/modules/dual_iso/exiftool-bridge.c
+++ a/magic-lantern/modules/dual_iso/exiftool-bridge.c
@@ -10,7 +10,7 @@
{
char exif_cmd[1000];
printf("%-16s: copying EXIF from %s\n", dest, source);
- snprintf(exif_cmd, sizeof(exif_cmd), "exiftool -tagsFromFile \"%s\" -all:all \"-xmp:subject=Dual-ISO\" \"-UniqueCameraModel<Model\" \"%s\" -overwrite_original -q", source, dest);
+ snprintf(exif_cmd, sizeof(exif_cmd), "exiftool -tagsFromFile \"%s\" -all:all \"-xmp:subject=Dual ISO DNG\" \"-UniqueCameraModel<Model\" \"-BaselineExposure=0.25\" \"-BaselineNoise=0.8\" \"-BaselineSharpness=1.2\" \"-BayerGreenSplit=100\" \"%s\" -overwrite_original -q", source, dest);
int r = system(exif_cmd);
if(r!=0)
{

+ 32
- 0
magiclantern-tools/04_patch_cr2hdr_disable-strings.patch View File

@ -0,0 +1,32 @@
--- a/magic-lantern/modules/dual_iso/cr2hdr.c
+++ b/magic-lantern/modules/dual_iso/cr2hdr.c
@@ -53,10 +53,10 @@
#include "timing.h"
#include "kelvin.h"
-#define MODULE_STRINGS_PREFIX dual_iso_strings
+/* #define MODULE_STRINGS_PREFIX dual_iso_strings
#include "../module_strings_wrapper.h"
#include "module_strings.h"
-MODULE_STRINGS()
+MODULE_STRINGS() */
/** Command-line interface */
@@ -570,14 +570,14 @@
int main(int argc, char** argv)
{
printf("cr2hdr: a post processing tool for Dual ISO images\n\n");
- printf("Last update: %s\n", module_get_string(dual_iso_strings, "Last update"));
+ /* printf("Last update: %s\n", module_get_string(dual_iso_strings, "Last update")); */
fast_randn_init();
if (argc == 1)
{
printf("No input files.\n\n");
- printf("GUI usage: drag some CR2 or DNG files over cr2hdr.exe.\n\n");
+ /* printf("GUI usage: drag some CR2 or DNG files over cr2hdr.exe.\n\n"); */
show_commandline_help(argv[0]);
return 0;
}

+ 11
- 0
magiclantern-tools/05_patch_modules-makefile_disable-strings.patch View File

@ -0,0 +1,11 @@
--- a/magic-lantern/modules/Makefile.modules
+++ b/magic-lantern/modules/Makefile.modules
@@ -14,7 +14,7 @@
MODULE_DEP = $(MODULE_NAME).dep
MODULE_DEPS = $(MODULE_NAME).d
-MODULE_STRINGS = module_strings.h
+MODULE_STRINGS =
HGDIFF_OBJS = hgdiff.tmp

+ 1
- 0
magiclantern-tools/Makefile.user View File

@ -0,0 +1 @@
ARM_PATH=$(TOP_DIR)/gcc-arm-none-eabi-4_8-2013q4

+ 103
- 0
magiclantern-tools/PKGBUILD View File

@ -0,0 +1,103 @@
# Maintainer: Pekka Helenius < fincer89 [at] hotmail [dot] com >
pkgname=magiclantern-tools
pkgver=1
pkgrel=1
pkgdesc="Magic Lantern Linux-compatible image processing tools for pictures taken with Canon DSLR's with Magic Lantern firmware."
arch=('any')
url='https://bitbucket.org/hudson/magic-lantern'
license=("GPL")
depends=('perl-image-exiftool' 'dcraw')
optdepends=('octave')
makedepends=('mercurial')
#REQUIRED BY MODULES
#Use these dependencies only if you try compile more modules. They rely partially on rst2html5 package.
#makedepends=('rst2html5' 'python-docutils')
arm_compiler=gcc-arm-none-eabi-4_8-2013q4
source=(
"https://launchpad.net/gcc-arm-embedded/4.8/4.8-2013-q4-major/+download/$arm_compiler-20131204-linux.tar.bz2"
"Makefile.user"
"01-patch_tcc_makefile-fix.patch"
"02_patch_cr2hdr-source_add-dryrun.patch"
"03_patch_add_baseline-exif.patch"
"04_patch_cr2hdr_disable-strings.patch"
"05_patch_modules-makefile_disable-strings.patch"
)
md5sums=('4869e6a6e1dc11ea0835e8b8213bb194'
'035e3049e5f3205680566ffc6c6e9023'
'd2f975ad4896c3b82a5076bd396ceec6'
'2a921d40e65004bb0f9f4d274b83ff04'
'317c4ce8317182a98700b57b285ef184'
'd2e57664cbc7310521eee4b0b13a3f41'
'25281350b6a5a9f40a1b40933f0de829')
prepare() {
cd "$srcdir"/
#####
#Download Magic Lantern latest source files
msg2 "Downloading Magic Lantern source code"
hg clone -r unified https://bitbucket.org/hudson/magic-lantern
#####
#This is an ugly hack, I know. Make sure you update the patch file if you change ARM compiler
patch -Np1 -i "$srcdir"/01-patch_tcc_makefile-fix.patch
#Implement Dry Run feature in CR2HDR
patch -Np1 -i "$srcdir"/02_patch_cr2hdr-source_add-dryrun.patch
#Write Baseline Exposure values to EXIF tags:
patch -Np1 -i "$srcdir"/03_patch_add_baseline-exif.patch
#All modules have python issues (outdated code?) so they don't compile. The problem is related to version etc. strings. Just disable them and compile the code. Only used for cr2hdr (as we need it, not other modules)
patch -Np1 -i "$srcdir"/04_patch_cr2hdr_disable-strings.patch
patch -Np1 -i "$srcdir"/05_patch_modules-makefile_disable-strings.patch
#Custom compilation settings for Magic Lantern (Mainly ARM compiler path redefinition)
ln -fs "$srcdir"/Makefile.user "$srcdir"/magic-lantern/Makefile.user
#Link downloaded ARM compiler files to Magic Lantern directory
ln -fs "$srcdir"/$arm_compiler "$srcdir"/magic-lantern/$arm_compiler
}
build() {
cd ${srcdir}
export PATH=$PATH:${PWD}/${arm_compiler}/bin
cd "$srcdir"/magic-lantern #/modules/dual_iso
#######################################
# FIRMWARE - MODULES FAIL TO BUILD DUE TO PYTHON ISSUES
##make 5D3 #5D Mark 3 - Both firmwares - DOESN'T INCLUDE MODULES YET
##make 5D3.113 #5D Mark 3 - Firmware 1.1.3 - DOESN'T INCLUDE MODULES YET
#make 5D3.123 #5D Mark 3 - Firmware 1.2.3 - DOESN'T INCLUDE MODULES YET
#mkdir -p "$startdir"/5dmark3_firmware_123/
#cp "$srcdir"/magic-lantern/platform/5D3.123/{autoexec.bin,ML-SETUP.FIR} "$startdir"/5dmark3_firmware_123/ #magiclantern.bin,version.bin
#######################################
# MODULES
#make all_modules #All modules - FAIL TO BUILD DUE TO PYTHON ISSUES
#CR2HDR application for host computer
cd "$srcdir"/magic-lantern/modules/dual_iso
make cr2hdr
cd ..
#MLV_DUMP application for host computer
cd "$srcdir"/magic-lantern/modules/mlv_rec
make mlv_dump
cd ..
}
package()
{
mkdir -p "$pkgdir"/usr/bin
cp "$srcdir"/magic-lantern/modules/dual_iso/cr2hdr "$pkgdir"/usr/bin
cp "$srcdir"/magic-lantern/modules/mlv_rec/mlv_dump "$pkgdir"/usr/bin/mlvdump
}

Loading…
Cancel
Save