Solved

How to save current pic of PictureBox VB6 control and compare it with new pic?

Posted on 2011-09-08
6
671 Views
Last Modified: 2012-05-12
Dear experts!

I have a picture control with VB6 desktop application. I pass his hWnd to a OCX which put picture in it. Actually a OCX provide me with preview of played video.  But in 5-10 min.  it block and show empty (black screen). Of course, first plan are to check the OCX, but it is on C and rule external device which it not under my control,also it may be driver problem . A possible  solution is to do workaround and to restart the control, then it continue fine. But I should detect that there is no change in picture last 2 or 5 sec.

So the question is: how to save current picture from PictureBox control and how to compare it after 2 sec. May be I need to get bytes of current pics and to compare it with old bytes? Only count of bytes, or to make some fast check sum over it?  Give me advice please.

I prefer to do this without save picture to file and check bytes of files, as it is slow and I'm sure all can be solved in memory only.

For C experts, if you give me idea about API fuctions may be I'll be able to call it from Vb6.
0
Comment
Question by:dvplayltd
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:satsumo
ID: 36506834
Are you trying to detect a black screen or no change in the picture?

You could try sending a WM_PRINTCLIENT message to the PictureBox.  You create a DC and pass it to the control as a parameter of the message.  If the control handles that message it will draw itself into the DC.

You could use GetPixel to test the image.  Alternatively, you can get the image into memory by using CreateDIBSection to allocate a memory buffer for the image, select the created DIB into a second DC then use BitBlt to copy the image into the buffer.
0
 
LVL 17

Accepted Solution

by:
inthedark earned 500 total points
ID: 36507241
There is a technique called DMA where you can map an array using a safe array gizmo to point the array to the same memory as the picture image.

you can then copy the image by moving from one array to another then you can compare the 2 arrays.
it all works in vb but depending on the pixel size vb may be too slow.

I would create a c++ dll to do the copy and compare. vb would take about 2 seconds to compare the images.in c++ you can drop in to assembler and compare or copy the images in a flash.

A cool thing to do is create a 3 byte UDT as a basis for your array in this way you can create your image copy as a greyscale which can sometimes work better when monitoring images in sunny location where the image changes with cloud movement or wind.

for internal images under fixed lighting it would be faster to keep the array as a simple byte array.

If you want to learn more I can post some code.
0
 

Author Comment

by:dvplayltd
ID: 36509055
To satsumo

>>Are you trying to detect a black screen or no change in the picture?

I'm trying to detect no change in picture. It should be fast and to not consume many resourses. The images will be in same widht, height and colour scheme, but I believe they will get different size in memory. May be best will be to check how much size in memory they take and if it is different, then the images are different.   But how ?

Please, give me API call, you may use C or C++, I'll do it in VB6.

To inthedark

Seems to me too many resourses to copy all bytes of the image on different memory. How can I get access to the memory of picture and get his size in bytes? Post some code please
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 12

Expert Comment

by:satsumo
ID: 36509940
I don't know the context of what your working on, if the picture is from a camera and the camera is pointed at a brick wall, then the image will not change, even when the camera is working.  I guess thats no relevant in this case?

Did you understand how to do the API calls in my first comment?
0
 

Author Comment

by:dvplayltd
ID: 36511108
The picture is not from camera, it is from video movies broadcasted from TV channels, so it is always change in a sec. .

Well, I have great practice with API call, but please send me excatly name of API and his order. Will be OK if it is real code in C . I have option to put this code in OCX in C, if I do not manage it under VB6. But I'm sure I'll ..many programmer are surpised what I can do with VB6 and API ... :-)

And again, I need this to be as fast as is possible and to not consume hardware, perfect will be to get just size in bytes in memory.
0
 

Author Closing Comment

by:dvplayltd
ID: 36565378
not complate answer.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now