Files
dragonpilot/selfdrive/camerad/test/frame_test.py
Adeeb Shihadeh 312b681a46 cereal cleanup part 2 (#20092)
* car stuff

* thermal

* Revert "car stuff"

This reverts commit 77fd1c65ebd01abfa8493ae12c9e6b14f7ada976.

* panda state

* camera stuff

* start deg

* most is building

* builds

* planner + controls run

* fix up paramsd

* cleanup

* process replay passes

* fix webcam build

* camerad

* no more frame

* thermald

* ui

* paramsd

* camera replay

* fix long tests

* fix camerad tests

* maxSteeringAngle

* bump cereal

* more frame

* cereal master
2021-02-16 21:39:32 -08:00

38 lines
979 B
Python
Executable File

#!/usr/bin/env python3
import numpy as np
import cereal.messaging as messaging
from PIL import ImageFont, ImageDraw, Image
font = ImageFont.truetype("arial", size=72)
def get_frame(idx):
img = np.zeros((874, 1164, 3), np.uint8)
img[100:400, 100:100+(idx % 10) * 100] = 255
# big number
im2 = Image.new("RGB", (200, 200))
draw = ImageDraw.Draw(im2)
draw.text((10, 100), "%02d" % idx, font=font)
img[400:600, 400:600] = np.array(im2.getdata()).reshape((200, 200, 3))
return img.tostring()
if __name__ == "__main__":
from common.realtime import Ratekeeper
rk = Ratekeeper(20)
pm = messaging.PubMaster(['roadCameraState'])
frm = [get_frame(x) for x in range(30)]
idx = 0
while 1:
print("send %d" % idx)
dat = messaging.new_message('roadCameraState')
dat.valid = True
dat.frame = {
"frameId": idx,
"image": frm[idx % len(frm)],
}
pm.send('roadCameraState', dat)
idx += 1
rk.keep_time()
#time.sleep(1.0)