producer/producer.py
def publish_camera(producer, frameDetails):
    """
    Publish camera video stream to specified Kafka topic.
    Kafka Server is expected to be running on the localhost. Not partitioned.
    """

    print("publishing webcam...")

    camera = cv2.VideoCapture(0)
    try:
        frame_sample = frameDetails.frameRate
        count = 1
        while True:

            while count % frame_sample != 0:
                count += 1
                success, frame = camera.read()

            count += 1
            ret, buffer = cv2.imencode(".jpg", frame)
            frameDetails.setFrame(count, buffer.tobytes())

            producer.send(frameDetails.topic, frameDetails)

            # Choppier stream, reduced load on processor
    #            time.sleep(3)

    except Exception as e:
        traceback.print_exc()
        print("\nExiting.")
        sys.exit(1)

    camera.release()

    Publish camera video stream to specified Kafka topic.
    Kafka Server is expected to be running on the localhost. Not partitioned.
    
Publish camera video stream to specified Kafka topic.
Kafka Server is expected to be running on the localhost. Not partitioned.
Publish camera video stream to specified Kafka topic . Kafka Server is expected to be running on the localhost . Not partitioned .
def publish_camera(producer, frameDetails):
    print("publishing webcam...")
    camera = cv2.VideoCapture(0)
    try:
        frame_sample = frameDetails.frameRate
        count = 1
        while True:
            while count % frame_sample != 0:
                count += 1
                success, frame = camera.read()
            count += 1
            ret, buffer = cv2.imencode(".jpg", frame)
            frameDetails.setFrame(count, buffer.tobytes())
            producer.send(frameDetails.topic, frameDetails)
    except Exception as e:
        traceback.print_exc()
        print("\nExiting.")
        sys.exit(1)
    camera.release()
def publish_camera ( producer , frameDetails ) : print ( "publishing webcam..." ) camera = cv2 . VideoCapture ( 0 ) try : frame_sample = frameDetails . frameRate count = 1 while True : while count % frame_sample != 0 : count += 1 success , frame = camera . read ( ) count += 1 ret , buffer = cv2 . imencode ( ".jpg" , frame ) frameDetails . setFrame ( count , buffer . tobytes ( ) ) producer . send ( frameDetails . topic , frameDetails ) except Exception as e : traceback . print_exc ( ) print ( "\nExiting." ) sys . exit ( 1 ) camera . release ( )
Publish camera video stream to specified Kafka topic.
Publish camera video stream to specified Kafka topic .
"""
    Publish camera video stream to specified Kafka topic.
    Kafka Server is expected to be running on the localhost. Not partitioned.
    """ # Choppier stream, reduced load on processor #            time.sleep(3)
producer
frameDetails