Distance detection with Depth Camera (Intel Realsense d435i) - Opencv with Python tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 มี.ค. 2021
  • source code and files: pysource.com/2021/03/11/dista...
    In this video tutorial, we will see how to detect the distance using the Intel Realsense d435I camera.
    The tutorial will be divided in two steps:
    1. Get the frames from the depth camera
    2. Distance detection on mouseover
    ➤ Full Video courses:
    Object Detection: pysource.com/object-detection...
    ➤ Follow me on:
    Instagram: / pysource7
    LinkedIn: / pysource
    ➤ For business inquiries:
    pysource.com/contact
    #opencv #intelrealsense #depthcamera
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 122

  • @nguyenmanhtuan629
    @nguyenmanhtuan629 3 ปีที่แล้ว +4

    A great video. Hope to see your tutorials on how to work with point cloud from Depth Camera.

  • @MrSri331
    @MrSri331 2 ปีที่แล้ว

    Thanks for the video.
    Does it work accurately on night or with out light?
    And curious if it works underwater?

  • @omerfarukpaker7551
    @omerfarukpaker7551 ปีที่แล้ว

    Thanks ever so much! This tutorial was eye opening for me! :)

  • @YazeedAlkosai
    @YazeedAlkosai 2 ปีที่แล้ว

    great video, how to measure the depth of the holes of the objects is it possible to use this camera to get precise holes diameter. thanks in advance

  • @mediocre7520
    @mediocre7520 3 ปีที่แล้ว +4

    Could you please explain about the IMU in the intel realsense?
    How to get the values using python? How to calibrate the IMU?

  • @mk-xx1vj
    @mk-xx1vj 2 ปีที่แล้ว

    Hi dear Sergio, Firstly tank you for everything. Can we measure the width and height of these objects at the same time?

  • @user-mh8kb5ng9f
    @user-mh8kb5ng9f 4 หลายเดือนก่อน

    I get it succeed by following this video you presented, it is super helpful. Thanks a lot !:)

  • @roberttom6849
    @roberttom6849 3 ปีที่แล้ว

    A great tutorial. Thanks.

  • @samchang4555
    @samchang4555 3 ปีที่แล้ว

    Can I know why after apply a color map for the depth frame the depth shown is in array mode?

  • @MyOkman
    @MyOkman 2 ปีที่แล้ว +1

    man, you are awesome !

  • @maxbretschneider6521
    @maxbretschneider6521 2 ปีที่แล้ว

    Great video, thanks a lot!

  • @abderrahmenmelliti9627
    @abderrahmenmelliti9627 2 ปีที่แล้ว

    So normally we don't need to do a calibration right?
    what if I want to detect the Aruco code using this camera which normally requires a file created after doing the calibration what i should do? do you have an idea about that? and thank you

  • @godataprof
    @godataprof 2 ปีที่แล้ว

    How did you install the pyrealsense? Am having issues on my MacBook. Thanks.

  • @YigalBZ
    @YigalBZ 3 ปีที่แล้ว +1

    Good and clear video, as always. Thank you. I assume Raspberry pi will be too slow for that, right? I am looking into object detection and distance analysis of that object with RPI. What would you think? Do you plan on any video on that direction?

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว +1

      Hi, this is mostly a product which is used for commercial projects.
      - Raspberry pi is in generally too slow for object detection in real time even withouth distance analysis.
      - The distance analysis itself doesn't require much computational power, so this camera on the raspberry pi with the same script of this video, without object deteciton will perform well.
      I'll suggest that you look into the Opencv AI kit which fits better your purpose. I've a video about it , I recommend to watch that one th-cam.com/video/HHJDXE0VcAY/w-d-xo.html

    • @YigalBZ
      @YigalBZ 3 ปีที่แล้ว

      @@pysource-com Currently I get 2.9 fps with tensorflow lite on RPI 4, with general set of objects to detect. I wonder what will be the change if I have only one object to detect (yes or no). I would need 10 fps at least. Perhaps I should dedicate old laptop for that target, instead of RPI, or even consider dedicated HW. I know there are several on market, including USB accelerators for PI.

  • @purushottamarao1209
    @purushottamarao1209 2 ปีที่แล้ว +1

    Nice video. When I am trying to initialize the camera using Depthcamera(), I am getting an error "RuntimeError: No device connected". Could u plz help in this?. Thanks in advance

  • @autonomousselfdrivingnonco8334
    @autonomousselfdrivingnonco8334 3 ปีที่แล้ว

    Thats awesome...what can be done if we want to detect object and create bounding box using intel camera...can u share insights

  • @saijasijsauiassiaj
    @saijasijsauiassiaj ปีที่แล้ว

    Hi Sergio!
    What is the best camera for computer vision, with a price of up to 1000 dollars?

  • @hamzaghnaim548
    @hamzaghnaim548 3 ปีที่แล้ว +2

    hello there Sergio, I'm a fan of your tutorials and I have used many of them in my university project, I have a question, can I actually apply the same code you implemented in this video on my laptop's webcam ?, if not, what changes may I perform to get the work done, and I'll be thankful if you helped me with a method of getting the X and Y coordinates of a tracked object, Thank you sir

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว +1

      Hi, this tutorial is specifically for Depth Camera intel realsense d435i, so it won't work with a normal webcam.

    • @srishti-ai
      @srishti-ai 2 ปีที่แล้ว

      @@pysource-com Can you make a tutorial on how to use laptop's webcam to do stereo vision projects?

    • @pysource-com
      @pysource-com  2 ปีที่แล้ว

      @@srishti-ai It's not possible to do this with laptop webcams as they don't provide depth information.

  • @xinwenzhang4150
    @xinwenzhang4150 2 ปีที่แล้ว

    thanks! A nice video!

  • @bharathgm2572
    @bharathgm2572 3 ปีที่แล้ว +1

    can you please explain how to find distance from Depth images

  • @cy5018
    @cy5018 3 ปีที่แล้ว

    Pretty awesome sir. Could u please make a tutorial to show how to measure the depth of a crack using stereo-vision? Thank you in advance.

  • @haseebahmed1726
    @haseebahmed1726 2 ปีที่แล้ว

    Hi, do you know how to connect 2 intel realsense cameras with open cv?

  • @nhatpham5797
    @nhatpham5797 6 หลายเดือนก่อน

    Hello, can I use this camera with YOLOv8?

  • @MikeNewham
    @MikeNewham 3 ปีที่แล้ว +1

    Great tuition. Good command of English.. Have Pixy2 camera here - so am on the lookout for scripts for that..

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว +1

      Thank you for the feedback.
      Unfortunately I don't have any experience with the Pixy camera, and at the moment it's not part of my plans to make any script for that.

  • @dafech_911
    @dafech_911 11 วันที่ผ่านมา

    Hi Sergio. Thank you for your video. I have a question for you. Currently I don't have acces to the camera, but would be the case if we go out of the 2 meters value? Which value would I get? The maximum value, a random distance, 0, null-value?
    Also I wanted to remark the the link that you provided for the codes is no longer available.
    Thank you again for your great job explaining this.

  • @aymenbenammar1292
    @aymenbenammar1292 ปีที่แล้ว

    Impressive work! can I use my phone's camera as depth camera ?

  • @DilipKumar-dc2rx
    @DilipKumar-dc2rx ปีที่แล้ว

    Does it mean we can use Realsense camera instead of Radar/Lidar for Self Driving Car?

  • @r.iyushofficial5318
    @r.iyushofficial5318 3 ปีที่แล้ว +2

    Awesome

  • @shahonwre5604
    @shahonwre5604 2 ปีที่แล้ว

    kinect v2(one) have error 2cm in his depth accuracy and how much many error on his camera ?

  • @granatapfel6661
    @granatapfel6661 11 หลายเดือนก่อน

    Combined with a bounding box it's a powerful detection with class and distance

  • @payman_azari
    @payman_azari 2 ปีที่แล้ว

    Does any one knows what is the depth resolution of the Realsense Cams in millimeters? (I need it to precisely scan face and ears)

  • @RacecarJ0hnny
    @RacecarJ0hnny ปีที่แล้ว

    Does this work outside for greater distances?

  • @LoFi_Beatz6
    @LoFi_Beatz6 ปีที่แล้ว

    can we apply the algorithm on an image

  • @christopherpalazzo9788
    @christopherpalazzo9788 3 ปีที่แล้ว +2

    This is great, but arent the depth and RGB image not aligned. Won't this will lead to incorrect readings? Thanks!

    • @nghiaducduong
      @nghiaducduong 3 หลายเดือนก่อน

      Have you found solution for this

  • @camdennagg6419
    @camdennagg6419 2 ปีที่แล้ว

    I am trying this on a raspberry pi 4. After doing all of the setup...i get an error while attempting to run the downloaded program
    "AttributeError: module 'pyrealsense2' has no attribute 'pipeline'"
    Any ideas on how to fix this?

  • @Sony-wq4hs
    @Sony-wq4hs 2 ปีที่แล้ว

    We can know asic temperature for depth images

  • @AkshajMusic
    @AkshajMusic ปีที่แล้ว +1

    How can I access my camera through Pycharm?

  • @jazzysehgal7543
    @jazzysehgal7543 ปีที่แล้ว

    Hello,
    import realsense_depth import *
    This import don't work even though the pyrealsense2 had been installed successfuly on my linux 18.04 OS image PC
    Also, I am trying to use this camera with a CNC based pipetting robot. A CNC machine is utilized in Manufacturing robot where it understands G-cordinates (X, Y, Z) . The robot is fully controlled in Python environment. I can manually send G-coordinates to the robot. But, How can I use this camera to have object recognition and the robot goes to that object? Please help

  • @N_Yayan_S
    @N_Yayan_S 3 ปีที่แล้ว

    Awesome broo, tq

  • @quentinjames981
    @quentinjames981 3 ปีที่แล้ว +4

    More about filtering for more accurate readings please!

    • @westparezal
      @westparezal 3 ปีที่แล้ว +1

      use Mean of a function and threshold

  • @ycdcherokee
    @ycdcherokee 3 ปีที่แล้ว +7

    you should better normalize the depth image between 0-255 for a better vision.

  • @ahmetpehlivan5494
    @ahmetpehlivan5494 2 ปีที่แล้ว

    so get_depth_frame() method returns distances 🤔

  • @antonpomboamarelle3430
    @antonpomboamarelle3430 3 ปีที่แล้ว +1

    Hi Sergio, I'm getting in a few problems that I can not solve. Every time I run the code I get these messages, "NameError:name 'DepthCamera' is not defined" and the other one "AttributeError: module 'pyrealsense2' has no attribute 'pipeline'. I downloaded the source code and files before this and also I'm in the Realsense_Depth folder with python, I re-checked the code but I don't know what is wrong.
    Please I will appreciate any help.

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว

      you should install correctly the pyrealsense2 module released by intel.
      Unfortunately I noticed that not on all systems the installation is easy, especially on raspberry/jetson

  • @panosgaras7544
    @panosgaras7544 3 ปีที่แล้ว

    how to programm the apple harvester woth open cv

  • @335LINZ
    @335LINZ 2 ปีที่แล้ว +1

    @ 12:46 to "filter" out zeros i added >> if distance == 0: continue

  • @84mchel
    @84mchel 3 ปีที่แล้ว

    awesome vid! are there ways with this code to make a collison avoidance version?

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว +1

      This code is pretty basic for collison avoidance, you will need to integrate it with object detection, and depth tracking of each single object on the 3d space

  • @weistrass
    @weistrass 8 หลายเดือนก่อน

    What about the distance between two given points?

  • @vighneshnkp6866
    @vighneshnkp6866 2 ปีที่แล้ว

    Hi. Is it possible to determine the distance of an object from the camera in 3 Dimensions? Like the objects real time x,y and z coordinates? Could you do a video on that or send me any material to get started? Thanks.

    • @CamilaDiCarvalho
      @CamilaDiCarvalho ปีที่แล้ว

      Hi, did you manage to?

    • @vighneshnkp6866
      @vighneshnkp6866 ปีที่แล้ว

      @@CamilaDiCarvalho Hi. Yes I did. Not the most accurate but it solved my then problem statement.

  • @Kupgnd
    @Kupgnd 11 หลายเดือนก่อน

    Can you please help?
    I don't have any errors, but PyCharm does not open the camera.

  • @onlaynstudy8811
    @onlaynstudy8811 2 ปีที่แล้ว

    thank you. In the next video please show detect fire //

  • @wezzzzzzzz
    @wezzzzzzzz 3 ปีที่แล้ว +1

    that's really helpful Sergio, Can you advise me on how to get the X and Y coordinates as well? :)

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว

      X and Y coordinates are there already, stored on the variable point.
      x = point[0]
      y = point[1]
      and if you want to display them in realtime:
      cv2.putText(color_frame, "x: {}, y:{}".format(point[0], point[1]), (point[0], point[1] - 45), cv2.FONT_HERSHEY_PLAIN, 2, (0, 0, 0), 2)

    • @wezzzzzzzz
      @wezzzzzzzz 3 ปีที่แล้ว

      @@pysource-com These X and Y are concerned with the streamed fames' pixels, not with the real distance in X and Y axes with respect to the camera origin (which is shown in the realsense viewer)

  • @mohsen_azimi
    @mohsen_azimi 2 ปีที่แล้ว +2

    Thank you, I tried your method; it seems that we need to scale the depth. I tried this piece of code and compared it with RealSense Viewer:
    depth_scale = depth_sensor.get_depth_scale()
    then,
    distance = depth_image[point[1], point[0]] * depth_scale * 1000

    • @ghostriley22
      @ghostriley22 2 ปีที่แล้ว +1

      Yes this is required for correct distance in m
      Also realsense api comes with a function:
      zDepth = depth_frame.get_distance(int(x),int(y))

  • @somusundram1823
    @somusundram1823 3 ปีที่แล้ว

    Good one bro. Hope to see finding size of an object via depth tutorial.
    This is good one but i didn't see any calibration made.

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว

      Thanks for your feedback.
      A project about object measurement is already on my plans and it will come in the near future

    • @hadizanddizari3921
      @hadizanddizari3921 2 ปีที่แล้ว

      @@pysource-com Thanks, have you done this project?

  • @i1r9e9n7e
    @i1r9e9n7e 2 ปีที่แล้ว

    Hi! I was using Thonny to code with python, but i really liked your interface, can you please drop the software?

  • @giorcks8416
    @giorcks8416 วันที่ผ่านมา

    i think you shoudl have aligned the depth information with the RGB camera

  • @kAlqamaRao
    @kAlqamaRao 3 ปีที่แล้ว +1

    can you please tell something about the accuracy? how accurate are the results? I want accuracy at mm level, an error of 0.01 mm can be ignored, but more than that would be harmful, can you please recommend any sensor which will give accuracy of this level

    • @shahonwre5604
      @shahonwre5604 2 ปีที่แล้ว

      me too i want that

    • @kAlqamaRao
      @kAlqamaRao 2 ปีที่แล้ว +1

      @@shahonwre5604 there's a lot of noise in the depth given by Intel depth cameras, I would recommend azure Kinect depth camera here's a comparison between the two
      th-cam.com/video/V2nimk44gQk/w-d-xo.html comparison

    • @shahonwre5604
      @shahonwre5604 2 ปีที่แล้ว

      @@kAlqamaRao
      bro can you give me your email i have something i want talk about that with you

  • @keyurborad8550
    @keyurborad8550 2 ปีที่แล้ว

    RuntimeError Traceback (most recent call last)
    in
    65 while True:
    66 # Get frameset of color and depth
    ---> 67 frames = pipeline.wait_for_frames()
    68 # frames.get_depth_frame() is a 640x360 depth image
    69
    RuntimeError: Frame didn't arrive within 5000
    how to resolve this error?

  • @asdfds6752
    @asdfds6752 3 ปีที่แล้ว

    Sergio, how do you install pyrealsense2 with pip???? I always get an error "ERROR: Could not find a version that satisfies the requirement pyrealsense2 (from versions: none)
    ERROR: No matching distribution found for pyrealsense2". This on Windows, but similar errors in all the platform I have ever used, e.g. Jetson Nano etc

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว

      HI, the installation with pip works well on windows, at least I tried it with python 3.7, while it might not work for all the versions.
      I've used realsense with Jetson nano and raspberry pi as well, and for them the installation with pip doesn't work, but it's necessary to compile the library from scratch (as raspberry and jetson have an arm cpu, and there are no compiled versions for them).
      i might do a video tutorial about it in the future

    • @asdfds6752
      @asdfds6752 3 ปีที่แล้ว

      @@pysource-com Hi, i have been trying to follow most tutorials online describing how to compile that library on raspberry and jetson, but without success.
      A step by step guide by You would be wonderful!!!

    • @asdfds6752
      @asdfds6752 3 ปีที่แล้ว

      @@pysource-com comunque ci tengo a dirti che sei un grandissimo!!! Grazie mille per il tuo lavoro e per le tue spiegazioni sempre chiarissime!!!!

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว +1

      @@asdfds6752 ti ringrazio per il feedback :)

  • @joseantoniogarciaortiz4161
    @joseantoniogarciaortiz4161 2 ปีที่แล้ว

    Hello! Thanks for your video, I have a question: how can I modify the minimun distance of range camera in the code. I get 0.5 m, but the features camera Intel Realsense L515 can 0.25m. Thanks!

    • @saarb4861
      @saarb4861 2 ปีที่แล้ว

      Hey Jose
      I'm a student using a camera for a graduation project and I got a little confused with its activation.
      can you help me?

    • @joseantoniogarciaortiz4161
      @joseantoniogarciaortiz4161 2 ปีที่แล้ว

      @@saarb4861 Hey Saar, what do you need?

    • @saarb4861
      @saarb4861 2 ปีที่แล้ว

      May I have your discord/skype something like that?

  • @bluehoney9874
    @bluehoney9874 ปีที่แล้ว

    Impressive! How much is the resolution of the measurement? Can it measure the size under 1cm?

    • @pysource-com
      @pysource-com  ปีที่แล้ว

      According to Intels benchmarks the camera is supposed to detect from 0.3 to 3m with a depth margin error at around 2%

  • @jaeyounglee574
    @jaeyounglee574 2 ปีที่แล้ว +2

    ModuleNotFoundError: No module named 'realsense_depth'
    Jupyter notebook of anaconda, does not working?

    • @omerfarukpaker7551
      @omerfarukpaker7551 ปีที่แล้ว

      it is a python file that you can download from his blog. That's what i did and it worked

  • @urvashimesariya1263
    @urvashimesariya1263 ปีที่แล้ว

    Hello, I am not able to get frame. It gives error as runtime error: frames = self.pipeline.wait_for_frames()
    RuntimeError: Frame didn't arrive within 5000. Kindly please help me with this.

  • @furkandursun6990
    @furkandursun6990 3 ปีที่แล้ว

    Great video, does it measure correctly under water

    • @somusundram1823
      @somusundram1823 3 ปีที่แล้ว

      With Stereo or PCL? Most probably you need to work out with serious distortions

  • @amruthahp5411
    @amruthahp5411 2 ปีที่แล้ว

    i am getting an error like this ModuleNotFoundError: No module named 'realsense_depth'

  • @vanshikajain6334
    @vanshikajain6334 6 หลายเดือนก่อน

    i am not able to download the realsense depth file

  • @shenghuiwang1837
    @shenghuiwang1837 หลายเดือนก่อน

    when I want to download the python files I can't register the website using my google account ,is there some that have download the python files successfully ,can someone help me to download files and send to me

  • @balajiezhumalai3786
    @balajiezhumalai3786 2 ปีที่แล้ว

    Hi, is the camera directly attached to the computer?

  • @user-od6ev1yj5f
    @user-od6ev1yj5f 3 ปีที่แล้ว

    Холи щит, 1.1т просмотров за 2 дня? Невероятно

  • @pukatupukatam
    @pukatupukatam 2 ปีที่แล้ว

    where did you get RealSense D435i from? Cannot locate it anywhere in e-commerce sites :)

    • @pysource-com
      @pysource-com  2 ปีที่แล้ว

      Unfortunately intel shut down their production, so that's the reason why you can't find them on sales anymore.
      I recommend to look for OAK D devices, which seems to be the solution taking over now

    • @pukatupukatam
      @pukatupukatam 2 ปีที่แล้ว

      @@pysource-com thank you so much! do you reckon OAK D are better than intel?

    • @pukatupukatam
      @pukatupukatam 2 ปีที่แล้ว

      @@pysource-com maybe a little bit more description, what I aim to do is to turn a flat surface (with projector's image) into a touchscreen using such camera, so distance could be short, but I aim to have accuracy + fast response time from device.

  • @kenrampingplay
    @kenrampingplay ปีที่แล้ว

    Can you use this for object detection?

    • @pysource-com
      @pysource-com  ปีที่แล้ว

      Yes, you can use this camera of course integrating this with Object Detection methods

  • @aminfirdaus3279
    @aminfirdaus3279 2 ปีที่แล้ว

    is this person detection using yolo

  • @kerron_
    @kerron_ ปีที่แล้ว

    can you post realsense_depth.py

  • @reemanjumaaali9784
    @reemanjumaaali9784 2 ปีที่แล้ว

    Depth camera 415 the same way????

    • @pysource-com
      @pysource-com  2 ปีที่แล้ว

      I haven't tested it with the 415, but most likely they work the same way as they all need the pyrealsense library

  • @user-gh6wt4wf5k
    @user-gh6wt4wf5k 2 ปีที่แล้ว

    Can I use the code on SR300?

    • @pysource-com
      @pysource-com  2 ปีที่แล้ว

      it should work on the SR300 as well

    • @user-gh6wt4wf5k
      @user-gh6wt4wf5k 2 ปีที่แล้ว

      @@pysource-com thank you
      I’m find the erron,my cv2 is. break

  • @sumitpatnaik7057
    @sumitpatnaik7057 3 ปีที่แล้ว +1

    Great video isn't oak better than intellisense

    • @pysource-com
      @pysource-com  3 ปีที่แล้ว +2

      Generally speaking OAK is better than Intel Realsense camera, but I wouldn't put them on the same level as:
      - Oak is a kit (camera + cpu + framework)
      - Intel Realsense is a simple camera
      so both have their own pros and cons, depending on the project.
      I'll make a comparison video about them in the future

    • @sumitpatnaik7057
      @sumitpatnaik7057 3 ปีที่แล้ว

      @@pysource-com thanks it would be great

  • @jaeyounglee574
    @jaeyounglee574 2 ปีที่แล้ว

    Do not use this
    In ubuntu, below show
    ModuleNotFoundError: No module named 'realsense_depth'

  • @yevgeniybondar7509
    @yevgeniybondar7509 2 ปีที่แล้ว

    Get an affiliate link for the camera so you can make money from the sale

  • @benr3346
    @benr3346 2 ปีที่แล้ว

    que pasa sergio !

  • @hoangtrieuviet6507
    @hoangtrieuviet6507 2 ปีที่แล้ว

    Like