Anubis - Bachelor thesis project

camera.py
Go to the documentation of this file.
1 # Anubis is a program to control industrial cameras and train and use artificial neural networks
2 # Copyright (C) 2021 Lukaszczyk Jakub
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17 from harvesters.core import Harvester
18 from vimba import *
19 import threading
20 import queue
21 import copy
22 import cv2
23 import os #for working with save path
24 from datetime import datetime
25
26 from global_queue import frame_queue
27 from global_queue import active_frame_queue
28
29 from config_level import Config_level
30 from vendors import Vendors
31
32 class Camera:
33 """!@brief This class implements backend for the communication with cameras using
34 Harvester and any other implemented API. Currently the app contains Harvester
35 and API Vimba.
36 """
37 def __init__(self, producer_paths = None):
38 """!@brief Initialize Camera object"""
39
40 self.h = Harvester()
41
42 self.paths = []
43 if(producer_paths):
44 for path in producer_paths:
45 self.add_gentl_producer(path)
46
47
48 self.vendor = Vendors.Other
49
50 self.is_recording = False
51
52 self.acquisition_running = False
53
54 self.devices_info = []
55
56 self.active_camera = 0
57
58 self.ia = None
59
60 def get_camera_list(self,):
61 """!@brief Connected camera discovery
62 @details Uses Harvester object to discover all connected cameras
63 @return List of Dictionaries cantaining informations about cameras
64 """
65 #if there is selected camera which uses different API, temporarily start
66 #Harvester to reload the camera list
67 if not self.vendor == Vendors.Other:
68 tmp_paths = self.paths.copy()
69 self.paths = []
70 for path in tmp_paths:
71 self.add_gentl_producer(path)
72 self.h.update()
73 self.devices_info = []
74 for device in self.h.device_info_list:
75 d = {'id_': device.id_,
76 'model': device.model,
77 'vendor': device.vendor}
78 self.devices_info.append(d)
79 if not self.vendor == Vendors.Other:
80 self.disconnect_harvester()
81 return self.devices_info
82
83 def select_camera(self,selected_device):
84 """!@brief choose camera to connect to
85 @details Select camera you will be using and set Camera object accordingly
86 @param[in] selected_device ID of a camera you want to connect to
87 """
88
89 if not self.vendor == Vendors.Other:
90 tmp_paths = self.paths.copy()
91 self.paths = []
92 for path in tmp_paths:
93 self.add_gentl_producer(path)
94 self.h.update()
95 #translate selected device to index in harvester's device info list
96 for index, camera in enumerate(self.devices_info):
97 if camera['id_'] == selected_device:
98 harvester_index = index
99 break
100 if(self.h.device_info_list[harvester_index].vendor == 'Allied Vision Technologies'):
101 self.disconnect_harvester()
102 self.vendor = Vendors.Allied_Vision_Technologies
103 self.active_camera = self._translate_selected_device(selected_device)
104 with Vimba.get_instance() as vimba:
105 cams = vimba.get_all_cameras()
106 with cams [self.active_camera] as cam:
107 try:
108 #Makes sure that the camera won't send packets larger
109 #than destination pc can raceive.
110 cam.GVSPAdjustPacketSize.run()
111 while not cam.GVSPAdjustPacketSize.is_done():
112 pass
113 except (AttributeError, VimbaFeatureError):
114 pass
115 else:
116 self.active_camera = harvester_index
117 self.vendor = Vendors.Other
118 self.ia = self.h.create_image_acquirer(harvester_index)
119
120 try:
121 self.ia.remote_device.node_map.GevSCPSPacketSize.value = 1500
122 except:
123 pass
124
125 def _translate_selected_device(self, selected_device):
126 """!@brief attrs camera ID to index in a list of detected cameras
127 @details Index is returned according to currently active camera vendor.
128 This method must be called in every method where new connection to a camera is made.
129 @param[in] selected_device ID of a camera you want to connect to
130 """
131 if self.vendor == Vendors.Allied_Vision_Technologies:
132 with Vimba.get_instance() as vimba:
133 cams = vimba.get_all_cameras()
134 for index, camera in enumerate(cams):
135 if camera.get_id() == selected_device:
136 return index
137 else:
138 for index, camera in enumerate(self.h.device_info_list):
139 if camera.id_ == selected_device:
140 return index
141
142 def get_parameters(self,feature_queue, flag, visibility = Config_level.Unknown):
143 """!@brief Read parameters from camera
144 @details Based on self.vendor and self.active_camera chooses right API and
145 loads all available camera parameters
146 @param[in] feature_queue each parameter's dictionary is put into
147 this queue
148 @param[in] flag used to signal that the method finished (threading object)
149 @param[in] visibility Defines level of parameters that should be put in
150 the queue
151 @return True if success else False
152 """
153 #categories are defined by GenICam SFNC
154 if(self.vendor == Vendors.Allied_Vision_Technologies):
155 #Establishing communication
156 try:
157 with Vimba.get_instance() as vimba:
158 cams = vimba.get_all_cameras ()
159 with cams[self.active_camera] as cam:
160 features = cam.get_all_features()
161 for feature in features:
162 feat_vis = int(feature.get_visibility())
163 if(feat_vis > 0 and feat_vis <= visibility ):
164 name = feature.get_name()
165
166 features_out = {}
167 features_out['name'] = name
168
169 disp_name = feature.get_display_name()
170 features_out['attr_name'] = disp_name
171
172 #if feature does not have read permission,
173 #go to next iteration
174 if(not feature.get_access_mode()[0]):
175 continue
176
177 #Get feature's write mode
178 try:
179 attr = feature.get_access_mode()[1]
180 except (AttributeError, VimbaFeatureError):
181 attr = None
182
183 features_out['attr_enabled'] = attr
184
185 #Get feature's type if it exists
186 try:
187 attr = str(feature.get_type())
188 attr = attr.replace("<class 'vimba.feature.", '')
189 attr = attr.replace("'>","")
190 except (AttributeError, VimbaFeatureError):
191 attr = None
192
193 features_out['attr_type'] = attr
194
195 #Get availible enums for enum feature type
196 if(features_out['attr_type'] == "EnumFeature"):
197 try:
198 attr = feature.get_available_entries()
199 except (AttributeError, VimbaFeatureError):
200 attr = None
201
202 features_out['attr_enums'] = attr
203
204 #Get category for the feature
205 try:
206 attr = feature.get_category()
207 except (AttributeError, VimbaFeatureError):
208 attr = None
209
210 features_out['attr_cat'] = attr
211
212 #Get feature's value if it exists
213 try:
214 attr = feature.get()
215 except (AttributeError, VimbaFeatureError):
216 attr = None
217
218 features_out['attr_value'] = attr
219
220 #Get feature's range if it exists
221 try:
222 attr = feature.get_range()
223 except (AttributeError, VimbaFeatureError):
224 attr = None
225
226 features_out['attr_range'] = attr
227
228 #Get feature's increment if it exists
229 try:
230 attr = feature.get_increment()
231 except (AttributeError, VimbaFeatureError):
232 attr = None
233
234 features_out['attr_increment'] = attr
235
236 #Get feature's max length if it exists
237 try:
238 attr = feature.get_max_length()
239 except (AttributeError, VimbaFeatureError):
240 attr = None
241
242 features_out['attr_max_length'] = attr
243
244 try:
245 attr = feature.get_tooltip()
246 except (AttributeError, VimbaFeatureError):
247 attr = None
248
249 features_out['attr_tooltip'] = attr
250
251 feature_queue.put(features_out)
252 flag.set()
253 return True
254 except:
255 return False
256 else:
257 features = dir(self.ia.remote_device.node_map)
258
259 for feature in features:
260 if(feature.startswith('_')):
261 continue
262 try:
263 feature_obj = getattr(self.ia.remote_device.node_map, feature).node
264 feature = getattr(self.ia.remote_device.node_map, feature)
265 #Some information is accessible through harvester feature,
266 #for some information we need to go deeper into Genapi itself
267 feat_acc = feature_obj.get_access_mode()
268 except:
269 continue
270
271 #according to genicam standard
272 #0 - not implemented
273 #1 - not availablle
274 #3 - write only
275 #4 - read only
276 #5 - read and write
277 if(feat_acc == 0 or feat_acc == 1):
278 continue
279
280 feat_vis = feature_obj.visibility
281 if( feat_vis < visibility ):
282 features_out = {}
283 features_out['name'] = feature_obj.name
284 #disp_name = feature.get_display_name()
285 features_out['attr_name'] = feature_obj.display_name
286
287
288
289 #Set feature's write mode
290 try:
291 if(feat_acc == 5 or feat_acc == 3):
292 attr = False
293 else:
294 attr = True
295 except:
296 attr = None
297
298 features_out['attr_enabled'] = attr
299
300 #Get feature's type if it exists
301 #intfIValue = 0 #: IValue interface
302 #intfIBase = 1 #: IBase interface
303 #intfIInteger = 2 #: IInteger interface
304 #intfIBoolean = 3 #: IBoolean interface
305 #intfICommand = 4 #: ICommand interface
306 #intfIFloat = 5 #: IFloat interface
307 #intfIString = 6 #: IString interface
308 #intfIRegister = 7 #: IRegister interface
309 #intfICategory = 8 #: ICategory interface
310 #intfIEnumeration = 9 #: IEnumeration interface
311 #ntfIEnumEntry = 10 #: IEnumEntry interface
312 #intfIPort = 11 #: IPort interface
313
314 try:
315 attr = feature_obj.principal_interface_type
316 if(attr == 2):
317 attr = "IntFeature"
318 elif(attr == 3):
319 attr = "BoolFeature"
320 elif(attr == 4):
321 attr = "CommandFeature"
322 elif(attr == 5):
323 attr = "FloatFeature"
324 elif(attr == 6):
325 attr = "StringFeature"
326 elif(attr == 9):
327 attr = "EnumFeature"
328 else:
329 attr = None
330
331 except:
332 attr = None
333
334 features_out['attr_type'] = attr
335 features_out['attr_enums'] = None
336 features_out['attr_cat'] = None
337
338 #Get feature's value if it exists
339 try:
340 attr = feature.value
341 except:
342 attr = None
343
344 features_out['attr_value'] = attr
345
346 #Get feature's range if it exists
347 try:
348 attr = [feature.min, feature.max]
349 except:
350 attr = None
351
352 features_out['attr_range'] = attr
353
354 #Get feature's increment if it exists
355 try:
356 attr = feature.inc
357 except:
358 attr = None
359
360 features_out['attr_increment'] = attr
361
362 #Get feature's max length if it exists
363 try:
364 attr = feature.max_length
365 except:
366 attr = None
367
368 features_out['attr_max_length'] = attr
369
370 try:
371 attr = feature_obj.tooltip
372 except:
373 attr = None
374
375 features_out['attr_tooltip'] = attr
376
377
378
379 feature_queue.put(features_out)
380 flag.set()
381 return
382
383 def read_param_value(self,param_name):
384 """!@brief Used to get value of one parameter based on its name
385 @param[in] param_name Name of the parametr whose value we want to read
386 @return A value of the selected parameter
387 """
388
389 if(self.vendor == Vendors.Allied_Vision_Technologies):
390 try:
391 with Vimba.get_instance() as vimba:
392 cams = vimba.get_all_cameras ()
393 with cams[self.active_camera] as cam:
394 return getattr(cam, param_name).get()
395 except:
396 return None
397 else:
398 try:
399 val = getattr(self.ia.remote_device.node_map, param_name).value
400 return val
401 except:
402 return None
403
404 def set_parameter(self,parameter_name, new_value):
405 """!@brief Method for setting camera's parameters
406 @details Sets parameter to value defined by new_value
407 @param[in] parameter_name A name of the parameter to be changed
408 @param[in] new_value Variable compatible with value key in parameter
409 @return True if success else returns False
410 """
411 if(self.vendor == Vendors.Allied_Vision_Technologies):
412 #EDIT to work well with new parameter dictionary (name, value, maximum etc.)
413 with Vimba.get_instance() as vimba:
414 cams = vimba.get_all_cameras()
415 with cams[self.active_camera] as cam:
416 try:
417 getattr(cam, parameter_name).set(new_value)
418 except (AttributeError, VimbaFeatureError):
419 return False
420 else:
421 try:
422 getattr(self.ia.remote_device.node_map, parameter_name).value = new_value
423 except:
424 return False
425
426 return True
427
428 def execute_command(self, command_feature):
429 """@brief Execute command feature type
430 @param[in] command_feature Name of the selected command feature
431 """
432 print(command_feature)
433 if(self.vendor == Vendors.Allied_Vision_Technologies):
434 with Vimba.get_instance() as vimba:
435 cams = vimba.get_all_cameras ()
436 with cams[self.active_camera] as cam:
437 try:
438 getattr(cam, command_feature).run()
439 print("done")
440 except:
441 print("oops")
442 pass
443 else:
444 try:
445 getattr(self.ia.remote_device.node_map, command_feature).execute()
446 except:
447 pass
448
449 def get_single_frame(self,):
450 """!@brief Grab single frame from camera
451 @details Based on vendor variable chooses right API for acquisition and
452 loads single frame from active_camera
453 @return Unmodified frame from camera
454 """
455 if(self.vendor == Vendors.Allied_Vision_Technologies):
456 while(True):
457 try:
458 with Vimba.get_instance() as vimba:
459 cams = vimba.get_all_cameras()
460 with cams [self.active_camera] as cam:
461 frame = cam.get_frame()
462 pixel_format = str(frame.get_pixel_format())
463 return [frame.as_opencv_image(), pixel_format]
464 except:
465 pass
466
467 else:
468 self.ia.start_acquisition()
469
470 with self.ia.fetch_buffer() as buffer:
471 frame = buffer.payload.components[0]
472 pixel_format = self.ia.remote_device.node_map.PixelFormat.value
473 return [frame.data, pixel_format]
474
475 self.ia.stop_acquisition()
476
477 def start_acquisition(self,):
478 """!@brief Starts continuous acquisition of image frames
479 @details Creates a threading object for the right API and starts frame
480 acquisition in that thread (producer thread)
481 """
482
483 if not self.acquisition_running:
484 self._stream_stop_switch = threading.Event()
485 self._frame_producer_thread = threading.Thread(target=self._frame_producer)
486 self._frame_producer_thread.start()
487 self.acquisition_running = True
488
489 def stop_acquisition(self,):
490 """!@brief Stops continuous acquisition
491 @details Sets stream_stop_switch, acquisition running to false and
492 removes inner link to queue object
493 """
494 #stop threads created by start_acquisition
495 if self.acquisition_running == True:
496 self._stream_stop_switch.set()
497 #this stops producer thread
498 self.acquisition_running = False
499
500 def start_recording(self,folder_path,name_scheme,configuration,):
501 """!@brief Starts continuous acquisition of image frames and saves them to files/video
502 @details Calls start_acquisition method and configures camera parameters for optimal acquisition
503 @param[in] folder_path Path where the files will be saved
504 @param[in] name_scheme Naming template for saved files
505 @param[in] configuration Parameters of output files and possibly camera parameters
506 """
507 self.start_acquisition()
508 self._frame_consumer_thread = threading.Thread(target=self._frame_consumer, args=(folder_path,name_scheme,configuration))
509 self._frame_consumer_thread.start()
510 self.is_recording = True
511
512 def stop_recording(self,):
513 """!@brief Stops continuous acquisition of image frames and closes all files
514 """
515 self.stop_acquisition()
516 self.is_recording = False
517
518 def load_config(self,path):
519 """!@brief Load existing camera configuration
520 @param[in] path Defines a path and a name of the file containing the
521 configuration of the camera
522 @return True if success else False
523 """
524 if self.vendor == Vendors.Allied_Vision_Technologies:
525 try:
526 with Vimba.get_instance() as vimba:
527 cams = vimba.get_all_cameras()
528 with cams[self.active_camera] as cam:
529 cam.load_settings(path, PersistType.NoLUT)
530 return True
531 except:
532 return False
533 else:
534 param = {}
535 val = None
536 attr_type = None
537 with open(path, 'r') as config:
538 config_dense = (line for line in config if line)
539 for line in config_dense:
540 line = line.rstrip('\n')
541 if line.startswith('attr_value') and param:
542 val = line.split('=')
543
544 if(attr_type[1] == 'IntFeature'):
545 self.set_parameter(param, int(val[1]))
546 elif(attr_type[1] == 'FloatFeature'):
547 self.set_parameter(param, float(val[1]))
548 elif(attr_type[1] == 'EnumFeature'):
549 self.set_parameter(param, val[1])
550 elif(attr_type[1] == 'BoolFeature'):
551 if(val[1] == 'True'):
552 self.set_parameter(param, True)
553 else:
554 self.set_parameter(param, False)
555 elif(attr_type[1] == 'StringFeature'):
556 self.set_parameter(param, val[1])
557
558 val = None
559 param.clear()
560 attr_type = None
561 elif line.startswith('attr_type') and param:
562 attr_type = line.split('=')
563
564 elif line.startswith('name'):
565 param['name'] = line.split('=')[1]
566 val = None
567
568 return True
569
570 def save_config(self,path):
571 """!@brief Saves configuration of a camera to .xml file
572 @param[in] path A path where the file will be saved
573 """
574 if self.vendor == Vendors.Allied_Vision_Technologies:
575 with Vimba.get_instance() as vimba:
576 cams = vimba.get_all_cameras ()
577 with cams[self.active_camera] as c:
578 #cam.save_settings(path + file_name + '.xml', PersistType.NoLUT)
579 c.save_settings(path, PersistType.NoLUT)
580 else:
581 #At the time of writing this code not Harvester nor genapi for Python
582 #supported saving .xml config, so the format of saved data created
583 #here is nonstandard and simplified for now.
584 #More here https://github.com/genicam/harvesters/issues/152
585
586 parameters = queue.Queue()
587 tmp_flag = threading.Event()
588 self.get_parameters(parameters, tmp_flag, Config_level.Invisible)
589
590 with open(path, 'w') as config:
591 while not parameters.empty():
592 param = parameters.get_nowait()
593 for key,val in param.items():
594 config.write(key + "=" + str(val) + '\n')
595 config.write('\n')
596
597 def add_gentl_producer(self,producer_path):
598 """!@brief Add a new frame producer to the harvester object
599 @details Adds .cti file specified by producer_path to the harvester object
600 @param[in] producer_path Path to a .cti file
601 @return list of all active producers
602 """
603 if(not producer_path in self.paths):
604 if(producer_path.endswith(".cti")):
605 self.h.add_file(producer_path)
606 self.paths.append(producer_path)
607
608 return self.paths
609
610 def remove_gentl_producer(self,producer_path):
611 """!@brief Remove existing frame producer from the harvester object
612 @details Removes .cti file specified by producer_path from the harvester object
613 @param[in] producer_path Path to a .cti file
614 """
615 if(producer_path in self.paths):
616 self.paths.remove(producer_path)
617 self.h.remove_file(producer_path)
618 return (self.paths, True)
619 else:
620 return(None, False)
621
622 def get_gentl_producers(self):
623 """!@brief Used to get a list of all path used by Harvesters in a
624 present moment
625 @return List of defined cti file paths
626 """
627 return self.paths
628
629 def disconnect_harvester(self,):
630 """!@brief Destroys harvester object so other APIs can access cameras
631 """
632 self.h.reset()
633
634 def disconnect_camera(self):
635 """!@brief Disconnect camera and restores the object to its initial state"""
636
637 self.stop_recording()
638 self.disconnect_harvester()
639 self.__init__(self.paths)
640
641 def _frame_producer(self):
642 """!@brief Gets frames from camera while continuous acquisition is active
643 @details Loads frames from camera as they come and stores them
644 in a frame queue for consumer thread to process. The thread
645 runs until stream_stop_switch is set
646 """
647
648 if self.vendor == Vendors.Allied_Vision_Technologies:
649 while(True):
650 #if an error occurs, the program will try again until the
651 #stream is established
652 try:
653 with Vimba.get_instance() as vimba:
654 cams = vimba.get_all_cameras()
655 with cams[self.active_camera] as c:
656 try:
657 c.start_streaming(handler=self._frame_handler_vimba)
658 self._stream_stop_switch.wait()
659 finally:
660 c.stop_streaming()
661 return
662 except:
663 pass
664 else:
665 self.ia.start_acquisition()
666
667 while(not self._stream_stop_switch.is_set()):
668 with self.ia.fetch_buffer() as buffer:
669 frame = buffer.payload.components[0]
670 pixel_format = self.ia.remote_device.node_map.PixelFormat.value
671 frame_queue.put_nowait([frame.data.copy(), pixel_format])
672 #data should contain numpy array which should be compatible
673 #with opencv image ig not do some conversion here
674 self.ia.stop_acquisition()
675
676 def _frame_consumer(self, folder_path, name_scheme, additional_config):
677 """!@brief Gradually saves frames generated by _frame_producer_thread
678 @details Uses openCV to saves images from frame_queue
679 to file_path according to additional_config
680 @param[in] folder_path Path where the files will be saved
681 @param[in] name_scheme Defines how to name output files
682 @param[in] additional_config Reserved.
683 """
684 if(folder_path[-1] != '/'):
685 folder_path = folder_path + '/'
686
687 if not os.path.exists(folder_path):
688 os.makedirs(folder_path)
689
690 n = name_scheme.find("%n")
691 if(n==-1):
692 name_scheme = name_scheme + "(%n)"
693
694 num = 0
695 extension = '.png'
696 while self.acquisition_running:
697 if not frame_queue.empty():
698 frame = frame_queue.get_nowait()[0]
699 name = name_scheme
700 name = name.replace("%t", datetime.now().strftime("%H-%M-%S"))
701 name = name.replace("%d", datetime.now().strftime("%d-%m-%Y"))
702 name = name.replace("%n", str(num))
703 #tranform image to format for ui show
704 cv2.imwrite(folder_path + name + extension, frame)
705 #because th __frame_handler saves only image data, I can save frame directly here without conversions
706 #use rather os.path.join method
707 num += 1
708
709 def _frame_handler_vimba(self,cam ,frame):
710 """!@brief Defines how to process incoming frames
711 @details Is defined for Vimba and defines how to acquire
712 whole frame and put into the frame_queue
713 """
714 try:
715 if not frame_queue.full() and frame.get_status() == FrameStatus.Complete:
716 frame_copy = copy.deepcopy(frame)
717 if self.is_recording:
718 frame_queue.put_nowait([frame_copy.as_opencv_image(),
719 str(frame_copy.get_pixel_format())])
720 active_frame_queue.put_nowait([frame_copy.as_opencv_image(),
721 str(frame_copy.get_pixel_format())])
722 else:
723 pass
724 cam.queue_frame(frame)
725 except:
726 pass
727
camera.Camera.select_camera
def select_camera(self, selected_device)
choose camera to connect to
Definition: camera.py:83
camera.Camera.devices_info
devices_info
Detected devices.
Definition: camera.py:54
camera.Camera.h
h
Harvester object used to communicate with Harvester module.
Definition: camera.py:40
camera.Camera.start_recording
def start_recording(self, folder_path, name_scheme, configuration)
Starts continuous acquisition of image frames and saves them to files/video.
Definition: camera.py:500
camera.Camera._translate_selected_device
def _translate_selected_device(self, selected_device)
attrs camera ID to index in a list of detected cameras
Definition: camera.py:125
camera.Camera.set_parameter
def set_parameter(self, parameter_name, new_value)
Method for setting camera's parameters.
Definition: camera.py:404
camera.Camera.get_camera_list
def get_camera_list(self)
Connected camera discovery.
Definition: camera.py:60
camera.Camera.is_recording
is_recording
Recording state.
Definition: camera.py:50
camera.Camera.load_config
def load_config(self, path)
Load existing camera configuration.
Definition: camera.py:518
camera.Camera
This class implements backend for the communication with cameras using Harvester and any other implem...
Definition: camera.py:32
camera.Camera.get_gentl_producers
def get_gentl_producers(self)
Used to get a list of all path used by Harvesters in a present moment.
Definition: camera.py:622
camera.Camera._frame_consumer_thread
_frame_consumer_thread
Definition: camera.py:508
camera.Camera.__init__
def __init__(self, producer_paths=None)
Initialize Camera object.
Definition: camera.py:37
camera.Camera.vendor
vendor
Camera vendor used to select the correct API.
Definition: camera.py:48
camera.Camera.active_camera
active_camera
Index of active camera for active API.
Definition: camera.py:56
camera.Camera._frame_handler_vimba
def _frame_handler_vimba(self, cam, frame)
Defines how to process incoming frames.
Definition: camera.py:709
camera.Camera.ia
ia
Image acquifier object used by Harvester.
Definition: camera.py:58
camera.Camera._frame_producer
def _frame_producer(self)
Gets frames from camera while continuous acquisition is active.
Definition: camera.py:641
camera.Camera.remove_gentl_producer
def remove_gentl_producer(self, producer_path)
Remove existing frame producer from the harvester object.
Definition: camera.py:610
camera.Camera.add_gentl_producer
def add_gentl_producer(self, producer_path)
Add a new frame producer to the harvester object.
Definition: camera.py:597
camera.Camera.read_param_value
def read_param_value(self, param_name)
Used to get value of one parameter based on its name.
Definition: camera.py:383
camera.Camera.get_parameters
def get_parameters(self, feature_queue, flag, visibility=Config_level.Unknown)
Read parameters from camera.
Definition: camera.py:142
camera.Camera._frame_consumer
def _frame_consumer(self, folder_path, name_scheme, additional_config)
Gradually saves frames generated by _frame_producer_thread.
Definition: camera.py:676
camera.Camera.start_acquisition
def start_acquisition(self)
Starts continuous acquisition of image frames.
Definition: camera.py:477
camera.Camera.disconnect_camera
def disconnect_camera(self)
Disconnect camera and restores the object to its initial state.
Definition: camera.py:634
camera.Camera.disconnect_harvester
def disconnect_harvester(self)
Destroys harvester object so other APIs can access cameras.
Definition: camera.py:629
camera.Camera.acquisition_running
acquisition_running
Image acquisition state.
Definition: camera.py:52
camera.Camera.paths
paths
paths to GenTL producers
Definition: camera.py:42
camera.Camera.save_config
def save_config(self, path)
Saves configuration of a camera to .xml file.
Definition: camera.py:570
camera.Camera.stop_recording
def stop_recording(self)
Stops continuous acquisition of image frames and closes all files.
Definition: camera.py:512
camera.Camera.execute_command
def execute_command(self, command_feature)
Definition: camera.py:428
camera.Camera.get_single_frame
def get_single_frame(self)
Grab single frame from camera.
Definition: camera.py:449
camera.Camera._frame_producer_thread
_frame_producer_thread
Definition: camera.py:485
camera.Camera._stream_stop_switch
_stream_stop_switch
Definition: camera.py:484
camera.Camera.stop_acquisition
def stop_acquisition(self)
Stops continuous acquisition.
Definition: camera.py:489