Solved

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

Posted on 2011-09-08
6
689 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

628 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