robotpy / robotpy-cscore

Moved to https://github.com/robotpy/mostrobotpy
Other
17 stars 12 forks source link

gettting nothing while running cam in process #77

Closed oriagranat9 closed 4 years ago

oriagranat9 commented 5 years ago

while trying to run a usb cam in a process and grabbing its frames the value of the image is 0

#camera is a usb camera object
multiprocessing.Process(target=self.camera_process, args=(cam,camera_server))

 def camera_process(self, camera,cs):
   cv_sink = cscore.CvSink("test")
   cv_sink.setSource(camera)
   while True:
            _, image = cv_sink.grabFrame(image)
PeterJohnson commented 5 years ago

No, this won't work. Images are passed internally to the library between sources and sinks, and that only works within a single process. You're going to have to send the images to the subprocess yourself (e.g. via a pipe).

virtuald commented 5 years ago

@oriagranat9 what are you trying to accomplish? If you're trying to run this code on a roborio, see the documentation at https://robotpy.readthedocs.io/en/stable/vision/roborio.html

oriagranat9 commented 5 years ago

no im trying to run this on my computer in and to process each camera in parallel

virtuald commented 5 years ago

If you create your camera objects inside the camera_process function, it should work.

virtuald commented 4 years ago

Closed due to age.