|
The function for thresholding works extremely fast compared by using SetPixel and GetPixel. However, i got another problem now.
My camera (frame grabber) returns the captured image in a CDC object only. And not in a Cbitmap. A CDC object does not have SetBitmapbits and GetBitmapBits members, so i cant call those. I can only access pixels in CDC using GetPixel and SetPixel. (Correct me if i'm wrong). And using Get & SetPixel is too slow, hence i needed a faster algorithm which you came up with. To use getbitmapbits, the object must be a CBItmap.
However, my question is now, how to copy contents of a CDC/DC buffer or object (already contains data) to a CBitmap object for processing, and then back to CDC object?
//------------custom hardware function that draws image from camera to DC-----------//
imgPlot ((GUIHNDL)MemDC.GetSafeHdc(), (void *)ImaqBuffer, 0, 0, Big, Big, 410, 10, plotFlag));
//-------------------------------------------
MemDC is a DC. Now contains an image copied from the camera buffer (ImaqBuffer) using a driver function.
How to copy MemDC to a CBitmap and do the thresholding with the function you came up with?
After finishing, how to copy the CBitmap back to MemDC for plotting on window etc.
THanks for the great help.
|
|
|
|
|
try using MemDC.GetCurrentBitmap() which returns a pointer to a CBitmap. Then you can do the thresholding with it.
|
|
|
|
|
Thanks, i tried that (GetCurrentBitmap), and it is exactly what i needded. Thanks a lot! You're a genius! Guess it works! Thanks a lot.
I'll find u againg, if i've got problem.. haha :P
|
|
|
|
|
uus99 wrote:
The code is too slow for real time. How can i do thresholding faster?
Can you get the hardware to give you a pointer to the image data instead of ploting it to a dc?
John
|
|
|
|
|
On a tangent :
How did you come up with RGB(64,128,255) as a B&W threshold color ?
I would have expected to take the pixel color, get its grey value, and check that against a threshold value of 128 (or whatever).
e.g.
byte grey = (byte)(
(R * 0.299) +
(G * 0.587) +
(B * 0.114)
);
...cmk
Save the whales - collect the whole set
|
|
|
|
|
John
>>Can you get the hardware to give you a pointer to the image data instead of ploting it to a dc?
The pointer to the image buffer is (void *)ImaqBuffer, however, i do not know the structure of data in it. The only way i can access it is by plotting to DC.
>>I would have expected to take the pixel color, get its grey value, and check that against a threshold value of 128 (or whatever).
I know, my comparison is just too crude. Thanks. I'll try that, but i still have to check all the pixels using SetPixel & GetPixel which is too slow. I need it fast.
>>Haven't messed with bitmaps in a while, but try GetBitmapBits(), which will give you an array of bytes containing the bitmap. Then run through this array changing values. Then call SetBitmapBits() with the modified array. This should be much faster.
I havent try this, but i will. I'll see how fast it is.
Btw, i've tried this.
1. Open a color bmp from disk and change it to B&W using LR_MONOCHROME
2. Open a color bmp, load into DC and do setpixel and getpixel.
The first method is way faster.. How come? I need a way to convert that fast. But, i want to do everything in memory to overcome disk read overhead.
Although, in this case, the 1 method is still faster, although i'm reading from disk.
|
|
|
|
|
Try creating a monochrome bitmap, and do a BitBlt() from the colour one to the monochrome one - let Windows do all the work for you. It doesn't give you control over the threshold, but might be adequate for what you need.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I want to modify the explorer.exe in xp
First,I modify the explorer.exe which in system32\dllcache,then modify the explorer in \windows,
system will notify me the file been modifyed,ask me whether resume the file.I know the system has a list
to point which files had been protected.How could I modify
the list so that I can modify the explorer.exe (any been protexted files) at will.
|
|
|
|
|
Uh... why do you want to modify explorer.exe? The only reason I can see modifing explorer.exe is malicious which is probably why you posted anonymously. If it isn't malicious you are gonna have to find a different way to do it.
Matt Newman
If you chose to continue this discussion, I am fully prepared to make you my bitch. I invite you to ask around, and you'll find out that I'm quite capable of doing so - John Simmons on Trolls
|
|
|
|
|
The files are protected for a simple reason: to prevent people from tampering with them. Even from a programmer's point of view, this is a good thing: no matter how badly your software bugged, it can't modify crucial things or endanger the operation of the system.
If you want to write an extension to the Windows Shell, see the Shell programming guide available here at CodeProject. If you want to write a completely new shell, see the source code of LiteStep.
If you just want to make the Shell do something it isn't normally supposed to do and in doing which may hamper it's operation, then you're out of luck: no can do.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi guys.
I'd like to show a dialog displaying a long amount of text, but I don't want to have the text in a text file, I'd like to have it in a resource.
What's the best way to do it?
How I have to store the information (text) in my app?
Do you know a class to do this?
Thanks a lot
Doc
|
|
|
|
|
Put a line like this in your projects .rc2 file:
RESOURCE_NAME TEXTFILE "res\\MyTextFile.txt"
Then to extract it in code:
CString target;
LoadResource(&target, "RESOURCE_NAME");
bool LoadResource(CString *script, const char* name)
{
bool bOK = false;
HRSRC hFRes = ::FindResource(AfxGetResourceHandle(), name, "TEXTFILE");
if (hFRes != NULL)
{
HANDLE hRes = ::LoadResource(AfxGetResourceHandle(), hFRes);
if (hRes != INVALID_HANDLE_VALUE)
{
char *lpRes = (char*)::LockResource(hRes);
DWORD size = SizeofResource(AfxGetResourceHandle(), hFRes);
CString format;
format.Format("%%.%1ds", size);
script->Format(format, lpRes);
::UnlockResource(hRes);
::FreeResource(hRes);
bOK = true;
}
}
return bOK;
}
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
how can i make my own custom class wizard for vs.net 2003?
thanks and greets from austria
|
|
|
|
|
Erm..
I don't quite understand what you mean.. The VS.Net 2003 has a class wizard, though it is somewhat different from the ones which ship with VS version 6. The new wizard, I think, is vastly more powerful..
But, the only thing I am aware of is writing new application wizards. I don't know if you can replace the original Class Wizard in any way.. Perhaps there's another way to accomplish what you're after ?
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I have created a socket using WSASocket function with the last parameter as Overlapped flag ie overlapped socket.
Then i have registered it for async. notification of the incoming connection using WSAAsyncSocket fn.(FD_ACCEPT). I am getting notification of the same. After accepting socket connection, i am making the accepted socket non-blocking using ioctlsocket fn. The last parameter specified is unsigned long int with the value as 1. Also i have registered for FD_WRITE notification using WSAAsyncSocket fn. which also make the socket as non-blocking socket. Now when i am pumping data on the accepted socket it is getting blocked if the client app. is reading the data slowly .. i have used WSASend fn to send the data on the network. The last two parameters of the fn is NULL. I should get WSAEWOULDBLOCK error if the send buffer of the transport layer is full but rather it is getting blocked .. i didn't understand why it is getting blocked ??
|
|
|
|
|
So everything works correctly if the client reads the data at normal speed?
I am not familiar with WSAAsyncSocket. Under non-blocking I/O model that utilizes OVERLAPPED I/O such as WSAEventSelect and IOCP, windows updates the process on the size of the actual buffer that has been sent to the remote system.
Kuphryn
|
|
|
|
|
In the debug mode i am restricting the client to read any data. The client is not reading any data but it receives the data at a very fast speed. I have specified NULL for the last two parameter of the WSASend fn.
|
|
|
|
|
hi,
i have an mdb file that i use in my mfc application. i access it thru odbc data source name. i would like to create this datasource name at install time or when i configure the program.
i tried SQLConfigDataSource, it creates the DSN but when i access with kmy app, gives an error.
can someone lead me to the right code?
|
|
|
|
|
SQLConfigDataSource() is the right function. How are you using it? What value does it return? What is the difference between the DSN that it creates and one that you create manually?
bmvbab wrote:
...but when i access with kmy app, gives an error.
What's the error?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
hy, i didnt found out, how i can do this. none of the classes i know, can
load a .avi movie and then get a certain frame as a bitmap, does anybody
has an idea, how i could do this?
thanx a lot!
|
|
|
|
|
Look in the MSDN for "AVIview: Read/Write APIs in AVIfile" for the example prog AviView.
I actually use AviView as a tool to look at individaul frames within an AVI file.
"There is no monument dedicated to the memory of a committee." - Lester J. Pourciau
|
|
|
|
|
hy, sorry, but i didnt found anything with this search string(not on the net and also not in the MSDN)!
and i also didnt found the sample prog AviView.
could you give me more details or an exact link?
thanx
|
|
|
|
|
Well it is on my MSDN! Honest
I found this link http://www.banasoft.net/Links.htm[^]
Or I can email to you it is c. 58 KB zipped including the exe file, I would suggest I email as the link could be wrong, let me know.
"There is no monument dedicated to the memory of a committee." - Lester J. Pourciau
|
|
|
|
|
hy, thanx a lot, i could download it.
the code seems quite complicated, could you maby tell me shortly, how i
can grabb a picture from an avi?
for instance load an avi, and get the 4th bitmap of the movie and store it
in a CBitmap object.
thanx a lot!
|
|
|
|
|
in aviview.c have a look at
lpbi = AVIStreamGetFrame(gapgf[giFirstVideo], 0);<br />
DrawDibBegin(ghdd[giFirstVideo], NULL,lpbi->biWidth, . . .
All drawing to the screen is done via the DrawDib functions, so add your code here to save the data to disk.
I would not say this code is very easy to follow but the concepts are straight forward, it will take a while for you to figure it out though!
Of course the new way to do this is to use DirectX but that is a different storey, the concept is the same just read the AVI frame by frame or jump to the frame you want then read/save it.
"There is no monument dedicated to the memory of a committee." - Lester J. Pourciau
|
|
|
|