Use OpenCV with camera in FlytSim px4

#1

Hello,
I’m trying to use the Python OpenCV script in flytsim, and I don’t know how to use the camera in flytsim on the drones simulator. I always have a USB webcam on my computer.
Thank.

#2

Configure FlytSim in PX4(Gazebo) mode. Click here to know how.

You won’t be able to access USB webcam in the simulation environment. Instead, we have a camera simulated within the environment. To access the camera, you need to subscribe to rostopic:

/flytsim/typhoon_h480/cgo3_camera/image_raw

#3

Thank you for your advice
I also found an easy way to use the camera.
code example:
cam = (“http://localhost:8080/stream?topic=/flytsim/flytcam/image_capture&width=320&height=240&type=ros_compressed”)

cap = cv2.VideoCapture(cam)