mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-29 02:21:41 +00:00
sending current pipline using zmq
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
import cscore
|
||||
from networktables import NetworkTables
|
||||
import networktables
|
||||
import cv2
|
||||
import numpy
|
||||
from cscore import CameraServer
|
||||
# from .app.classes.SettingsManager import SettingsManager
|
||||
from app.classes.SettingsManager import SettingsManager
|
||||
from ..classes.Singleton import Singleton
|
||||
import time
|
||||
from multiprocessing import Process
|
||||
import multiprocessing
|
||||
import threading
|
||||
import zmq
|
||||
|
||||
@@ -97,22 +94,27 @@ class VisionHandler(metaclass=Singleton):
|
||||
context = zmq.Context()
|
||||
socket = context.socket(zmq.REQ)
|
||||
socket.bind("tcp://*:%s" % port)
|
||||
|
||||
p = Process(target=self.camera_process, args=(cam_name, port))
|
||||
p.start()
|
||||
|
||||
pipeline = SettingsManager().cams[cam_name]["pipelines"]["pipeline0"]
|
||||
while True:
|
||||
start = time.time()
|
||||
# start = time.time()
|
||||
if(pipeline != SettingsManager().cams[cam_name]["pipelines"]["pipeline0"]):
|
||||
|
||||
pipeline = SettingsManager().cams[cam_name]["pipelines"]["pipeline0"]
|
||||
|
||||
_, image = cv_sink.grabFrame(image)
|
||||
socket.send_pyobj(image)
|
||||
socket.send_pyobj({'image': image,
|
||||
'pipeline': pipeline})
|
||||
# end = time.time()
|
||||
image = socket.recv_pyobj()
|
||||
cv_publish.putFrame(image)
|
||||
end = time.time()
|
||||
|
||||
# print(cam_name + " " + str(1 / (end - start)))
|
||||
|
||||
def camera_process(self, cam_name, port):
|
||||
|
||||
curr_pipeline = list(SettingsManager.cams[cam_name]["pipelines"].values())[0]
|
||||
|
||||
|
||||
# def change_camera_values():
|
||||
# camera.setBrightness(0)
|
||||
@@ -143,8 +145,9 @@ class VisionHandler(metaclass=Singleton):
|
||||
socket.connect("tcp://localhost:%s" % port)
|
||||
|
||||
while True:
|
||||
image = socket.recv_pyobj()
|
||||
|
||||
obj = socket.recv_pyobj()
|
||||
image = obj['image']
|
||||
curr_pipeline = obj["pipeline"]
|
||||
hsv_image = self._hsv_threshold(curr_pipeline["hue"],
|
||||
curr_pipeline["saturation"], curr_pipeline["value"],
|
||||
image, curr_pipeline["erode"], curr_pipeline["dilate"])
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"pipelines": {"pipeline0": {"exposure": 50, "brightness": 50, "orientation": "Normal", "resolution": 14, "hue": [0, 100], "saturation": [0, 100], "value": [0, 100], "erode": false, "dilate": false, "area": [0, 100], "ratio": [0, 20], "extent": [0, 100], "is_binary": "Normal"}}, "path": "/dev/v4l/by-path/pci-0000:02:03.0-usb-0:1:1.0-video-index0", "video_mode": {"fps": 15, "width": 640, "height": 480, "pixel_format": "kYUYV"}}
|
||||
{"pipelines": {"pipeline0": {"exposure": 25, "brightness": 19, "orientation": "Normal", "resolution": 11, "hue": [0, 10], "saturation": [58, 69], "value": [61, 87], "erode": false, "dilate": false, "area": [0, 100], "ratio": [0, 20], "extent": [0, 100], "is_binary": "Normal"}}, "path": "/dev/v4l/by-path/pci-0000:02:03.0-usb-0:1:1.0-video-index0", "video_mode": {"fps": 50, "width": 640, "height": 480, "pixel_format": "kYUYV"}}
|
||||
Reference in New Issue
Block a user