Implementation for inspecting OpenCV CvMat structs
| 81 | return re.match(type_regex, symbol_type) is not None |
| 82 | |
| 83 | class CvMat(interface.TypeInspectorInterface): |
| 84 | """ |
| 85 | Implementation for inspecting OpenCV CvMat structs |
| 86 | """ |
| 87 | def get_buffer_metadata(self, obj_name, picked_obj, debugger_bridge): |
| 88 | data = picked_obj['data'] |
| 89 | if data.type == 'CvMat::(unnamed union)': |
| 90 | data = data[0] |
| 91 | buffer = debugger_bridge.get_casted_pointer('char', data) |
| 92 | if buffer == 0x0: |
| 93 | raise RuntimeError('Received null buffer!') |
| 94 | |
| 95 | width = int(picked_obj['cols']) |
| 96 | height = int(picked_obj['rows']) |
| 97 | flags = int(picked_obj['type']) |
| 98 | |
| 99 | channels = ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) |
| 100 | row_stride = int(int(picked_obj['step'])/channels) |
| 101 | |
| 102 | if channels >= 3: |
| 103 | pixel_layout = 'bgra' |
| 104 | else: |
| 105 | pixel_layout = 'rgba' |
| 106 | |
| 107 | cvtype = ((flags) & CV_MAT_TYPE_MASK) |
| 108 | |
| 109 | type_value = (cvtype & 7) |
| 110 | |
| 111 | if (type_value == symbols.OID_TYPES_UINT16 or |
| 112 | type_value == symbols.OID_TYPES_INT16): |
| 113 | row_stride = int(row_stride / 2) |
| 114 | elif (type_value == symbols.OID_TYPES_INT32 or |
| 115 | type_value == symbols.OID_TYPES_FLOAT32): |
| 116 | row_stride = int(row_stride / 4) |
| 117 | elif type_value == symbols.OID_TYPES_FLOAT64: |
| 118 | row_stride = int(row_stride / 8) |
| 119 | |
| 120 | return { |
| 121 | 'display_name': f'{obj_name} ({picked_obj.type})', |
| 122 | 'pointer': buffer, |
| 123 | 'width': width, |
| 124 | 'height': height, |
| 125 | 'channels': channels, |
| 126 | 'type': type_value, |
| 127 | 'row_stride': row_stride, |
| 128 | 'pixel_layout': pixel_layout, |
| 129 | 'transpose_buffer': False |
| 130 | } |
| 131 | |
| 132 | def is_symbol_observable(self, symbol, symbol_name): |
| 133 | symbol_type = str(symbol.type) |
| 134 | type_regex = r'(const\s+)?CvMat(\s+?[*&])?' |
| 135 | return re.match(type_regex, symbol_type) is not None |
| 136 | |
| 137 | |
| 138 | class IplImage(interface.TypeInspectorInterface): |
nothing calls this directly
no outgoing calls
no test coverage detected