I am working on a CCTV project which employs ONVIF. I use a Winform sample, which is provided by \"ONVIF Device Manager\" project, to obtain video frames from a camera. (You can
You get the error "Bitmap is already locked" because of the following line:
Bitmap bmp = img as Bitmap;
It seems that img
is declared globally, and it is being used both by your thread, and the UI thread ath the same time. When a Bitmap
object is being displayed in UI, it is being Locked by UI thread for painting. The Lock
method in your thread conflicts with this operation in UI thread.
To get better performance, I recommend you to generate a Bitmap for each frame you get in your thread. Then BeginInvoke it to display the prepared image. In UI thread you should care for disposing the Bitmap when replacing in PictureBox property.