Jump to: Board index » General » Fusion

Auto Cropping

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

Saso Bogdanov

  • Posts: 15
  • Joined: Fri Sep 04, 2015 9:54 am
  • Location: Ljubljana, Slovenia

Auto Cropping

PostTue Nov 24, 2015 2:45 pm

In Crop tool, there is "Auto cropping" tab which does exactly what i want.
I just want to do that for every frame (cause result is different every frame).
Does anybody know expression for X, Y offset and X, Y size?

ASAP solution would be appreciated... Thank you
Offline
User avatar

Rony Soussan

  • Posts: 727
  • Joined: Tue Nov 11, 2014 5:33 pm

Re: Auto Cropping

PostTue Nov 24, 2015 5:33 pm

modify x and y with expression linked to the input size of your clip

right click on x and select expression
type the following
source.Input.Height / Width

replace source with the name of your node
Offline
User avatar

Chad Capeland

  • Posts: 3025
  • Joined: Mon Nov 10, 2014 9:40 pm

Re: Auto Cropping

PostTue Nov 24, 2015 7:34 pm

Rony Soussan wrote:modify x and y with expression linked to the input size of your clip

right click on x and select expression
type the following
source.Input.Height / Width

replace source with the name of your node


That won't crop the same as Auto Crop, which finds the first and last row and column with pixels that are not the same as the canvas color.

An easy way to do this is to use the AutoDomain tool, then read in the modified DataWindow table in the Crop tool:

Code: Select all
Inputs = {
   XOffset = Input {
     Expression = "Input.DataWindow[1]",
   },
   YOffset = Input {
     Expression = "Input.DataWindow[2]",
        },
   XSize = Input {
     Expression = "Input.DataWindow[3]-Input.DataWindow[1]",
   },
   YSize = Input {
          Expression = "Input.DataWindow[4]-Input.DataWindow[2]",
   },
     },
Chad Capeland
Indicated, LLC
www.floweffects.com
Offline

Saso Bogdanov

  • Posts: 15
  • Joined: Fri Sep 04, 2015 9:54 am
  • Location: Ljubljana, Slovenia

Re: Auto Cropping

PostWed Nov 25, 2015 9:48 am

@chad
Is there a possibilty you make simple comp and paste code here?
Cause i'm not sure how to implement everything you wrote. Doing only what you described does... Well, nothing :)

thank you
Offline
User avatar

Philipp Walz

  • Posts: 371
  • Joined: Fri Apr 25, 2014 12:41 pm
  • Location: Borkwalde - Germany

Re: Auto Cropping

PostFri Jun 29, 2018 3:54 pm

I would like to know it too please :-)
Pete
Offline

Hector Corcin

  • Posts: 155
  • Joined: Sun Aug 23, 2015 8:38 pm

Re: Auto Cropping

PostSun Oct 18, 2020 2:44 pm

I wonder if it is possible with some script in the crop node to get the maximum values from the AutoDomain values. Then we could just play all the frames get those maximum numbers and set the values to the crop tool to get a fixed minimum crop needed for the clip.
Offline
User avatar

Philipp Walz

  • Posts: 371
  • Joined: Fri Apr 25, 2014 12:41 pm
  • Location: Borkwalde - Germany

Re: Auto Cropping

PostThu Dec 03, 2020 10:27 pm

Any ideas?
Pete
Offline

Steffen Dünner

  • Posts: 31
  • Joined: Thu Nov 13, 2014 10:28 am

Re: Auto Cropping

PostThu Jan 25, 2024 1:46 pm

OK, now that I needed Auto Cropping I found out how to use the expressions.

Just copy and paste the code below in your Fusion flow. It'll add an "AutoDomain" node and a "Crop" node with the necessary expressions already in place.

Code: Select all
{
   Tools = ordered() {
      AutoDomain1 = AutoDomain {
         ViewInfo = OperatorInfo { Pos = { 715, 181.5 } },
      },
      Crop1 = Crop {
         Inputs = {
            XOffset = Input {
               Value = 896,
               Expression = "self.Input.DataWindow[1]",
            },
            YOffset = Input {
               Value = 829,
               Expression = "self.Input.DataWindow[2]",
            },
            XSize = Input {
               Value = 136,
               Expression = "self.Input.DataWindow[3]-self.Input.DataWindow[1]",
            },
            YSize = Input {
               Value = 140,
               Expression = "self.Input.DataWindow[4]-self.Input.DataWindow[2]",
            },
            Input = Input {
               SourceOp = "AutoDomain1",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 715, 214.5 } },
      }
   }
}


I hope this helps. Important note: There was a change in Fusion's expression syntax that requires to put "self." in front of the "Input.DataWindow". So the expression that was posted in 2015 no longer works.
Offline
User avatar

AlexYez

  • Posts: 65
  • Joined: Tue Apr 21, 2020 5:20 pm
  • Location: Planet Earth
  • Real Name: Alexander Ezhov

Re: Auto Cropping

PostMon Feb 05, 2024 9:24 pm

Steffen Dünner wrote:OK, now that I needed Auto Cropping I found out how to use the expressions.

Just copy and paste the code below in your Fusion flow. It'll add an "AutoDomain" node and a "Crop" node with the necessary expressions already in place.

Code: Select all
{
   Tools = ordered() {
      AutoDomain1 = AutoDomain {
         ViewInfo = OperatorInfo { Pos = { 715, 181.5 } },
      },
      Crop1 = Crop {
         Inputs = {
            XOffset = Input {
               Value = 896,
               Expression = "self.Input.DataWindow[1]",
            },
            YOffset = Input {
               Value = 829,
               Expression = "self.Input.DataWindow[2]",
            },
            XSize = Input {
               Value = 136,
               Expression = "self.Input.DataWindow[3]-self.Input.DataWindow[1]",
            },
            YSize = Input {
               Value = 140,
               Expression = "self.Input.DataWindow[4]-self.Input.DataWindow[2]",
            },
            Input = Input {
               SourceOp = "AutoDomain1",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 715, 214.5 } },
      }
   }
}


I hope this helps. Important note: There was a change in Fusion's expression syntax that requires to put "self." in front of the "Input.DataWindow". So the expression that was posted in 2015 no longer works.


Chad and Steffen, thank you so much, this very helpful!
Alexander Ezhov,
Compositing Artist, Davinci Resolve Certified Trainer

Return to Fusion

Who is online

Users browsing this forum: No registered users and 61 guests