Solved

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

Posted on 2011-09-08
6
688 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Acrinis True image 2 121
Formula problem with Excel attachment 6 45
maximize the sum of fractions 33 75
VB6 - Check if date format = "MM/DD/YYYY' and check if date also exist 23 78
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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