PDA

View Full Version : [Fuse]Trying to create a Fuse, think Im failing...



TheAdmiral
November 21st, 2011, 09:10 PM
Hey Guys, Im trying to build my first Fuse. I was originally trying to write a script or put together a Marco wasn't really sure how to go about it. Looked around and found info on fuses have found that it will be the best way to go about this? Not quite sure to be honest though. I have been using Fusion in production for 2 years now but haven't had to script at all, so if this is completely ridiculous I apologize in advance :D Bare with me please

I need to create a tool that runs through an image sequence, finds its highest and lowest overall values automatically, then stores them in a variable I can extract for use in normalizing the sequence.

Im not really sure what the best approach is, but this is what I have come up with so far.

The tool needs to take in the GlobalIn and GlobalOut values from the Input. Then normalize that frame range, so that regardless of the sequence range you always have a time at 0.

the tool then checks the time value to see if it is the first frame of the sequence, if it is, then it stores the current highest value in which ever channel you use. If it isnt the first frame then it stores the high value in X.

It compares X to the highest value it has found, stored above, and replaces if needed, or moves on.

It does the same process with the lowest values. (preferably simultaneously)

Finally it displays the highest and lowest values read-only.

Now I do not know anything about lua, so Im basing alot of what I am doing on VEX, PRman, and other fun stuff. Its probably ugly and Im not sure the variables work yet. I am still sifting through the Eyeon docs to get the syntax right aswell, but I wanted to post what I have so far to get any feedback, hate mail, or help available :D Im attaching the .fuse that I have put together. TIA!

(Doesnt allow .fuse, so just change it after dl)

12765

pingking
November 22nd, 2011, 03:21 PM
cant see your attached file here, but a good way to start is to look at the fuses at vfxpedia, from there you can get a lot of stuff which isnt so clear in the docs

for your idea: i'm not sure if a fuse can evalute another frame in time, but if this is possible then there is no problem in finding the highest and lowest pixelvalue and store that

TheAdmiral
November 22nd, 2011, 03:56 PM
Hi pingking, thanks for the response. Ive been looking through those files and they have definitely helped alot! this is what i have so far (i hope inline isnt frowned upon?)


--[[-- This Fuse is my first attempt to create a High/Low Probe stand alone Fuse in Fusion
--]]--

FuRegisterClass("HighLowProbe", CT_Tool, {
REGS_Name = "High Low Probe Tool",
REGS_Category = "Fuses\\eyeon",
REGS_OpIconString = "Prb",
REGS_OpDescription = "This tool searches a image sequence and returns the highest and lowest values in the red channel.",
REG_NoAutoProxy = true,
REG_OpNoMask = true,
REG_NoBlendCtrls = true,
REG_NoMotionBlurCtrls = true,})

function Create()
InImage = self:AddInput("Input", "Input", {
LINKID_DataType = "Image",
LINK_Main = 1,
})
InChannel = self:AddInput("Channel", "Channel", {
LINKID_DataType = "Number",
INPID_InputControl = "MultiButtonControl",
INP_Default = 0.0,
{ MBTNC_AddButton = "Red", MBTNCD_ButtonWidth = 1/5, },
{ MBTNC_AddButton = "Green", MBTNCD_ButtonWidth = 1/5, },
{ MBTNC_AddButton = "Blue", MBTNCD_ButtonWidth = 1/5, },
{ MBTNC_AddButton = "Alpha", MBTNCD_ButtonWidth = 1/5, },
{ MBTNC_AddButton = "Luma", MBTNCD_ButtonWidth = 1/5, },
INP_Integer = true,
})
InExecute = self:AddInput("Execute", "Execute", {
LINKID_DataType = "Number",
INPID_InputControl = "ButtonControl",
INP_Default = 1.0,
{ MBTNC_AddButton = "Execute", MBTNCD_ButtonWidth = 1/3, },
INP_Integer = true,
})
InLowV = self:AddInput("Low Value", "LowValue", {
LINKID_DataType = "Number",
INPID_InputControl = "RangeControl",
INP_Default = 0.0,
IC_ControlGroup = 2,
IC_ControlID = 0,
})
InHighV = self:AddInput("High Value", "HighValue", {
LINKID_DataType = "Number",
INPID_InputControl = "RangeControl",
INP_Default = 1.0,
IC_ControlGroup = 2,
IC_ControlID = 1,
})
OutImage = self:AddOutput("Output", "Output", {
LINKID_DataType = "Image",
LINK_Main = 1,
})
end

function Process(req)

--channel picker
local tChan = InImage.R
-- 0 = red
-- 1 = green
-- 2 = blue
-- 3 = alpha
-- 4 = luma
if channel == 0 then
tChan = InImage.Red
elseif channel == 1 then
tChan = InImage.Green
elseif channel == 2 then
tChan = InImage.Blue
elseif channel == 3 then
tChan = InImage.Alpha
elseif channel == 4 then
tChan = InImage.L
end


local F1 = InImage:GetValue(req).GlobalIn
local F2 = InImage:GetValue(req).GlobalOut
local TIME = (time/(F2-F1))
local HighF = tChan.High
local HighV = 0
local x = 0
local LowF = tChan.Low
local LowV = 0
local y = 0
local i = 0

if execute == 0 then
for i = F1, F2, 1 do
--setting value at first frame as default high value, and storing other values in x
if TIME == 0 then
HighF = HighV
else
HighF = x
--comparing x to the high value thus far
if x > HighV then
x = HighV
else
HighV = HighV
end
end

--setting value at first frame as default low value, and storing other values in y
if TIME == 0 then
LowF = LowV
else
LowF = y
--comparing y to the low value thus far
if y > LowV then
y = LowV
else
LowV = LowV
end
end


end
end

local img = InImage:GetValue(req)
img:Use()

OutImage:Set(req, img)

Like i said in my earlier post, I have no real experience in lua, so im looking things up, copying so reference, and in some cases making things up as i go along haha

Im trying to run a for loop in order to run through the sequence, as of right now fusionj is telling me that F1 and F2 are not pulling the globalIn and globalOut variables correctly, so calculating my frames is impossible... im trying to find out how to get that variable now. but everything else seems to load into fusion fine... its problem now is doing anything haha

Next up is to see if my for loop does anything, then onto how to call the luma channel, how to display the high and low info or store in a variable (preferably in the high and low value inputs i created making them uneditable?), and finally see if any part of all of this works haha

Thanks again though!!