MultistreamHandler Python, segmentation fault

I’m trying to use the multistream handler, i want to clarify that my streams are synced liked mentioned in the documentation. Currently I manged to acquire the images with costume code, using multiprocessing and threding. I also see when I put the fps to a fixed amount (e.g. 20) I have acquired the expected mount(e.g. 200 on each camera after 10 seconds).

however when I use the multistream handler from cvb i just get segmentation fault error.

discover = cvb.DeviceFactory.discover_from_root(cvb.DiscoverFlags.IgnoreVins)

with cvb.DeviceFactory.open(discover[0].access_token) as device1, cvb.DeviceFactory.open(discover[1].access_token) as device2:
    stream1 = device1.stream
    stream2 = device2.stream
    with cvb.MultiStreamHandler([device1.stream,device2.stream]) as handler:
        handler.run()
        time.sleep(10)
        handler.finish()

i can verify that stream1 and stream2 are cvb.stream objects at 0x0xxxxxxxxx

Hi @basirsedighi ,
could you please specify your system/platform version, python version and the release version of your CVB installation?
Which camera(s) do you use?

18.04.1-Ubuntu SMP Linux
python 3.6.9
cvb.version() → v13.02.001
cameras, Genie nano C1920

Hi @basirsedighi ,
could you please verify which interfaces are taken as device1 and device2, maybe by printing their access_token.

print(discover[0].access_token)
print(discover[1].access_token)

You may think of an upgrade of CVB.

Under is the printed accesstokens, seperated by a hard line.
When I use the singelstrem object from your examples, I acquire images on both cameras

{
    "tls": [
        {
            "ifaces": [
                {
                    "devices": [
                        {
                            "id": "::ID->00-01-0D-C3-E2-38::10.0.222.10",
                            "lvl": "5",
                            "features": "",
                            "infos": [
                                {
                                    "name": "drivertype",
                                    "value": "SOCKET",
                                    "id": "2004"
                                },
                                {
                                    "name": "tltype",
                                    "value": "GEV",
                                    "id": "3000"
                                },
                                {
                                    "name": "username",
                                    "value": "S1231442",
                                    "id": "3001"
                                },
                                {
                                    "name": "serialnumber",
                                    "value": "S1183970",
                                    "id": "3002"
                                },
                                {
                                    "name": "mac",
                                    "value": "00-01-0D-C3-E2-38",
                                    "id": "3003"
                                },
                                {
                                    "name": "ip",
                                    "value": "10.0.222.10",
                                    "id": "3004"
                                },
                                {
                                    "name": "subnet",
                                    "value": "255.255.255.0",
                                    "id": "3005"
                                },
                                {
                                    "name": "vendor",
                                    "value": "Teledyne DALSA",
                                    "id": "3008"
                                },
                                {
                                    "name": "model",
                                    "value": "Nano-C1920",
                                    "id": "3009"
                                },
                                {
                                    "name": "deviceid",
                                    "value": "::ID->00-01-0D-C3-E2-38::10.0.222.10",
                                    "id": "3010"
                                },
                                {
                                    "name": "accessstatus",
                                    "value": "READWRITE",
                                    "id": "3011"
                                }
                            ]
                        }
                    ],
                    "id": "SD::MAC->9A-CD-DC-69-0F-A2",
                    "lvl": "4",
                    "features": "",
                    "infos": [
                        {
                            "name": "subnet",
                            "value": "10.0.222.1 255.255.255.0",
                            "id": "2000"
                        },
                        {
                            "name": "mac",
                            "value": "9A-CD-DC-69-0F-A2",
                            "id": "2001"
                        },
                        {
                            "name": "tltype",
                            "value": "GEV",
                            "id": "2002"
                        },
                        {
                            "name": "displayname",
                            "value": "Socket Driver @ 9A-CD-DC-69-0F-A2",
                            "id": "2003"
                        },
                        {
                            "name": "interfaceid",
                            "value": "SD::MAC->9A-CD-DC-69-0F-A2",
                            "id": "2005"
                        }
                    ]
                }
            ],
            "path": "\/opt\/cvb\/drivers\/genicam\/libGevTL.cti",
            "id": "\/opt\/cvb\/drivers\/genicam\/libGevTL.cti.1.2000.10",
            "lvl": "3",
            "features": "",
            "infos": [
                {
                    "name": "tlpath",
                    "value": "\/opt\/cvb\/drivers\/genicam\/libGevTL.cti",
                    "id": "4000"
                },
                {
                    "name": "tlvendor",
                    "value": "STEMMER IMAGING",
                    "id": "4002"
                }
            ]
        }
    ]
}

