clariusdev / cast

APIs for Researchers and Marketplace Apps
https://www.clarius.com
BSD 3-Clause "New" or "Revised" License
37 stars 16 forks source link

Receiving Images With newProcessedImage Function in pycaster.py Example #149

Open MarkWijkhuizen opened 9 months ago

MarkWijkhuizen commented 9 months ago

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!

clariusk commented 9 months ago

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

MarkWijkhuizen commented 9 months ago

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?

clariusk commented 9 months ago

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

AriBunnell commented 9 months ago

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.

MarkWijkhuizen commented 8 months ago

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?

deepakraina99 commented 7 months ago

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

AriBunnell commented 7 months ago

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.

deepakraina99 commented 7 months ago

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

clariusk commented 7 months ago

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

deepakraina99 commented 7 months ago

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

AriBunnell commented 7 months ago

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.

deepakraina99 commented 7 months ago

@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 commented 7 months ago

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

clariusk commented 7 months ago

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

deepakraina99 commented 7 months ago

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

julien-l commented 7 months ago

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.

deepakraina99 commented 7 months ago

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!