天天看點

SXH232攝像頭使用示範

it occurred to me suddenly that i wanted to program the our camera sensor for pc desktop, just like the one purchased from shop, which can make the video recording. finally although the result seemed

not to be as good as expected, it improved me.

here i used the sxh232-v1 camera. judging from literal meaning, it has rs232 port obviously.so first connect the camera to pc with 232 port correctly. then create a winform vs project, and create

a form like this:

SXH232攝像頭使用示範

here's what i intend to do. when i click "start taking photo" button, the picture taken by camera is showed in the picturebox in no time.if the speed is fast enough, then we'll

see a video made up of several frames of pictures. however to my pity, i haven't done it completely, which means it has a few seconds of delay.

ok, then let's see the main code:

first create some private members and initiate the form and camera

when i start taking, the message handling function creates two threads. one is responsible for taking picture, another for showing it.

the above are two threads. one puts the image into queue, anther gets image from the queue.

of course, there is an important problem here. how do we get the data from camera? well, we should write the camera driver according to camera document. as for the code, you

finally build the execute the program. let's watch a snapshot from camera:

SXH232攝像頭使用示範

it has to be acknowledged that this program has imperfections. sometimes after a little long time running, it will raise a kind of exception. apparently there are errors in

my code. furthermore,  i'm looking forward to seeing the real-time video instead of the delayed pictures, but actually i've no idea whether it can be achieved. i had thought that i could handle it with threads programming. anyway something's wrong with my

design.

繼續閱讀