You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (myFile) {
for (uint32_t i=0;i<320240;i+=2) {
myFile.write((img+i+1));
myFile.write(*(img+i));
}
Serial.println("file written successfully");
}
else {
Serial.println("FIle opening failed");
}
myFile.close();
}
void loop() {
// put your main code here, to run repeatedly:
}`
Then I wrote a python code using PIL library to display the image saved by maix 1 dock board.
`import numpy as np
from PIL import Image
from numpy import asarray
data = list()
with open("FORL2.txt", "rb") as f:
byte = f.read(1)
while byte != b"":
# print (byte)
data.append(int.from_bytes(byte, "big"))
# Do stuff with byte.
byte = f.read(1)
data = np.array(data)
image_array = np.reshape(data, (240, 320))
image2 = Image.fromarray(image_array)
image2.show()`
I took the image of my face but here's the image that was displayed by the python code -
Where am I going wrong?
The text was updated successfully, but these errors were encountered:
Hi team,
I wanted to save snapshot taken by maix one dock board to the sd card. Here's the code I wrote for it.
`#include <Sipeed_OV2640.h>
#include <Sipeed_ST7789.h>
#include<SD.h>
SPIClass spi0(SPI0); // MUST be SPI0 for Maix series on board LCD
Sipeed_ST7789 lcd(320, 240, spi0);
Sipeed_OV2640 camera(FRAMESIZE_QVGA, PIXFORMAT_RGB565);
File myFile;
File myFile2;
File myFile3;
File myFile4;
#define SWAP_SMALL(x) (x >> 8 & 0xff)
#define SWAP_16(x) ((x >> 8 & 0xff) | (x << 8))
#define LCD_MAX_PIXELS (76800)
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(100);
Serial.print("Initializing SD card...");
if (!SD.begin(29)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
myFile = SD.open("forl2.txt", FILE_WRITE);
lcd.begin(15000000, COLOR_RED);
lcd.invertDisplay(true); // comment this out when camera is on the backside
Serial.print("camera init ");
if(!camera.begin())
Serial.println("failed");
else
Serial.println("success");
camera.run(true);
delay(100);
uint8_t* img = camera.snapshot();
if (myFile) {
for (uint32_t i=0;i<320240;i+=2) {
myFile.write((img+i+1));
myFile.write(*(img+i));
}
}
else {
Serial.println("FIle opening failed");
}
myFile.close();
}
void loop() {
// put your main code here, to run repeatedly:
}`
Then I wrote a python code using PIL library to display the image saved by maix 1 dock board.
`import numpy as np
from PIL import Image
from numpy import asarray
data = list()
with open("FORL2.txt", "rb") as f:
byte = f.read(1)
while byte != b"":
# print (byte)
data.append(int.from_bytes(byte, "big"))
# Do stuff with byte.
byte = f.read(1)
data = np.array(data)
image_array = np.reshape(data, (240, 320))
image2 = Image.fromarray(image_array)
image2.show()`
I took the image of my face but here's the image that was displayed by the python code -
Where am I going wrong?
The text was updated successfully, but these errors were encountered: