riCOM_cpp
This repository contains the C++ implementation of the riCOM (Real Time Centre Of Mass) algorithm for 4D Scanning electron microscopy.
Camera.h
Go to the documentation of this file.
1 /* Copyright (C) 2021 Thomas Friedrich, Chu-Ping Yu,
2  * University of Antwerp - All Rights Reserved.
3  * You may use, distribute and modify
4  * this code under the terms of the GPL3 license.
5  * You should have received a copy of the GPL3 license with
6  * this file. If not, please visit:
7  * https://www.gnu.org/licenses/gpl-3.0.en.html
8  *
9  * Authors:
10  * Thomas Friedrich <thomas.friedrich@uantwerpen.be>
11  * Chu-Ping Yu <chu-ping.yu@uantwerpen.be>
12  */
13 
14 #ifndef CAMERA_H
15 #define CAMERA_H
16 
17 #include <vector>
18 #include <atomic>
19 #include <array>
20 #include <stdlib.h>
21 
22 // Only forward declaration for Ricom class
23 class Ricom;
24 
25 
26 
27 namespace CAMERA
28 {
30  {
35  };
36 
38  {
41  };
42 
44  {
45  public:
48  uint16_t nx_cam;
49  uint16_t ny_cam;
51  uint16_t depth;
52  size_t group_size;
54 
55  std::vector<int> u;
56  std::vector<int> v;
57  void init_uv_default();
58 
61  nx_cam(256),
62  ny_cam(256),
63  swap_endian(true),
64  depth(1),
65  group_size(1),
66  dwell_time(1000){};
67 
68  };
69 
70  // primary template
71  template <class CameraInterface, CAMERA::Camera_type cam_type>
72  class Camera : public CameraInterface, public Camera_BASE
73  {
74  };
75 
76  // specialization for frame based camera
77  template <class CameraInterface>
78  class Camera<CameraInterface, FRAME_BASED> : public CameraInterface, public Camera_BASE
79  {
80  public:
81  Camera();
82  explicit Camera(Camera_BASE &cam);
83  void run(Ricom *ricom);
84  template <typename T>
85  void read_frame(std::vector<T> &data, bool b_first);
86  };
87 
88  // specialization for event based camera
89  template <class CameraInterface>
90  class Camera<CameraInterface, EVENT_BASED> : public CameraInterface, public Camera_BASE
91  {
92  public:
93  Camera();
94  explicit Camera(Camera_BASE &cam);
95  void run(Ricom *ricom);
97  std::vector<size_t> &dose_map,
98  std::vector<size_t> &sumx_map, std::vector<size_t> &sumy_map,
99  std::vector<float> &stem_map, bool &b_stem,
100  std::array<float, 2> &offset, std::array<float, 2> &radius,
101  int &processor_line, int &preprocessor_line, size_t &first_frame, size_t &end_frame
102  );
104  std::vector<size_t> &dose_map,
105  std::vector<size_t> &sumx_map, std::vector<size_t> &sumy_map,
106  std::vector<float> &stem_map, bool &b_stem,
107  std::array<float, 2> &offset, std::array<float, 2> &radius,
108  std::vector<size_t> &frame, std::array<std::atomic<size_t>, 3> &frame_id_plot_cbed,
109  int &processor_line, int &preprocessor_line, size_t &first_frame, size_t &end_frame
110  );
111  };
112 
114  {
115  public:
117  CAMERA::Camera_BASE &operator[](unsigned int index);
118  std::array<CAMERA::Camera_BASE, CAMERA::MODELS_COUNT> hws;
119 
120  private:
121  CAMERA::Camera_BASE *hws_ptr;
122  };
123 }
124 
125 #endif // CAMERA_H
void read_frame_com(std::vector< size_t > &dose_map, std::vector< size_t > &sumx_map, std::vector< size_t > &sumy_map, std::vector< float > &stem_map, bool &b_stem, std::array< float, 2 > &offset, std::array< float, 2 > &radius, int &processor_line, int &preprocessor_line, size_t &first_frame, size_t &end_frame)
void read_frame_com_cbed(std::vector< size_t > &dose_map, std::vector< size_t > &sumx_map, std::vector< size_t > &sumy_map, std::vector< float > &stem_map, bool &b_stem, std::array< float, 2 > &offset, std::array< float, 2 > &radius, std::vector< size_t > &frame, std::array< std::atomic< size_t >, 3 > &frame_id_plot_cbed, int &processor_line, int &preprocessor_line, size_t &first_frame, size_t &end_frame)
void read_frame(std::vector< T > &data, bool b_first)
size_t group_size
Definition: Camera.h:52
uint16_t ny_cam
Definition: Camera.h:49
Camera_type type
Definition: Camera.h:47
Camera_model model
Definition: Camera.h:46
std::vector< int > v
Definition: Camera.h:56
std::vector< int > u
Definition: Camera.h:55
void init_uv_default()
Definition: Camera.cpp:21
uint16_t depth
Definition: Camera.h:51
uint16_t nx_cam
Definition: Camera.h:48
CAMERA::Camera_BASE & operator[](unsigned int index)
Definition: Camera.cpp:45
std::array< CAMERA::Camera_BASE, CAMERA::MODELS_COUNT > hws
Definition: Camera.h:118
Definition: Ricom.h:154
Definition: Camera.h:28
Camera_model
Definition: Camera.h:30
@ TIMEPIX
Definition: Camera.h:32
@ CHEETAH
Definition: Camera.h:33
@ MODELS_COUNT
Definition: Camera.h:34
@ MERLIN
Definition: Camera.h:31
Camera_type
Definition: Camera.h:38
@ FRAME_BASED
Definition: Camera.h:39
@ EVENT_BASED
Definition: Camera.h:40