# Getting uint16 info over rtsp using cv2.videocapture

**URL:** <https://forum.opencv.org/t/getting-uint16-info-over-rtsp-using-cv2-videocapture/13936>\
**Category:** Python\
**Tags:** gstreamer, rtsp, videoio\
**Created:** [July 19, 2023, 11:04am UTC](https://forum.opencv.org/t/getting-uint16-info-over-rtsp-using-cv2-videocapture/13936 "2023-07-19T11:04:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhs](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bhs](https://forum.opencv.org/u/bhs)\
**Post date:** [July 19, 2023, 11:04am UTC](https://forum.opencv.org/t/getting-uint16-info-over-rtsp-using-cv2-videocapture/13936/1 "2023-07-19T11:04:45Z")

</div>

Hello, I managed to get a grayscale image of (480,640) through the code below.

```auto

cap_depth = cv2.VideoCapture("rtsp://admin:admin@192.168.1.10/depth", cv2.CAP_GSTREAMER)
while(True):
    ret2, frame_depth = cap_depth.read()
    cv2.namedWindow('kinova_depth', cv2.WINDOW_AUTOSIZE)
    cv2.setMouseCallback('kinova_depth', mouse_callback)
    cv2.imshow('kinova_depth',frame_depth)
    if cv2.waitKey(20) & 0xFF == ord('q'):
        break
cap_depth.release()
cv2.destroyAllWindows()

```

However, the output image was in uint8 format ranging from 0 to 255, and accurate depth information could not be obtained.  
I was able to get a value similar to uint16 through (pixel/255)\*65535, but a lot of errors occurred because I had already brought the value of uint8.

Is there a way to get raw depth information of uint16 when streaming rtsp using opencv?

My environment is as below  
Window10  
python 3.7  
opencv 4.1.0

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [July 19, 2023, 2:28pm UTC](https://forum.opencv.org/t/getting-uint16-info-over-rtsp-using-cv2-videocapture/13936/2 "2023-07-19T14:28:29Z")

</div>

> [@bhs](#):
>
> opencv 4.1.0

please, in any case update this

and, [it might work with ffmpeg](https://github.com/opencv/opencv/pull/22894)

---

<div class="post-metadata">

**Author:** ![bhs](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bhs](https://forum.opencv.org/u/bhs)\
**Post date:** [July 20, 2023, 7:30am UTC](https://forum.opencv.org/t/getting-uint16-info-over-rtsp-using-cv2-videocapture/13936/3 "2023-07-20T07:30:48Z")

</div>

I know I need to use version 4.1.0 to use CAP\_GSTREAMER.

I also looked for related links. If you use ffmpeg, you can probably use 16-bit information as input. But what I want is to get the output in 16bit.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [July 21, 2023, 6:26am UTC](https://forum.opencv.org/t/getting-uint16-info-over-rtsp-using-cv2-videocapture/13936/4 "2023-07-21T06:26:49Z")

</div>

> [@bhs](#):
>
> I know I need to use version 4.1.0 to use CAP\_GSTREAMER.

not true. why do you think so ?

---

<div class="post-metadata">

**Author:** ![bhs](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bhs](https://forum.opencv.org/u/bhs)\
**Post date:** [July 25, 2023, 1:34am UTC](https://forum.opencv.org/t/getting-uint16-info-over-rtsp-using-cv2-videocapture/13936/5 "2023-07-25T01:34:27Z")

</div>

I found a way to build opencv 4.1.0 version to use CAP\_GSTREAMER on window10.  
However, this method is only available in Python version 3.7 and from 3.8 it is said that a different method should be used, but unfortunately that method is not possible, so we are using versions 3.7 and 4.1.0.
