Not possible to do anything on the VC itself without access to source, compilers and knowledge.tasanakorn wrote:Yes. process on encoder input buffer in I420 format (12 bit per pixel, 1,382,400 bytes per frame).
It should be better if we can process in video core.
Code: Select all
def _createImage(self, imgBuf, width, height): planeSize = width*height img=np.zeros((height, width, 3), np.uint8) # Luma y = np.fromstring(imgBuf[:planeSize], dtype='uint8') y.shape = (height, width) img[:,:,0] = y # Chroma is subsampled, i.e. only available for every 4-th pixel (4:2:0), we need to interpolate u = np.fromstring(imgBuf[planeSize:planeSize+planeSize/4], dtype='uint8') u.shape = (height/2, width/2) img[:,:,1] = cv2.resize(u, (width, height), cv.CV_INTER_LINEAR) #@UndefinedVariable v = np.fromstring(imgBuf[planeSize+planeSize/4: planeSize+planeSize/2], dtype='uint8') #@UndefinedVariable v.shape = (height/2, width/2) img[:,:,2] = cv2.resize(v, (width, height), cv.CV_INTER_LINEAR) #@UndefinedVariable return cv2.cvtColor(img, cv.CV_YCrCb2RGB) #@UndefinedVariable
Hi,nicolas_darkn wrote:Hello tasanakorn,
just a question. How do you do to loop your image acquisition? Do you start in loop you software or you have had a loop into your code?
geo wrote:Hi All
When using the original video_record.c from tasanakorn the CPU load went up to 85%.
To reduce CPU load while recording video i slowed down the overlay update rate in main() ,usleep(1000000) . The problem then was that if the overlay is redrawn while it was copied in to the videostream the text was flickering. Sorry about my coding , but C is not my first language.
So i tried the following:
1. Added a 'double buffer' for the overlay drawing , not knowing much about cairo i added a second cairo context.
2. camera_video_buffer_callback : the last updated overlay_buffer is copied to the videostream
3. main() : the now inactive buffer is redrawn then marked active.
Since i get GPS data every 1 sec im happy updating the overlay_buffer only when new gps data is available.
CPU load is less than 5% with video-size 640x480.:w
3020 pi 20 0 67816 5076 2140 S 4.2 1.3 0:01.16 mmal_video_reco
3028 pi 20 0 4680 1456 1028 R 1.3 0.4 0:00.21 top
I'm new to git , not knowning how to puplish the changes to the original repository i forked tasanakorn's repository to https://github.com/george-ch/rpi-mmal-demo
Users browsing this forum: No registered users and 13 guests