{
    "tls": [
        {
            "ifaces": [
                {
                    "devices": [
                        {
                            "id": "::ID->00-01-0D-C5-0E-28::10.0.222.11",
                            "lvl": "5",
                            "features": "",
                            "infos": [
                                {
                                    "name": "drivertype",
                                    "value": "SOCKET",
                                    "id": "2004"
                                },
                                {
                                    "name": "tltype",
                                    "value": "GEV",
                                    "id": "3000"
                                },
                                {
                                    "name": "username",
                                    "value": "S1231442",
                                    "id": "3001"
                                },
                                {
                                    "name": "serialnumber",
                                    "value": "S1231442",
                                    "id": "3002"
                                },
                                {
                                    "name": "mac",
                                    "value": "00-01-0D-C5-0E-28",
                                    "id": "3003"
                                },
                                {
                                    "name": "ip",
                                    "value": "10.0.222.11",
                                    "id": "3004"
                                },
                                {
                                    "name": "subnet",
                                    "value": "255.255.255.0",
                                    "id": "3005"
                                },
                                {
                                    "name": "vendor",
                                    "value": "Teledyne DALSA",
                                    "id": "3008"
                                },
                                {
                                    "name": "model",
                                    "value": "Nano-C1920",
                                    "id": "3009"
                                },
                                {
                                    "name": "deviceid",
                                    "value": "::ID->00-01-0D-C5-0E-28::10.0.222.11",
                                    "id": "3010"
                                },
                                {
                                    "name": "accessstatus",
                                    "value": "READWRITE",
                                    "id": "3011"
                                }
                            ]
                        }
                    ],
                    "id": "SD::MAC->9A-CD-DC-69-0F-A2",
                    "lvl": "4",
                    "features": "",
                    "infos": [
                        {
                            "name": "subnet",
                            "value": "10.0.222.1 255.255.255.0",
                            "id": "2000"
                        },
                        {
                            "name": "mac",
                            "value": "9A-CD-DC-69-0F-A2",
                            "id": "2001"
                        },
                        {
                            "name": "tltype",
                            "value": "GEV",
                            "id": "2002"
                        },
                        {
                            "name": "displayname",
                            "value": "Socket Driver @ 9A-CD-DC-69-0F-A2",
                            "id": "2003"
                        },
                        {
                            "name": "interfaceid",
                            "value": "SD::MAC->9A-CD-DC-69-0F-A2",
                            "id": "2005"
                        }
                    ]
                }
            ],
            "path": "\/opt\/cvb\/drivers\/genicam\/libGevTL.cti",
            "id": "\/opt\/cvb\/drivers\/genicam\/libGevTL.cti.1.2000.10",
            "lvl": "3",
            "features": "",
            "infos": [
                {
                    "name": "tlpath",
                    "value": "\/opt\/cvb\/drivers\/genicam\/libGevTL.cti",
                    "id": "4000"
                },
                {
                    "name": "tlvendor",
                    "value": "STEMMER IMAGING",
                    "id": "4002"
                }
            ]
        }
    ]
}

Singel stream example with device[0] object output:

setup
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 0
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 1
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 2
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 0
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 1
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 2
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 0
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 1
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 2
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 0
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 1
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 2
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 0
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 1
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 2
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 0
handle_async_stream
New image: RingBufferImage <cvb.RingBufferImage object at 0x7fa737e57260> | Status: 0 | Buffer Index: 1
handle_async_stream
tear_down

Multistream example on device[0] and device[1] output:
segmentation fault

Can you please specify the line (i.e. the code), from which the seg fault occurs? Maybe start your script with the python debugger and step through:

python3 -m pdb your_script_name.py

Did you check out these docs?

from the above code provided the fult accures at this step, and the program just stop working:

 with cvb.MultiStreamHandler([device1.stream,device2.stream]) as handler:

print(device[0].stream device[1].stream) gives [<cvb.Stream object at 0x7f781d792198>,
<cvb.Stream object at 0x7f781d7921e8>
]

or at super().init(stream)

class MyStreamHandler(cvb.MultiStreamHandler):

def __init__(self, stream):
    super().__init__(stream)
    self.rate_counter = cvb.RateCounter()
 with MyStreamHandler ([device1.stream,device2.stream]) as handler:

Anyone have the solution to that issue? is it related to CVB versions or should it work in all CVB versions ?

Hi @basirsedighi, hi @antonkristensen,

maybe some context if someone else runs into this issue:

  • Please keep in mind, that on Windows with GEV cameras you would get access tokens for the GevSD and GevFD so opening token 0 and 1 most probably would try to open the same device twice. On Linux only the SD is available as there is no (back then very slow) Windows network stack to skip like the GevFD does. That’s why @s-woe asked for the access tokens :slight_smile:
  • You’ll need to call the multi stream handle on the stream objects retrieved by device.stream() like so:
    with cvb.MultiStreamHandler([device1.stream,device2.stream]) as handler:

That being said you also ran into a bug. I will send you a download link to a fixed python lib asap. The issue will also be fixed in CVB 13.04.000 which should be available this week. Sorry for the inconvenience!

From one thing to another, what is the difference between GevSD and GevFD, i guess that SD is Socket Device and FD is filter? device?
What is the difference between them and which ones are available in linux?
are there any speed differences?

Almost :wink: GevFD is the filter driver. It is only available on Windows since it filters all GigE-Vision related network traffic and bypasses the windows stack for it. This resulted in a major speed increase on Windows systems mainly back with WIndows XP. Nowadays the difference is not so distinct. The other way to open a device is using the GevSD (socket driver) which opens a device using the os’s socket. You only habe the SD in linux but that’s enough :slight_smile: .