LoginSignup
0
0

esp32-camのCameraWebServerで表示されるページを調整する

Posted at

esp32-camのCameraWebServerで表示されるページのhtmlソースは
camera_index.hの

const uint8_t index_ov2640_html_gz[] 

などにgzip圧縮されたstringが16進数表示で格納されている。

人が読めるソースにするには
https://note.com/khe00716/n/n52f6ccf3cc96
にあるように、

ov2640 =bytes([
〜省略〜
])
print(len(ov2640))
data = gzip.decompress(ov2640)
print(data.decode())

などとする。


さて、調整したhtmlを埋め込み直すなら、html文字列をhexの配列にする必要がある。

例えば、pythonなら下記

target_str="""
<!DOCTYPE html>
<html lang="en">

省略

</html>
"""

compressed_value = gzip.compress(bytes(target_str.replace("\n",""), 'utf-8')).hex()

print(len(compressed_value))

print("----------------")
i = 0
j = 2
for _ in range(len(compressed_value) // 2):
	if i>0:
		print(",",end='')
	print("0x"+compressed_value[i:j],end='')
	i += 2
	j += 2

出てきた値を

#define index_ov2640_html_gz_len XXX
const uint8_t index_ov2640_html_gz[] = {
YYY
};

にコピペすればいい。

※上記でtarget_strは、改行を無くしているので、コメント行があるとそこ以降がコメントになってしまう可能性があるので注意

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0