Merge pull request #15 from supertobi/master

Fixed bugs and make it work with hugin 2015.0.0
This commit is contained in:
Boucman
2015-09-11 10:38:12 +02:00

View File

@@ -3,6 +3,7 @@
copyright (c) 2014 Wolfgang Goetz
copyright (c) 2015 Christian Kanzian
copyright (c) 2015 Tobias Jakobs
darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,38 +33,87 @@ USAGE
This plugin will add a new storage option and calls hugin after export.
]]
dt = require "darktable"
local dt = require "darktable"
-- should work with darktable API version 2.0.0
dt.configuration.check_version(...,{2,0,0})
dt.register_storage("module_hugin","Hugin panorama",
function(storage, image, format, filename,
number,total,high_quality,extra_data)
dt.print("Export to hugin " .. tostring(number).."/"..tostring(total))
end,
function(storage,image_table,extra_data) --finalize
-- list of exported images
local img_list
-- reset and create image list
img_list = ""
for _,v in pairs(image_table) do
img_list = img_list ..v.. " "
end
dt.print("Will try to stitch now")
if coroutine.yield("RUN_COMMAND","hugin "..img_list)
then
dt.print("Command hugin failed ...")
end
end,
nil,
nil
)
local function checkIfBinExists(bin)
local handle = io.popen("which "..bin)
local result = handle:read()
local ret
handle:close()
if (result) then
dt.print_error("true checkIfBinExists: "..bin)
ret = true
else
dt.print_error(bin.." not found")
ret = false
end
return ret
end
local function show_status(storage, image, format, filename,
number, total, high_quality, extra_data)
dt.print("Export to Hugin "..tostring(number).."/"..tostring(total))
end
local function create_panorama(storage, image_table, extra_data) --finalize
if not checkIfBinExists("hugin") then
darktable.print_error("hugin not found")
return
end
-- Since Hugin 2015.0.0 hugin provides a command line tool to start the assistant
-- http://wiki.panotools.org/Hugin_executor
-- We need pto_gen to create pto file for hugin_executor
-- http://hugin.sourceforge.net/docs/manual/Pto_gen.html
local hugin_executor = false
if (checkIfBinExists("hugin_executor") and checkIfBinExists("pto_gen")) then
hugin_executor = true
end
-- list of exported images
local img_list
-- reset and create image list
img_list = ""
for _,v in pairs(image_table) do
img_list = img_list ..v.. " "
end
dt.print("Will try to stitch now")
local huginStartCommand
if (hugin_executor) then
huginStartCommand = "pto_gen "..img_list.." -o "..dt.configuration.tmp_dir.."/project.pto"
dt.print("Creating pto file")
coroutine.yield("RUN_COMMAND", huginStartCommand)
dt.print("Running Assistent")
huginStartCommand = "hugin_executor --assistant "..dt.configuration.tmp_dir.."/project.pto"
coroutine.yield("RUN_COMMAND", huginStartCommand)
huginStartCommand = "hugin "..dt.configuration.tmp_dir.."/project.pto"
else
huginStartCommand = "hugin "..img_list
end
dt.print_error(huginStartCommand)
if coroutine.yield("RUN_COMMAND", huginStartCommand)
then
dt.print("Command hugin failed ...")
end
end
-- Register
dt.register_storage("module_hugin", "Hugin Panorama", show_status, create_panorama)
--
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua