-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect two Gig-E cameras in the same python script #344
Comments
Hello! This depends on your "script" or program. |
Hi Tim,
thank you for the replay.
I read the documentation but I’m not able to find a way to stream two cameras at the same time. If I try to create two Harvester objects it gives an error, same if I put a second “h.update()”.
Can you help me please?
Best regards,
Fabio Conti
Fabio Conti
PhD Candidate
Research Group of Measurements and Experimental Techniques
***@***.***
***@***.***
Phone: 02.2399.8558
Office: Via La Masa 34 – B22
Politecnico di Milano
Via La Masa 1
Milan
Italy
www.polimi.it<http://www.polimi.it/>
Da: Tim ***@***.***>
Inviato: martedì 17 maggio 2022 10:21
A: genicam/harvesters ***@***.***>
Cc: Fabio Conti ***@***.***>; Author ***@***.***>
Oggetto: Re: [genicam/harvesters] Connect two Gig-E cameras in the same python script (Issue #344)
Hello!
This depends on your "script" or program.
—
Reply to this email directly, view it on GitHub<#344 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMUAKJ7LXWD3ELS6ZMRQA2TVKNJGTANCNFSM5WBUAMDQ>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
Hey Fabio, I did it myself so it is possible. You just need to :
If you create two image acquirer you'll have IO conflicts. Cheers Fishy |
@FabioContipolimi Hi Fabio, thank you for the message and I am sorry for having kept you waiting.
Sure, it is. In general, you need just one On the You can learn how an Anyway, please give it a try and let me know if you face an issue that you do not expect to see. Regards, Kazunari. |
Hi,
sorry for the late answer, I tried and succeeded! Thank you very much. Just another question, is it possible to use a multiprocess approach rather than multithreading?
Best regards,
Fabio Conti
Fabio Conti
PhD Candidate
Research Group of Measurements and Experimental Techniques
***@***.***
***@***.***
Phone: 02.2399.8558
Office: Via La Masa 34 – B22
Politecnico di Milano
Via La Masa 1
Milan
Italy
www.polimi.it<http://www.polimi.it/>
Da: Paolo De Keyzer ***@***.***>
Inviato: mercoledì 18 maggio 2022 17:46
A: genicam/harvesters ***@***.***>
Cc: Fabio Conti ***@***.***>; Author ***@***.***>
Oggetto: Re: [genicam/harvesters] Connect two Gig-E cameras in the same python script (Issue #344)
Hey Fabio,
I did it myself so it is possible. You just need to :
* Create one image acquirer that connects to both cameras and return the handler
* Create two threads (one per camera) and pass it the handler object. These will scan simultaneously.
If you create two image acquirer you'll have IO conflicts.
Cheers
Fishy
—
Reply to this email directly, view it on GitHub<#344 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMUAKJ32FAVHNBYALZQQJNDVKUGENANCNFSM5WBUAMDQ>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
Hi Kazunari,
thank you very much, I tried with multiprocess and it worked, I’ll test also your script to validate mine.
Do you know if it is possible to use multithreading rather than multiprocess?
Best regards,
Fabio Conti
Fabio Conti
PhD Candidate
Research Group of Measurements and Experimental Techniques
***@***.***
***@***.***
Phone: 02.2399.8558
Office: Via La Masa 34 – B22
Politecnico di Milano
Via La Masa 1
Milan
Italy
www.polimi.it<http://www.polimi.it/>
Da: Kazunari ***@***.***>
Inviato: lunedì 30 maggio 2022 16:31
A: genicam/harvesters ***@***.***>
Cc: Fabio Conti ***@***.***>; Mention ***@***.***>
Oggetto: Re: [genicam/harvesters] Connect two Gig-E cameras in the same python script (Issue #344)
@FabioContipolimi<https://github.com/FabioContipolimi> Hi Fabio, thank you for the message and I am sorry for having kept you waiting.
is it possible to connect two Gig-E cameras within the same python script?
Sure, it is. In general, you need just one Harvester object no matter how many devices you work with; you can have multiple Harvester objects but it is not necessary to talk now.
On the Harvester.update method call, then it will update the list of device information and you should be able to check the result by reading its Harvester.device_info_list property. There you will find the devices that you should be familiar with.
You can learn how an ImageAcquirer object by visiting this test script<https://github.com/genicam/harvesters/blob/master/src/harvesters/test/test_319.py> but the most trivial approach would be to pass an index to the Harvester.create method.
Anyway, please give it a try and let me know if you face an issue that you do not expect to see. Regards, Kazunari.
—
Reply to this email directly, view it on GitHub<#344 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMUAKJ53JWEZNGHQF7YAJ23VMTGKZANCNFSM5WBUAMDQ>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
Hi, thank you for the update.
I am afraid, but the current Harvester supports threading but not processing. I would appreciate it if you could tell me why you need processing instead of threading. Yes, that would be great if you could show a piece of code you expect to have just as an example. Thanks. |
Hi,
I’m working on an application that involves three cameras and should work continuously.
I need to stream the videos and to make some heavy computations for objects recognitions.
For these reasons I thought that avoiding the global interpreter lock could be a better idea in terms of performances, in this way I can run the script on different cores.
This is an example (if I understood correctly what you are asking me):
# Import Harvester:
from harvesters.core import Harvester
from harvesters.util.pfnc import mono_location_formats
from multiprocessing import Process
import numpy as np
import time
import matplotlib.pyplot as plt
import cv2
import os
def camera_stream(camera_name):
camera_name.start()
while cv2.waitKey(1) != 27:
Buffer = camera_name.fetch(timeout=-1)
component = Buffer.payload.components[0]
width = component.width
height = component.height
original = component.data.reshape(height, width)
img = original.copy()
image = cv2.cvtColor(img, cv2.COLOR_BayerRG2RGB)
# computations here.
cv2.imshow('Display frame', image)
Buffer.queue()
if __name__ == "__main__":
h = Harvester()
h.add_file(xxxx)
h.update()
device_found = h.device_info_list
ia = h.create(0)
ib = h.create(1)
device_found = [ia, ib]
procs = []
for name in device_found:
proc = Process(target=camera_stream, args=(name,))
procs.append(proc)
proc.start()
for proc in procs:
proc.join()
ia.stop()
ia.destroy()
ib.stop()
ib.destroy()
h.reset()
print("Exiting...")
exit
Fabio Conti
PhD Candidate
Research Group of Measurements and Experimental Techniques
***@***.***
***@***.***
Phone: 02.2399.8558
Office: Via La Masa 34 – B22
Politecnico di Milano
Via La Masa 1
Milan
Italy
www.polimi.it<http://www.polimi.it/>
Da: Kazunari ***@***.***>
Inviato: lunedì 30 maggio 2022 16:41
A: genicam/harvesters ***@***.***>
Cc: Fabio Conti ***@***.***>; Mention ***@***.***>
Oggetto: Re: [genicam/harvesters] Connect two Gig-E cameras in the same python script (Issue #344)
Hi, thank you for the update.
is it possible to use a multiprocess approach rather than multithreading?
I am afraid, but the current Harvester supports threading but not processing. I would appreciate it if you could tell me why you need processing instead of threading. Yes, that would be great if you could show a piece of code you expect to have just as an example. Thanks.
—
Reply to this email directly, view it on GitHub<#344 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMUAKJZOW7TGYJPX4BV5KTTVMTHQXANCNFSM5WBUAMDQ>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
Are you conflating image acquirer objects with a harvester core object? I don't think one image acquirer can connect to multiple devices. Do you still have the code where you did this? Best |
I am also stuck in the same problem, where two image acquirers for two cameras don't work. Have you found any solutions on this? Any information would be appreciated. |
Hi,
is it possible to connect two Gig-E cameras within the same python script?
The text was updated successfully, but these errors were encountered: