Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8044873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:22:07+00:00 2026-06-05T05:22:07+00:00

G’ Morning SO- I’m trying to move some bounding boxes on a video. I’m

  • 0

G’ Morning SO-

I’m trying to move some bounding boxes on a video. I’m at sort of a sticking point . If I’ve got a frame on a data file every 15 frames, then I have to create 14 frames in between each real one. Since it’s a tool (actually part of an ffmpeg plugin), it needs to work for any gap size.

I’ve written a function that takes the distance between two points, and how many frames it has to smoothly transition from the beginning point to ending point. What this function would ideally return is an array of how many pixels to shift from the preceding frame

For example if x at frame 1 was 50, and at frame 16 was 65, then I would have an array of all ones so that each frame would add one to the frame before. Here’s what I’ve got so far:

int* generateSequence(int difference, int numStep){
  int* sequence = (int*)malloc(sizeof(int*)*numStep);
  int i;
  for(i=0; i<numStep; i++){ 
    sequence[i] = 0;
  }
  while(difference > numStep){
    for(i=0; i<numStep; i++){ 
      sequence[i]++;
    }
    difference -= numStep;
  }

I’m satisfied with this part, (which would add one to EACH frame in between for every multiple of the distance between the two over the number of frames in between).

But now I’m getting to the point where I would need to add one to SOME frames but not all. All I’ve got is these jury rigged algorithms that aren’t very portable for a tool that produces different frame distances…

double delta = difference/numStep;
if(delta >=.05 && delta< .20){
  for(i=0; i<numStep; i+=6){ 
    sequence[i]++;
  }
}

Should I be using a modulus operator or maybe approaching it differently? Hard coding in what seem like arbitrary values doesn’t sit too well with me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:22:09+00:00Added an answer on June 5, 2026 at 5:22 am

    More generally, it sounds like you want to generate the “smoothest” series of x integers whose sum is y. (Smoothness is minimal average distance between elements in the series.)

    This can be achieved with the following algorithm.

    given sum and steps
    float step = sum/steps
    float delta = 0
    sequence = []
    for x:
        int integerstep = round(step + delta)
        delta += step - integerstep
        sequence.push(round(integerstep))
    

    An example implementation in python (sorry, not a c person) can be found below.

    def renderSmoothIntegerSequence(steps, distance):
        step = float(distance)/steps
        delta = 0
        sequence = []
        for _ in xrange(steps):
            integerstep = int(round(step + delta))
            delta += step - integerstep
            sequence.append(integerstep)
        return sequence
    

    Example invocations:

    >>> print renderSmoothIntegerSequence(5,8)
    [2, 1, 2, 1, 2]
    >>> print renderSmoothIntegerSequence(5,7)
    [1, 2, 1, 2, 1]
    >>> print renderSmoothIntegerSequence(32,1)
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    >>> print renderSmoothIntegerSequence(1,50)
    [50]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
I want to construct a data frame in an Rcpp function, but when I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.