Skip to content

Commit 07f0fc8

Browse files
authored
Adhere to PEP 8
1 parent cb3fd7a commit 07f0fc8

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

cameraDisplayModule.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
import os
44
import robomodules as rm
55
from messages import *
6-
import cv2, pickle, pygame, numpy
6+
import cv2
7+
import numpy
8+
import pickle
9+
import pygame
710

8-
ADDRESS = os.environ.get("BIND_ADDRESS","localhost")
11+
ADDRESS = os.environ.get("BIND_ADDRESS", "localhost")
912
PORT = os.environ.get("BIND_PORT", 11297)
1013

1114
FREQUENCY = 0
1215
SCREEN_SIZE = 800
1316

17+
1418
class CameraDisplayModule(rm.ProtoModule):
1519
def __init__(self, addr, port):
1620
self.subscriptions = [MsgType.CAMERA_FRAME_MSG]
17-
super().__init__(addr, port, message_buffers, MsgType, FREQUENCY, self.subscriptions)
21+
super().__init__(addr, port, message_buffers, MsgType, FREQUENCY,
22+
self.subscriptions)
1823
self.frame = None
1924
pygame.init()
2025
self.display = pygame.display.set_mode((SCREEN_SIZE, SCREEN_SIZE))
@@ -25,22 +30,23 @@ def msg_received(self, msg, msg_type):
2530
if msg_type == MsgType.CAMERA_FRAME_MSG:
2631
self.frame = msg.cameraFrame
2732
self._display_serialized_image()
28-
33+
2934
def tick(self):
3035
# FREQUENCY is 0, so this will never be called.
3136
return
3237

3338
def _display_serialized_image(self):
34-
if self.frame == None:
39+
if self.frame is None:
3540
print('frame == None')
3641
return
3742
frame = pickle.loads(self.frame)
38-
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
43+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
3944
frame = numpy.rot90(frame)
4045
frame = pygame.surfarray.make_surface(frame)
41-
self.display.blit(frame,(0,0))
46+
self.display.blit(frame, (0, 0))
4247
pygame.display.flip()
4348

49+
4450
def main():
4551
module = CameraDisplayModule(ADDRESS, PORT)
4652
module.run()

0 commit comments

Comments
 (0)