Giter VIP home page Giter VIP logo

Comments (4)

bruno-darochac avatar bruno-darochac commented on July 18, 2024 1

Thanks for your answer as always ! :D

I've already tried with a rectangle as your solution describe, and it was the same. It's I in my code I removed it to try without.
But I found a way more logical two calculate the exact distance between two point without using SpatialLocationCalculator.

So I'll continue with that instead of troubleshooting my problem.

from depthai_blazepose.

geaxgx avatar geaxgx commented on July 18, 2024

Is your code visible somewhere so that I can have a look ?

from depthai_blazepose.

bruno-darochac avatar bruno-darochac commented on July 18, 2024

I can put the add I've made in your library here :

In create_pipeline I've add :

            xoutSpatialData = pipeline.create(dai.node.XLinkOut)
            xinSpatialCalcConfig = pipeline.create(dai.node.XLinkIn)
            xoutSpatialData.setStreamName("spatialData")
            xinSpatialCalcConfig.setStreamName("spatialCalcConfig")

            spatial_location_calculator.out.link(xoutSpatialData.input)
            xinSpatialCalcConfig.out.link(spatial_location_calculator.inputConfig)
            stereo.depth.link(spatial_location_calculator.inputDepth)

Then I've created two queue

            self.q_spatial_calc = self.device.getOutputQueue(name="spatialData", maxSize=4, blocking=False)
            self.q_spatial_conf = self.device.getInputQueue("spatialCalcConfig")

And then create this function :

    def roi_data(self, point):
        top_left = dai.Point2f(point[0], point[1])
        bottom_right = dai.Point2f(point[0], point[1])

        config = dai.SpatialLocationCalculatorConfigData()
        config.depthThresholds.lowerThreshold = 100
        config.depthThresholds.upperThreshold = 10000
        config.roi = dai.Rect(top_left, bottom_right)
        config.calculationAlgorithm = dai.SpatialLocationCalculatorAlgorithm.AVERAGE
        cfg = dai.SpatialLocationCalculatorConfig()
        cfg.addROI(config)
        self.q_spatial_conf.send(cfg)

        spatial_data = self.q_spatial_calc.get().getSpatialLocations()
        xyz = spatial_data[0].spatialCoordinates
        return [float(xyz.x), float(xyz.y), float(xyz.z)]

        # for depth_data in spatial_data:
        #     return [depth_data.spatialCoordinates.x,
        #             depth_data.spatialCoordinates.y,
        #             depth_data.spatialCoordinates.z]

And that's the output of roi_data that give me the point printed in the first comment. And I observe too that sometimes he blocked all x y and z value at 0.0

from depthai_blazepose.

geaxgx avatar geaxgx commented on July 18, 2024

Your top_left is the same as bottom_right. I am not sure how the SpatialLocationCalculator behaves in that case, but usually we use a square zone, something like:

top_left = dai.Point2f(point[0]-d, point[1]-d)
bottom_right = dai.Point2f(point[0]+d, point[1]+d)

And d is chosen such that the square zone belongs only to the object (here the body part) we are interested in. If the zone is a mix of body pixels and background pixels and you use the AVERAGE algorithm, the z will probably be not accurate. So you don't want the zone to be too large.

Yet I don't think that explains the wrong x and y you observe. I can't see other problem in the code you shared. Without seeing the whole code, I can't say more.

from depthai_blazepose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.