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

Поделиться
HTML-код
  • Опубликовано: 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
  • НаукаНаука

Комментарии • 120

  • @nguyenmanhtuan629
    @nguyenmanhtuan629 3 года назад +4

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

  • @omerfarukpaker7551
    @omerfarukpaker7551 Год назад

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

  • @MrSri331
    @MrSri331 2 года назад

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

  • @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

  • @user-mh8kb5ng9f
    @user-mh8kb5ng9f 3 месяца назад

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

  • @samchang4555
    @samchang4555 3 года назад

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

  • @roberttom6849
    @roberttom6849 3 года назад

    A great tutorial. Thanks.

  • @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?

  • @abderrahmenmelliti9627
    @abderrahmenmelliti9627 Год назад

    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.

  • @maxbretschneider6521
    @maxbretschneider6521 Год назад

    Great video, thanks a lot!

  • @MyOkman
    @MyOkman 2 года назад +1

    man, you are awesome !

  • @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.

  • @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

  • @haseebahmed1726
    @haseebahmed1726 2 года назад

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

  • @saijasijsauiassiaj
    @saijasijsauiassiaj Год назад

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

  • @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 ruclips.net/video/HHJDXE0VcAY/видео.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.

  • @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

  • @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.

  • @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)

  • @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.

    • @srishtisingh7031
      @srishtisingh7031 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 года назад

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

  • @nhatpham5797
    @nhatpham5797 5 месяцев назад

    Hello, can I use this camera with YOLOv8?

  • @shahonwre5604
    @shahonwre5604 2 года назад

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

  • @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

  • @granatapfel6661
    @granatapfel6661 10 месяцев назад

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

  • @r.iyushofficial5318
    @r.iyushofficial5318 3 года назад +2

    Awesome

  • @DilipKumar-dc2rx
    @DilipKumar-dc2rx Год назад

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

  • @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?

  • @RacecarJ0hnny
    @RacecarJ0hnny Год назад

    Does this work outside for greater distances?

  • @aymenbenammar1292
    @aymenbenammar1292 Год назад

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

  • @N_Yayan_S
    @N_Yayan_S 3 года назад

    Awesome broo, tq

  • @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

  • @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 2 месяца назад

      Have you found solution for this

  • @quentinjames981
    @quentinjames981 3 года назад +4

    More about filtering for more accurate readings please!

    • @westparezal
      @westparezal 2 года назад +1

      use Mean of a function and threshold

  • @Kupgnd
    @Kupgnd 10 месяцев назад

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

  • @335LINZ
    @335LINZ 2 года назад +1

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

  • @Sony-wq4hs
    @Sony-wq4hs 2 года назад

    We can know asic temperature for depth images

  • @AkshajMusic
    @AkshajMusic 11 месяцев назад +1

    How can I access my camera through Pycharm?

  • @panosgaras7544
    @panosgaras7544 3 года назад

    how to programm the apple harvester woth open cv

  • @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

  • @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 🤔

  • @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

  • @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 :)

  • @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)

  • @weistrass
    @weistrass 7 месяцев назад

    What about the distance between two given points?

  • @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 Год назад

      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 Год назад

      @@saarb4861 Hey Saar, what do you need?

    • @saarb4861
      @saarb4861 Год назад

      May I have your discord/skype something like that?

  • @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.

  • @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?

  • @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))

  • @kAlqamaRao
    @kAlqamaRao 2 года назад +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 года назад +1

      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
      ruclips.net/video/V2nimk44gQk/видео.html comparison

    • @shahonwre5604
      @shahonwre5604 2 года назад

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

  • @amruthahp5411
    @amruthahp5411 Год назад

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

  • @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.

  • @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%

  • @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?

  • @vanshikajain6334
    @vanshikajain6334 5 месяцев назад

    i am not able to download the realsense depth file

  • @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

  • @balajiezhumalai3786
    @balajiezhumalai3786 2 года назад

    Hi, is the camera directly attached to the computer?

  • @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.

  • @shenghuiwang1837
    @shenghuiwang1837 10 дней назад

    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

  • @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

  • @user-od6ev1yj5f
    @user-od6ev1yj5f 3 года назад

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

  • @kerron_
    @kerron_ Год назад

    can you post realsense_depth.py

  • @aminfirdaus3279
    @aminfirdaus3279 2 года назад

    is this person detection using yolo

  • @user-gh6wt4wf5k
    @user-gh6wt4wf5k Год назад

    Can I use the code on SR300?

    • @pysource-com
      @pysource-com  Год назад

      it should work on the SR300 as well

    • @user-gh6wt4wf5k
      @user-gh6wt4wf5k Год назад

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

  • @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

  • @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'

  • @benr3346
    @benr3346 Год назад

    que pasa sergio !

  • @hoangtrieuviet6507
    @hoangtrieuviet6507 2 года назад

    Like

  • @yevgeniybondar7509
    @yevgeniybondar7509 2 года назад

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