mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-03 03:01:40 +00:00
working camera process
it need more work with integration
This commit is contained in:
@@ -42,6 +42,8 @@ class CamerasHandler:
|
|||||||
|
|
||||||
camera = cscore.UsbCamera(name=device_name, dev=device.dev)
|
camera = cscore.UsbCamera(name=device_name, dev=device.dev)
|
||||||
camera.setPixelFormat(pixelFormat=camera.enumerateVideoModes()[0].pixelFormat) #TODO if dictionary is empy do this else take from dictionary
|
camera.setPixelFormat(pixelFormat=camera.enumerateVideoModes()[0].pixelFormat) #TODO if dictionary is empy do this else take from dictionary
|
||||||
|
camera.setFPS(camera.enumerateVideoModes()[0].fps)
|
||||||
|
camera.setResolution(width=camera.enumerateVideoModes()[0].width,height=camera.enumerateVideoModes()[0].height)
|
||||||
|
|
||||||
cameras[device_name] = camera
|
cameras[device_name] = camera
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import networktables
|
|||||||
import cv2
|
import cv2
|
||||||
import numpy
|
import numpy
|
||||||
from cscore import CameraServer
|
from cscore import CameraServer
|
||||||
from .CamerasHandler import CamerasHandler
|
from CamerasHandler import CamerasHandler
|
||||||
from app.classes.SettingsManager import SettingsManager
|
from app.classes.SettingsManager import SettingsManager
|
||||||
import time
|
import time
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
class VisionHandler:
|
class VisionHandler:
|
||||||
@@ -91,7 +92,8 @@ class VisionHandler:
|
|||||||
def mode_listener(table, key, value, is_new):
|
def mode_listener(table, key, value, is_new):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
image = numpy.zeros(shape=(0, 0, 3), dtype=numpy.uint8)
|
jsonn = json.loads(camera.getConfigJson())
|
||||||
|
image = numpy.zeros(shape=(jsonn['width'], jsonn['height'], 3), dtype=numpy.uint8)
|
||||||
table = NetworkTables.getTable("/Chameleon-Vision/" + camera.getInfo().name)
|
table = NetworkTables.getTable("/Chameleon-Vision/" + camera.getInfo().name)
|
||||||
|
|
||||||
table.addEntryListenerEx(pipeline_listener, key="Pipeline",
|
table.addEntryListenerEx(pipeline_listener, key="Pipeline",
|
||||||
@@ -99,17 +101,21 @@ class VisionHandler:
|
|||||||
table.addEntryListenerEx(mode_listener, key="Driver_Mode",
|
table.addEntryListenerEx(mode_listener, key="Driver_Mode",
|
||||||
flags=networktables.NetworkTablesInstance.NotifyFlags.UPDATE)
|
flags=networktables.NetworkTablesInstance.NotifyFlags.UPDATE)
|
||||||
change_camera_values()
|
change_camera_values()
|
||||||
|
cs = CameraServer.getInstance()
|
||||||
cv_sink = CameraServer.getInstance().getVideo(camera=camera)
|
cv_sink = cs.getVideo(camera=camera)
|
||||||
|
cv_publish = cs.putVideo(name='ds;fjkl',width=jsonn['width'],height=jsonn['height'])
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
start = time.time()
|
||||||
_, image = cv_sink.grabFrame(image)
|
_, image = cv_sink.grabFrame(image)
|
||||||
# hsv_image = self._hsv_threshold()
|
# hsv_image = self._hsv_threshold()
|
||||||
filtered_contours = None
|
filtered_contours = None
|
||||||
if table.getBoolean("Driver_Mode", False):
|
# if table.getBoolean("Driver_Mode", False):
|
||||||
#contours = self.find_contours(hsv_image)
|
#contours = self.find_contours(hsv_image)
|
||||||
# filtered_contours = self.filter_contours(contours)
|
# filtered_contours = self.filter_contours(contours)
|
||||||
pass
|
# pass
|
||||||
# image = self.draw_image(input_image=hsv_image, is_binary=False, rectangles=[])
|
# image = self.draw_image(input_image=hsv_image, is_binary=False, rectangles=[])
|
||||||
# stream.putFrame(image)
|
cv_publish.putFrame(image)
|
||||||
|
end = time.time()
|
||||||
|
print(1/(end-start))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user