@erik
If I want to study how the disparity cost is computed and also would like to output disparity cost vector (i.e. each pixel will have a vector of 95 cost for it's neighbors), where can I find the source code of the implmentation of the disparity cost formula? Is it possible to change the formula and output disparity cost vector map for debug/development? Thank you very much for your help.

  • erik replied to this.

    Hi ynjiun ,
    That logic is implemented into the firmware (closed source), and you can configure it via API, see StereoDepthConfigs CostMatching api. Would that suffice?
    Thanks, Erik

    Hi @erik
    Thank you for the information. It is very helpful.
    I notice in the doc it mentions "debugDispCostDump". I wonder if that dump contains the information what I am looking for. Could you share an example code to perform debugDispCostDump?
    Thank you.

    • erik replied to this.

      Hi ynjiun , yes, that will output disparity cost dump. Just note it's very (very) slow. We have example here, use -dumpdispcost argument.
      Thanks, Erik

      Hi @erik
      Thanks for the link.
      I tried it and save the disparity_cost_dump.raw.
      But it seems only save one 16-bit cost value for each pixel not 96 byte for each pixel.
      I looked at the code at line 16:
      parser.add_argument('-dumpdispcost', "--dumpdisparitycostvalues", action="store_true", help="Dumps the disparity cost values for each disparity range. 96 byte for each pixel.")
      We should expect to have a dump of 96 cost values for each pixel, is that right?
      What else of option I need to turn on to dump the 96 cost values for each pixel?
      Thanks a lot for your help again.

        GergelySzabolcs

        "You can uncomment this line to get widthheight96 bytes disparity cost dump:
        https://github.com/luxonis/depthai-python/blob/main/examples/StereoDepth/stereo_depth_from_host.py#L605"

        Thank you for the recommendation. Actually I already did that and I examed the disparity_cost_dump.raw only has 1 16-bit integer for each pixel not 96 bytes!
        Any other suggestion to dump 96 bytes of cost values for each pixel?
        Thank you very much for your help.

          ynjiun

          Change the line to:

          image.getData().tofile(name+'.raw')

          in order to save the raw data. It will save a 98304000 byte long file (1280x800x96)

            GergelySzabolcs

            Very nice! It works now.
            One more question: in order to correspond to the image left/right pixel position of resolution 1280x800, (image_left/right.shape => (800,1280) row index first format), what reshape order should I use (800,1280,96)? or (1280,800,96)?

            That is which is correct?
            framedata = image.getData().reshape((800,1280,96))
            or
            framedata = image.getData().reshape((1280,800,96))
            please confirm. Thanks a lot!

            • erik replied to this.

              Hi ynjiun ,
              Depends on whether you want Planar (CHW) or Interleaved (HWC) image representation.
              Thanks, Erik