Hello,
The primary goal is to feel I am getting the most for the money paid for the PI Board/Camera, that what I create with it is taking full advantage of the best in modern engineering. I plan on on deploying about 10 on my own property, and 10 on my mothers property once I get the software up to par. When neighbors want me to watch their house, would like to place 4 around their property watching their stuff. We could always do a Zoom meeting or something.
1080 is like 2mp. I'm currently recording at: 2304x1296 is close to 3MP. (Of course youtube wants to down sample it to 1080p) I would like to be able to record at a higher resolution, I just don't think I can get the FPS I need. This would be to pick up licence plates closer to the road. Really wish I could get 12k video. Will revisit this later, revisit #1
I wanted to be able to preview the cameras from time to time to make sure they are functioning correctly, and there are no obstructions. If I am at my desk, and I hear a loud commotion outside, it's nice to peer up at the browser window and see what's going on. The better the browser frame rate, the better the experience. Right now, I am only able to display jpg images on an interval, I haven't figured out how to simultaneously be encoding audio and sending audio clips to the browser for near real time audio monitoring. Can pulseAudio/wire do this, or is microphone recording an exclusive lock. That will be a revisit #2
I was doing some opencv motion detection, on the RPI5 8gb 200 mb/write SSD. It's slow, and was bringing the frame rate I was able to acquire from the camera down to about 2fps. It did a good job at letting me know where the motion was occurring in the current window. I had noticed, if I used these detection areas to subsample a large frame and send that smaller clip over to darkweb's YOLO3, the object identification was substantially better as it filtered out all the noise. The speed was greatly improved. However, this second phase of the object detection was going to be to slow on the PI even at 2fps.
I was able to take your advice and startup the MJPEGEncoder simultaneously, and that did make a HUGE difference in the frame-rates. If I left my motion detection in place, I could almost get 4 FPS which was actually usable in a browser window to let you know what's going on and could actually alert you if there was motion in my yard. When I took out the motion detection opencv stuff, the MJPEGEncoder could supply about 20fps which was incredible and this is alongside of the MP4Encoder writing to a file on the SSD. So the OpenCV stuff, especially in the conversion of a JPG to a numpy array was a huge performance hit.
There is one thing I haven't figured out how to do with the MP4/MJPEG encoders. Right now, I wanted the MP4 encoder to just record continuous 10 second clips. In order to do that, it seems you have to call stop_recording() on some interval to break the recording and finish writing the file. This makes it easier to send the file to the server for quicker processing and security in having the moments before the cameras sabotage. The only bad thing with stop_recording() is that it seems to stop BOTH encoders. I want the ability to tell the MJPEG encoder to just record forever until the program stops. That way I don't notice a 2 second lag of images in my browser window when the MP4 is writing out ever 10 seconds. I'm also worried about dropped frames. Is there a better way to accomplish this?
#Setup a streaming output so that I write JPEG frames to this instead of a file so I can decide what to save and what to keep
class StreamingOutput(io.BufferedIOBase):
def __init__(self):
self.frame = None
self.condition = Condition()
def write(self, buf):
with self.condition:
self.frame = buf
self.condition.notify_all()
# Main Code Fragment:
encoder = H264Encoder(10000000)
output1 = StreamingOutput()
encoder1 = MJPEGEncoder()
#Loop until we shut the porgram down:
while not shutdown_engaged:
output = FfmpegOutput(mp4_file, audio=True)
picam2.start_recording(encoder, output, quality=Quality.VERY_HIGH)
picam2.start_recording(encoder1, FileOutput(output1))
#While we are recording to MP4, obtain some frames to send to the browser.
while tn < future :
with output1.condition:
output1.condition.wait()
curr_frame = output1.frame
#This originally was to stop the recording of the H264 (MP4) encoder, but it stops both the H264, and the MJPEG! Is there a way just to stop a particular encoder?
picam2.stop_recording()
The primary goal is to feel I am getting the most for the money paid for the PI Board/Camera, that what I create with it is taking full advantage of the best in modern engineering. I plan on on deploying about 10 on my own property, and 10 on my mothers property once I get the software up to par. When neighbors want me to watch their house, would like to place 4 around their property watching their stuff. We could always do a Zoom meeting or something.
1080 is like 2mp. I'm currently recording at: 2304x1296 is close to 3MP. (Of course youtube wants to down sample it to 1080p) I would like to be able to record at a higher resolution, I just don't think I can get the FPS I need. This would be to pick up licence plates closer to the road. Really wish I could get 12k video. Will revisit this later, revisit #1
I wanted to be able to preview the cameras from time to time to make sure they are functioning correctly, and there are no obstructions. If I am at my desk, and I hear a loud commotion outside, it's nice to peer up at the browser window and see what's going on. The better the browser frame rate, the better the experience. Right now, I am only able to display jpg images on an interval, I haven't figured out how to simultaneously be encoding audio and sending audio clips to the browser for near real time audio monitoring. Can pulseAudio/wire do this, or is microphone recording an exclusive lock. That will be a revisit #2
I was doing some opencv motion detection, on the RPI5 8gb 200 mb/write SSD. It's slow, and was bringing the frame rate I was able to acquire from the camera down to about 2fps. It did a good job at letting me know where the motion was occurring in the current window. I had noticed, if I used these detection areas to subsample a large frame and send that smaller clip over to darkweb's YOLO3, the object identification was substantially better as it filtered out all the noise. The speed was greatly improved. However, this second phase of the object detection was going to be to slow on the PI even at 2fps.
I was able to take your advice and startup the MJPEGEncoder simultaneously, and that did make a HUGE difference in the frame-rates. If I left my motion detection in place, I could almost get 4 FPS which was actually usable in a browser window to let you know what's going on and could actually alert you if there was motion in my yard. When I took out the motion detection opencv stuff, the MJPEGEncoder could supply about 20fps which was incredible and this is alongside of the MP4Encoder writing to a file on the SSD. So the OpenCV stuff, especially in the conversion of a JPG to a numpy array was a huge performance hit.
There is one thing I haven't figured out how to do with the MP4/MJPEG encoders. Right now, I wanted the MP4 encoder to just record continuous 10 second clips. In order to do that, it seems you have to call stop_recording() on some interval to break the recording and finish writing the file. This makes it easier to send the file to the server for quicker processing and security in having the moments before the cameras sabotage. The only bad thing with stop_recording() is that it seems to stop BOTH encoders. I want the ability to tell the MJPEG encoder to just record forever until the program stops. That way I don't notice a 2 second lag of images in my browser window when the MP4 is writing out ever 10 seconds. I'm also worried about dropped frames. Is there a better way to accomplish this?
#Setup a streaming output so that I write JPEG frames to this instead of a file so I can decide what to save and what to keep
class StreamingOutput(io.BufferedIOBase):
def __init__(self):
self.frame = None
self.condition = Condition()
def write(self, buf):
with self.condition:
self.frame = buf
self.condition.notify_all()
# Main Code Fragment:
encoder = H264Encoder(10000000)
output1 = StreamingOutput()
encoder1 = MJPEGEncoder()
#Loop until we shut the porgram down:
while not shutdown_engaged:
output = FfmpegOutput(mp4_file, audio=True)
picam2.start_recording(encoder, output, quality=Quality.VERY_HIGH)
picam2.start_recording(encoder1, FileOutput(output1))
#While we are recording to MP4, obtain some frames to send to the browser.
while tn < future :
with output1.condition:
output1.condition.wait()
curr_frame = output1.frame
#This originally was to stop the recording of the H264 (MP4) encoder, but it stops both the H264, and the MJPEG! Is there a way just to stop a particular encoder?
picam2.stop_recording()
Statistics: Posted by UltimateCodeWarrior — Wed Dec 18, 2024 6:22 pm