MCPcopy Create free account
hub / github.com/OpenImageDebugger/OpenImageDebugger / IplImage

Class IplImage

resources/oidscripts/oidtypes/opencv.py:138–180  ·  view source on GitHub ↗

Implementation for inspecting OpenCV IplImage structs

Source from the content-addressed store, hash-verified

136
137
138class IplImage(interface.TypeInspectorInterface):
139 """
140 Implementation for inspecting OpenCV IplImage structs
141 """
142
143 types = {8: symbols.OID_TYPES_UINT8, 0x80000008: symbols.OID_TYPES_UINT8,
144 16: symbols.OID_TYPES_UINT16, 0x80000010: symbols.OID_TYPES_INT16,
145 32: symbols.OID_TYPES_FLOAT32,
146 64: symbols.OID_TYPES_FLOAT64}
147
148 def get_buffer_metadata(self, obj_name, picked_obj, debugger_bridge):
149 buffer = debugger_bridge.get_casted_pointer('char', picked_obj['imageData'])
150 if buffer == 0x0:
151 raise RuntimeError('Received null buffer!')
152
153 width = int(picked_obj['width'])
154 height = int(picked_obj['height'])
155 channels = int(picked_obj['nChannels'])
156 depth = int(picked_obj['depth'])
157 row_stride = int(int(picked_obj['widthStep']) / depth * 8)
158
159 if channels >= 3:
160 pixel_layout = 'bgra'
161 else:
162 pixel_layout = 'rgba'
163
164 return {
165 'display_name': f'{obj_name} ({picked_obj.type})',
166 'pointer': buffer,
167 'width': width,
168 'height': height,
169 'channels': channels,
170 'type': self.types[depth],
171 'row_stride': row_stride,
172 'pixel_layout': pixel_layout,
173 'transpose_buffer': False
174 }
175
176 def is_symbol_observable(self, symbol, symbol_name):
177 symbol_type = str(symbol.type)
178 type_regex = r'(const\s+)?IplImage(\s+?[*&])?'
179 result = re.match(type_regex, symbol_type) is not None
180 return result
181

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected