basler / pypylon

The official python wrapper for the pylon Camera Software Suite
http://www.baslerweb.com
BSD 3-Clause "New" or "Revised" License
574 stars 208 forks source link

On-Demand Multicast with Gige ethernet samples? #173

Open marvision-ai opened 5 years ago

marvision-ai commented 5 years ago

I would like to use a single Gige camera to grab a frame and send that single frame to multiple computers at the same time. Please let me know if this is possible.

I would like to implement On-demand multicasting: https://www.baslerweb.com/fp-1481127658/media/en/downloads/documents/application_notes/AW00078903000_Unicasting-Multicasting_with_IPCam.pdf

marvision-ai commented 5 years ago

Anyone attempt this?

IceTDrinker commented 5 years ago

I'm also interested if you have leads on how to do this.

IceTDrinker commented 5 years ago

see 2.5 here : https://www.baslerweb.com/fp-1566549625/media/downloads/documents/users_manuals/AW00148802000_pylon_SDK_Samples_Manual.pdf

The first user needs to open the camera in control mode, then other users can open the camera in multicast mode, careful with bandwidth

marvision-ai commented 4 years ago

Good find @IceTDrinker ... So we can confirm it works with C++.

Any luck finding examples with Python?

davidi-theother commented 4 years ago

After a little bit of testing that is working for me (use ConfigurationEventPrinter() from samples )

camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) camera.MonitorModeActive = True

camera.RegisterConfiguration(ConfigurationEventPrinter(), pylon.RegistrationMode_ReplaceAll, pylon.Cleanup_Delete)

camera.Open() camera.StartGrabbing()

marvision-ai commented 4 years ago

Hi @davidi-theother I am not really sure what you mean by your response.

What about the 3 scripts in samples? gige_action_command.py gige_announce_renounce.py gige_ip_config.py

Would those be used at all with the samples @IceTDrinker provided?

IceTDrinker commented 4 years ago

I believe there is a nearly 1:1 python code for this, I was not the one to try it. But I believe the snippet from @davidi-theother is basically what we use. Only problem with this solution is apparently bandwidth if camera streams raw images. ConfigurationEventPrinter can be substituted for None safely I think ? Haven’t played much with configurations so feedback is welcome.

marvision-ai commented 4 years ago

@davidi-theother So the code you wrote would be for application B correct? Application A (controller) would do what specifically?

Also, I believe this is just for multicasting? How about if we wanted application A (controller) to only have the camera multicast a single frame to the other applications (clients) at a time?

PartyTrix commented 4 years ago

After a little bit of testing that is working for me (use ConfigurationEventPrinter() from samples )

camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) camera.MonitorModeActive = True

camera.RegisterConfiguration(ConfigurationEventPrinter(), pylon.RegistrationMode_ReplaceAll, pylon.Cleanup_Delete)

camera.Open() camera.StartGrabbing()

A long search ended here, thanks!! 😄

For future reference: this got it working for me:

from pypylon import pylon
from samples.configurationeventprinter import ConfigurationEventPrinter #get this file from the pypylon "samples" folder
import cv2

#load converter
converter = pylon.ImageFormatConverter()
converter.OutputPixelFormat = pylon.PixelType_BGR8packed
converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned

#initate camera in MonitorMode 
camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
camera.MonitorModeActive = True
camera.RegisterConfiguration(ConfigurationEventPrinter(), pylon.RegistrationMode_ReplaceAll, pylon.Cleanup_Delete)

#open camera stream
camera.Open()
camera.StartGrabbing()

#while grabbing, display the image using openCV
while camera.IsGrabbing():
    grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)

    if grabResult.GrabSucceeded():
        # Access the image data
        image = converter.Convert(grabResult)
        img = image.GetArray()
        cv2.namedWindow('title', cv2.WINDOW_NORMAL)
        cv2.imshow('title', img)
        k = cv2.waitKey(1)
        if k == 27:
            break
    grabResult.Release()

camera.Close()