librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

RuntimeError: null pointer passed for argument "frame_ref"

Open KeCh96 opened this issue 8 years ago • 8 comments

Required Info
Camera Model SR300
Firmware Version
Operating System & Version Ubuntu
Kernel Version (Linux Only) 4.15.0
Platform Linux
SDK Version SDK2

I try to read depth image by the following code:

pipeline = rs.pipeline()
pipeline.start()
while True:
    frames = pipeline.wait_for_frames()
    depth  = frames.get_depth_frame()
    depth_data = depth.as_frame().get_data()
    np_image = np.asanyarray(depth_data)

But I run into an error:

Traceback (most recent call last):
  File "demo.py", line 374, in <module>
    depth_data = depth.as_frame().get_data()
RuntimeError: null pointer passed for argument "frame_ref"

Could you please help me? @dorodnic @zivsha @RealSense-Customer-Engineering

KeCh96 avatar Aug 21 '18 05:08 KeCh96

Hello @KeCh96 , The code doesn't check the return value to establish whether the depth frame is valid. Please see the python example reference

ev-mp avatar Aug 21 '18 06:08 ev-mp

Hello, @ev-mp . I tried if not depth: continue, but the error still occurs. Note that even when I plug out the camera, the code also run into RuntimeError: null pointer passed for argument "frame_ref".

KeCh96 avatar Aug 23 '18 08:08 KeCh96

Same here:

while True:
    frames = pipeline.wait_for_frames()
    ir_frame = frames.get_infrared_frame(0)
    if not ir_frame:
        continue
    d = ir_frame.get_data()

drzraf avatar Oct 07 '18 00:10 drzraf

[Realsense Customer Engineering Team Comment] Hi @KeCh96 ,

I can't reproduce this issue. Please try again with new version librealsense.

[Realsense Customer Engineering Team Comment] @KeCh96 Did you get chance to try the latest librealsense? Any good news? Looking forward to your update. Thanks!

Using 2.16.3.316

Code:

pipeline = rs.pipeline()
config = rs.config()
profile = pipeline.start(config)
dev = profile.get_device()
with open("rs.json", "r") as f:
    advnc_mode = rs.rs400_advanced_mode(dev)
    advnc_mode.load_json(f.read())
cv2.namedWindow('RealSense', cv2.WINDOW_AUTOSIZE)
while True:
    frames = pipeline.wait_for_frames()
    ir_frame = frames.get_infrared_frame(0)
    d = ir_frame.get_data()

RuntimeError: null pointer passed for argument "frame_ref"

Config

{
    "aux-param-autoexposure-setpoint": "1536",
    "aux-param-colorcorrection1": "0.298828",
    "aux-param-colorcorrection10": "0",
    "aux-param-colorcorrection11": "0",
    "aux-param-colorcorrection12": "0",
    "aux-param-colorcorrection2": "0.293945",
    "aux-param-colorcorrection3": "0.293945",
    "aux-param-colorcorrection4": "0.114258",
    "aux-param-colorcorrection5": "0",
    "aux-param-colorcorrection6": "0",
    "aux-param-colorcorrection7": "0",
    "aux-param-colorcorrection8": "0",
    "aux-param-colorcorrection9": "0",
    "aux-param-depthclampmax": "65536",
    "aux-param-depthclampmin": "0",
    "aux-param-disparityshift": "0",
    "controls-autoexposure-auto": "False",
    "controls-autoexposure-manual": "32857",
    "controls-color-autoexposure-auto": "False",
    "controls-color-autoexposure-manual": "4978",
    "controls-color-backlight-compensation": "0",
    "controls-color-brightness": "-64",
    "controls-color-contrast": "63",
    "controls-color-gain": "64",
    "controls-color-gamma": "300",
    "controls-color-hue": "0",
    "controls-color-power-line-frequency": "3",
    "controls-color-saturation": "64",
    "controls-color-sharpness": "50",
    "controls-color-white-balance-auto": "False",
    "controls-color-white-balance-manual": "3560",
    "controls-depth-gain": "16",
    "controls-laserpower": "30",
    "controls-laserstate": "on",
    "ignoreSAD": "0",
    "param-autoexposure-setpoint": "1536",
    "param-censusenablereg-udiameter": "9",
    "param-censusenablereg-vdiameter": "9",
    "param-censususize": "9",
    "param-censusvsize": "9",
    "param-depthclampmax": "65536",
    "param-depthclampmin": "0",
    "param-depthunits": "1000",
    "param-disableraucolor": "0",
    "param-disablesadcolor": "0",
    "param-disablesadnormalize": "0",
    "param-disablesloleftcolor": "0",
    "param-disableslorightcolor": "0",
    "param-disparitymode": "0",
    "param-disparityshift": "0",
    "param-lambdaad": "800",
    "param-lambdacensus": "26",
    "param-leftrightthreshold": "24",
    "param-maxscorethreshb": "2047",
    "param-medianthreshold": "500",
    "param-minscorethresha": "1",
    "param-neighborthresh": "7",
    "param-raumine": "1",
    "param-rauminn": "1",
    "param-rauminnssum": "3",
    "param-raumins": "1",
    "param-rauminw": "1",
    "param-rauminwesum": "3",
    "param-regioncolorthresholdb": "0.0499022",
    "param-regioncolorthresholdg": "0.0499022",
    "param-regioncolorthresholdr": "0.0499022",
    "param-regionshrinku": "3",
    "param-regionshrinkv": "1",
    "param-robbinsmonrodecrement": "10",
    "param-robbinsmonroincrement": "10",
    "param-rsmdiffthreshold": "4",
    "param-rsmrauslodiffthreshold": "1",
    "param-rsmremovethreshold": "0.375",
    "param-scanlineedgetaub": "72",
    "param-scanlineedgetaug": "72",
    "param-scanlineedgetaur": "72",
    "param-scanlinep1": "60",
    "param-scanlinep1onediscon": "105",
    "param-scanlinep1twodiscon": "70",
    "param-scanlinep2": "342",
    "param-scanlinep2onediscon": "190",
    "param-scanlinep2twodiscon": "130",
    "param-secondpeakdelta": "325",
    "param-texturecountthresh": "0",
    "param-texturedifferencethresh": "0",
    "param-usersm": "1",
    "param-zunits": "1000",
    "stream-depth-format": "Z16",
    "stream-fps": "30",
    "stream-height": "480",
    "stream-width": "640"
}

drzraf avatar Oct 31 '18 22:10 drzraf

Got it: main problem is that if depth stream is not explicitly enabled, IR is not available.

  • Although configuration is exported from realsense-viewer, is does not enable the emitter.
  • Using various calls to config.enable_stream(rs.stream.*) instead, I was able to use frames.get_infrared_frame(0) and ir_frame.get_data()

Note:

  • The python error is far from clear and it should be thrown sooner. Eg: something like "Unconfigured/unavailable stream" when doing frames.get_infrared_frame(0) would be better.

drzraf avatar Nov 01 '18 00:11 drzraf

[Realsense Customer Engineering Team Comment] Thank you, @drzraf . You are right. @KeCh96, please enable_stream in config object before pipeline.start, and call pipeline.start with param config.