AxisCommunications / acap-computer-vision-sdk-examples

Example applications that provide developers with the tools and knowledge to use Axis Camera Application Platform (ACAP) Computer Vision solution
Apache License 2.0
52 stars 22 forks source link

Issue obtaining images from camera source using a python script #181

Closed AlejandroDiazD closed 2 weeks ago

AlejandroDiazD commented 7 months ago

Hello,

I'm trying to, using a python script, read an image from video streaming and later write it on my axis camera device. The objective is to process that image using a dnn similarly to the object-detector-python example, but my current issue is just about reading the image from video streaming.

I have followed the steps described in object-detector-python example, but for the following image (screenshot from the web interface of the camera):

325594054-ad4ecd1a-629f-4fcf-8f27-76117d64fb53

I'm getting the following image:

325592596-ed58668f-23c5-4b45-b215-1934d67f3fb1

Next, I provide my specific case characteristics:

I also provide some reproducible code:

import cv2 from vdo_proto_utils import VideoCaptureClient stream_width, stream_height, stream_framerate = (1280, 960, 10) grpc_socket = 'unix:///tmp/acap-runtime.sock' capture_client = VideoCaptureClient(socket=grpc_socket, stream_width=stream_width, stream_height=stream_height, stream_framerate=stream_framerate) frame = capture_client.get_frame() cv2.imwrite('/app/output_image.jpg', frame)

I'm running that code inside a docker container based on a docker image built using the Dockerfile provided in the object-detector-python example.

Thank you for your time.

AlejandroDiazD commented 7 months ago

Update: I almost solved the issue (@Corallo ).

The problem was related to the image rotation of the camera. To solve it I changed the rotation from the web interface in /video/installation.

Now the only problem is the color representation, we can see how the blue parts of the image are seen as brown.

The original image:

imagen

The obtained image:

train_mod_results_0

Do you know how can I solve it?

Thanks!

Corallo commented 7 months ago

Hi @AlejandroDiazD

Good that you solved the issue by yourself, I guess if you want to keep the image flipped, you can try to flip also the resolution (960x1280). I am keeping this issue open until we document this behavior.

Regarding the color problem, I think it is just that cv2 expects the color format in bgr when you save the image, while your frame is in rgb. try bgr_img = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)

AlejandroDiazD commented 7 months ago

It worked! :)

Thank you @Corallo, feel free to mark the issue as solved when you consider.

We keep in contact.