View my account

Inconsistent frames

Comments

10 comments

  • MartyG

    It is not unusual to get different frame counts from different approaches to reading a bag.

    If Python is your preference, playing back the frames with real-time set to false may give more consistent results.

    https://github.com/IntelRealSense/librealsense/issues/4840 

    0
    Comment actions Permalink
  • 1106569356

    I've set this up, but it's still quite different.And, when I extracted only some of the frames, I found that they were identical.

    This is the number of frames you see in matlab.

    The results above are consistent with those obtained using rs-convert.exe.Using wait_for_frames() in python, however, results in very different frames.

    0
    Comment actions Permalink
  • MartyG

    Trying to select exact frame numbers from a bag can be awkward.  For example, if you wanted to browse forward and back through frame numbers like watching a video, the recommended solution for rewinding to an earlier frame is to reset to the first frame and then skip ahead to the frame number that you want.

    Instead of trying to select  a batch of frame numbers, you may get better results if you use ROS' rosbag editing tool to pick out the batch frames you want by setting a start and end point, and save them as a new, smaller bag file.

    https://github.com/IntelRealSense/librealsense/issues/4764#issuecomment-526466915 

    0
    Comment actions Permalink
  • 1106569356

    What I've done is I've looped from the first frame to the frame I want, which I think is the right thing to do.But the results were not satisfactory.

    Here's part of my loop.

    while (playback.current_status() == rs.playback_status.playing) :
    n += 1
    print n
    x = np.zeros((848*480,1))
    y = np.zeros((848*480,1))
    frames = pipe.wait_for_frames()
    if (n > start_num-1) and (n < (end_num+1)):
    m +=1
    depth_frame = frames.get_depth_frame()
    color_frame = frames.get_color_frame()
     *******

    0
    Comment actions Permalink
  • MartyG

    The GitHub is the best place for this particular question, and I see that you have already posted it there.

    Looking at your code though, my thoughts are:

    -  Have you defined the values of start_num and end_num, so that they are not both '0' by default?  

    -  I would remove the n += 1 statement in your While loop, and have it in the If loop.   This should ensure that it only increments by 1 every time the If loop is checked, if n is not currently smaller than the start value or larger than the end value.   If you have the n statement true when playback is active, it gives the potential for n to increment uncontrollably.

    -  If Librealsense supports the notation, it may be tidier to use 'less than or equal' and 'greater than or equal':

    if (n >= start_num) and (n <= (end_num)):

     

     

    0
    Comment actions Permalink
  • 1106569356

    Sorry, I only put part of the statement, The values of start_num and end_num are set by me. M is the number of frames in the if statement.N is used to record all the frames of the bag file. What I want to do is process the frames when n is between start_num and end_num, that is, when wait_for_frames reach the one I need.

    0
    Comment actions Permalink
  • MartyG

    As I said, the GitHub may be the best place to get a solution for this.  If I were writing it myself though, I would consider moving the wait_for_frames line outside of the while loop, so that it was on the line below the pipe.start() instruction in your script.  'n' is not going to increment unless playing is true anyway.

    0
    Comment actions Permalink
  • 1106569356

    Thanks for your prompt reply and help. I will try it first and ask for help under github.

    0
    Comment actions Permalink
  • 1106569356

    I can see from the timestamp and image sequence that there are many identical frames using wait_for_frames(). What should I do about this?

    0
    Comment actions Permalink
  • MartyG

    I see that Dorodnic the RealSense SDK Manager has responded to your GitHub question.  I recommend asking about it there.  Thanks!

    0
    Comment actions Permalink

Please sign in to leave a comment.