jeffbass / imagenode

Capture and Selectively Send Images and Sensor Data; detect Motion; detect Light
MIT License
38 stars 19 forks source link

Implementation #23

Open mohan51 opened 1 year ago

mohan51 commented 1 year ago

how you implemented the imagenode in raspberrypi and what changes we need to do?I am testing this project using single raspberrypi as imagenode and my pc(linux os) as image hub.what changes do i need to do for running this project successfully using my resources?

jeffbass commented 1 year ago

imageZMQ always sends and receives (text, image) tuples. If text = 'Hello World', then this is what sender and receiver lines of code need to be:

text = 'Hello World'  # text variable contains the text you want to send

# sender always sends text and image that are its 2 arguments
sender.send_image(text, image)  # sender side will send the 'Hello World' in the text variable

# receiver always receives a tuple of 2 variables: text, image 
# Why are you throwing away "text" with a "_" variable in your example?
text, frame = receiver.recv_image()  # will receive text in first variable; don't throw it away
print(text)
# prints 'Hello World' which is the text you sent

Copying your code from above as an example, the correct way to send 'Hello World' will be:

while True:
    text = 'Hello World'
    image = np.zeros((100,300,3),dtype=np.uint8)
    # NOT THIS: cv2.putText(image,text,(10,50),font,1,(255,255,255),2,cv2.LINE_AA)
    sender.send_image(text,image)  # 'Hello World' is in the text variable

Code snippet on subscriber side:
while True:
    text, frame = receiver.recv_image()  # text receives 'Hello World' that was sent
    _, jpeg = cv2.imencode('.jpg', frame)
    frame_bytes = jpeg.tobytes()