cast icon indicating copy to clipboard operation
cast copied to clipboard

Receiving Images With newProcessedImage Function in pycaster.py Example

Open MarkWijkhuizen opened this issue 2 years ago • 17 comments

Dear Clarius Support,

After connecting to the Clarius probe using the pycaster.py example with the correct IP address and port all commands seem to work, except the stream action.

# Output after successfully connecting to the Clarius probe
initialization succeeded
connected to 192.168.1.1 on port 37425
press (q)->quit (a)->action (s)->stream (p)->param change: s

The newProcessedImage function is never called for reasons unknown to me.

How could I stream the images on the PC and save them as PNG?

def newProcessedImage(image, width, height, sz, micronsPerPixel, timestamp, angle, imu):
    print(f'newProcessedImage called!') # <- this line is never printed
    bpp = sz / (width * height)
    if printStream:
        print(
            "image: {0}, {1}x{2} @ {3} bpp, {4:.2f} um/px, imu: {5} pts".format(
                timestamp, width, height, bpp, micronsPerPixel, len(imu)
            ),
            end="\r",
        )
    if bpp == 4:
        img = Image.frombytes("RGBA", (width, height), image)
    else:
        img = Image.frombytes("L", (width, height), image)
    img.save("processed_image.png")
    return

Thanks in advance for any help!

MarkWijkhuizen avatar Dec 14 '23 10:12 MarkWijkhuizen

Are you on a Windows system? If so, ensure your firewall has an exception for the python executable, or temporarily disable the firewall.

clariusk avatar Dec 14 '23 17:12 clariusk

I added an inbound and outbound rule for the Python executable allowing any connection, however, the images are still not streamed.

Which firewall rules should be added to make the streaming work?

MarkWijkhuizen avatar Dec 15 '23 12:12 MarkWijkhuizen

Maybe try a full disable temporarily to see if that helps, suggest removing your Internet connection beforehand

clariusk avatar Dec 16 '23 20:12 clariusk

I added an inbound and outbound rule for the Python executable allowing any connection, however, the images are still not streamed.

Which firewall rules should be added to make the streaming work?

Adding the inbound and outbound rules and completely disconnecting from WiFi before worked for me on my Windows machine.

AriBunnell avatar Jan 02 '24 22:01 AriBunnell

Happy to hear someone got it to work on Windows. Could you provide the details of your inbound and outbound rules so I could reproduce you configuration?

MarkWijkhuizen avatar Jan 22 '24 08:01 MarkWijkhuizen

I am having the same issue. I am not able to stream it. Pressing 's' does nothing.

deepakraina99 avatar Feb 07 '24 20:02 deepakraina99

This hasn't been reproducible for me on another Windows computer with the inbound/outbound rules. However, disconnecting from WiFi and/or ethernet and disabling Windows Defender Firewall before connecting to the probe WiFi works for me every time.

AriBunnell avatar Feb 07 '24 20:02 AriBunnell

@AriBunnell Thanks. But not working for me. Want to re-confirm if you are able to stream the real-time ultrasound video on Windows computer using the pycaster.py?

deepakraina99 avatar Feb 07 '24 20:02 deepakraina99

and just a note if the program allows you to connect, change parameters, etc. -- you do have a successful connection to the probe via the API, however the UDP stream is being blocked, and firewall, etc, needs to be taken care of. It's more difficult for python since it's the entire python framework you're enabling/disabling, if you choose to use the C++ program, you can set specific firewall rules for that executable

clariusk avatar Feb 07 '24 20:02 clariusk

@AriBunnell Great! Can you let us know the inbound and outbound rules you followed? That would be of great help.

deepakraina99 avatar Feb 07 '24 20:02 deepakraina99

https://answers.microsoft.com/en-us/windows/forum/all/defender-firewall-and-python/18a32297-42d9-4c6a-8c21-57b52dd163d1

But again, this hasn't been reliable. Disabling firewall is my current solution.

AriBunnell avatar Feb 07 '24 20:02 AriBunnell

@clariusk @AriBunnell Still not working. I have added inbound and outbound rules for python.exe. The firewall is also disabled. But no success so far.

deepakraina99 avatar Feb 07 '24 21:02 deepakraina99

@clariusk It works with Qt app, I can see the real-time video, but not with pycaster.py. I want to do some processing (deep learning) on real-time ultrasound images. Look forward to your guidance.

deepakraina99 avatar Feb 07 '24 21:02 deepakraina99

maybe try Linux :) I run Ubuntu, simple install and have never had issues

clariusk avatar Feb 07 '24 21:02 clariusk

pycaster.py worked but only with v11.0.0, not with the latest v11.1.0 (For some unknown reason)

deepakraina99 avatar Feb 10 '24 17:02 deepakraina99

pycaster.py worked but only with v11.0.0, not with the latest v11.1.0 (For some unknown reason)

Maybe due to incompatible versions, try SDK 11.1.0 with app version 11.1.0.

julien-l avatar Feb 12 '24 17:02 julien-l

Yes, we had the app version 11.1.0. I tried with SDK 11.1.0, but it did not work. But 11.1.0 worked!

deepakraina99 avatar Feb 12 '24 17:02 deepakraina99