I forgot to mention that I also attempted to do that, however I get the error that dimensions don’t work out when done this way.
/imx219@10 - Selected sensor format: 1920x1080-SBGGR10_1X10 - Selected unicam format: 1920x1080-pBAA
Traceback (most recent call last):
File "/home/FordMontana/tflite1/webcam.py", line 173, in <module>
interpreter.set_tensor(input_details[0]['index'],input_data)
File "/home/FordMontana/.local/lib/python3.9/site-packages/tflite_runtime/interpreter.py", line 720, in set_tensor
self._interpreter.SetTensor(tensor_index, value)
ValueError: Cannot set tensor: Dimension mismatch. Got 4 but expected 3 for dimension 3 of input 0.
Perhaps I am not removing it properly, but the way I went about it is shown below.
# Acquire frame and resize to expected shape [1xHxWx3]
frame = frame1.copy()
#frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame_resized = cv2.resize(frame, (width, height))
input_data = np.expand_dims(frame_resized, axis=0)
# Normalize pixel values if using a floating model (i.e. if model is non-quantized)
if floating_model:
input_data = (np.float32(input_data) - input_mean) / input_std
# Perform the actual detection by running the model with the image as input
interpreter.set_tensor(input_details[0]['index'],input_data)
interpreter.invoke()