Tool/software:
Hello everyone,
I'm trying to connect MSP430FR5994 with OV7670 (with FIFO memory), getting an image data (not for video streaming) and show it on the PC screen (with Python code). I can successfully read the data from OV7670's FIFO memory and store it into MSP430FR5994's FRAM. I can also send this data to PC via MSP430FR5994's UART. However, when I want to show the image on the sceen, I will get the window which is all garbled, shown as below:
I also noticed that the data received on PC would include some weird data, like "m", "i", "~". I thought the data I got should be the number between 0~f.
This is my Python code to show the image window:
import serial import numpy as np import cv2 SERIAL_PORT = 'COM9' BAUD_RATE = 115200 IMAGE_WIDTH = 160 IMAGE_HEIGHT = 120 IMAGE_SIZE = IMAGE_WIDTH * IMAGE_HEIGHT def receive_image(): with serial.Serial(SERIAL_PORT, BAUD_RATE, timeout=5) as ser: print("waiting for data...") data = ser.read(IMAGE_SIZE) if len(data) == IMAGE_SIZE: print("receive successfully, data length:", len(data)) print(data) return np.frombuffer(data, dtype=np.uint8).reshape((IMAGE_HEIGHT, IMAGE_WIDTH)) else: print("receive failed, data length:", len(data)) return None image = receive_image() if image is not None: cv2.imshow("OV7670 Image", image) cv2.waitKey(0) cv2.destroyAllWindows()
The image format I used is 160x120 with RGB565.
I am wondering how to fix this problem? Is it caused by some image encoding/decoding problems?
Thanks,
YaTong
Hi YaTong,
Did you check the data stream typing? Sometimes the expected format is different than what you're intending to send. For example if you're expecting a hex format but the PC is expecting an ASCII, it would convert the given hex into ascii and display that value instead.
Can you go back and only send 1 character from the MSP430 to the PC and see if the value received is the same as what you had sent.
Regards,
Luke
RGB565 sounds like a 16-bit datum (big-endian, I suspect) but I don't see anything which reconstructs those words from the bytes you're working with.
You might try starting with something like an 8-bit grayscale, until you're sure all the other pieces are in order.
**Attention** This is a public forum