|
I hope this question is not too basic for this forum but I have been working at this for a while now and need to get something working.
I would like to be able to place a bitmap in my IE window when predetermined web pages are accessed, detect mouse clicks etc in IE and have IE function normally for all other pages.
I program in C/C++ and already have an intermediate level of familiarity with visual studio 2005 and mfc and have looked into BHOs, COM, ATL and ActiveX and find myself a bit overwhelmed.
If someone could just lay out a road map for me of the essentials so that I know what study path to follow to get to the point where I can build the above add on I would greatly appreciate it. Please point me to any existing apps that you know of that may help as well.
Thanks in advance for any help.
|
|
|
|
|
|
Hi-
I have been trying to work out how to delete a single point from a quad tree and am having no luck at all. Below are the code snippets for delete the entire tree then my failed attempt at deleting a single point. If someone could explain what I am doing wrong I would appreciate it.
Deleting the entire tree:
qnode *
deleteTree (qnode * root)
{
int i = 0;
for (i = 0; i < 4; i++)
{
if (root == NULL)
return root;
if (root->children[i] != NULL)
{
free (root->children[i]);
deleteTree (root->children[i]);
if (root->leaf == TRUE)
{
free (root);
root->leaf = NULL;
}
root->children[i] = NULL;
root->leaf;
root->cx = NULL;
root->cy = NULL;
root->size = NULL;
}
}
}
Failed attempt to delete a single point:
qnode *
deleteP (qnode * root, int vx, int vy)
{
int i = 0;
if (root->px - 5 >= vx && vx <= root->px + 5 && root->py - 5 >= vy && vy <= root->py + 5)
{
if (root == NULL)
return root;
if (root->leaf == TRUE)
{
root->leaf = NULL;
free (root);
}
else
{
root->leaf = TRUE;
deleteP (root, vx, vy);
root->px = NULL;
root->py = NULL;
free (root);
}
}
}
Thank you for your time
|
|
|
|
|
First, you have bugs in your deleteTree implementation.
Chidori-chan wrote:
free (root->children[i]);
deleteTree (root->children[i]);
This is undefined behavior. Once you have freed the child node, it is no longer yours and you must not access it. Reverse the order of these two lines.
There are more problems in your deleteTree implementation as well. I will let you work on finding them.
Perhaps I am wrong here, but I would think that deleting a single point actually means deleting the entire subtree starting from that point. Otherwise, what do you do about all those would be orphaned nodes? So I expected to see a call to deleteTree somewhere in deleteP. I didn't find it.
Also, I would think that you need to traverse the tree to locate the point to be deleted. I would expect that to be the first thing you would have to deal with, but don't see it in your code.
Please do not read this signature.
|
|
|
|
|
Without fully understanding the code above I noticed a couple of things in the deleteTree() function:
if (root->leaf == TRUE)
{
free (root);
root->leaf = NULL;
}
You then continue using the root pointer.
The following statement is meaningless.
root->leaf;
In the following block in the deleteP() function:
if (root->leaf == TRUE)
{
root->leaf = NULL;
free (root);
}
there is no point in setting root->leaf to null, as you immediately free the object. Similarly in the else block you set two pointers to null immediately before freeing the object.
Also both functions have paths that do not return values, and thus should not compile.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Thank you all for your help, keeping your advice in mind I have come up with these functions and it kinda works. It will delete points only in a certain area of the screen..
int checkKids(qnode *parent)
{
int i;
for(i = 0; i < 4; ++i)
if(parent->children[i] != NULL)
return 0;
return 1;
}
void deletE(qnode *root)
{
if(checkKids(root) && !root->leaf)
{
root = NULL;
free(root);
}
else
{
int i;
for(i = 0; i < 4; ++i)
if(root->children[i] != NULL)
deletE(root->children[i]);
}
}
void deletePoint()
{
deletE(root);
}
void deletePointS (int sx, int sy, qnode *root)
{
int i;
for(i=0; i<4; i++)
{
if(root->children[i] != NULL)
{
if(root->children[i]->leaf == TRUE)
{
if(isIn(root->children[i]->px, root->children[i]->py, sx, sy, 5))
{
root->children[i] = NULL;
free(root->children[i]);
if(checkKids(root))
{
free(root);
root = NULL;
}
return;
}
}
else
{
deletePointS(sx, sy, root->children[i]);
}
}
}
}
void deleteNode (int sx, int sy)
{
int deleting;
if(deleting == 1)
return;
deleting = 1;
deletePointS(sx, sy, root);
deletePoint();
deleting = 0;
}
|
|
|
|
|
Hi there,
Does anyone know if there's a possibility to implement a fast translation-, rotation- and scalation-invariant Template Matching application in native C++.
I want to realize that task by using open-source libraries such as OpenCV and fftw.
I just read about techniques with log-polar transformations or circular/radial filters to find the template location, after that I may need some kind of cross-correlation?!
Has anyone other suggestions than that?
And which one would be the fastest?
I have to operate on realtime and I know, that this task is very computational intensive. But it's also ok to take a learning-phase with the template, in which some preparing computations can be done.
I have also the possiblity to work on a limited factor size in rotation and scalation (maybe +/-10%).
What would you recommend me to do or has anyone done a similar project?
Or are there some good open-source libraries to manage that?
I'd be happy about some suggestions! Thanks in advance!
cherry
|
|
|
|
|
I've been doing some work with OpenCV for about a year or so now. Not knowing exactly what you're trying to accomplish, the short answer is yes. What size images are you planning to work with and what frame rate do you consider "real time". Those are the two big tradeoffs with any image processing. I'd say from the description, you're not going to get anywhere near 30 frames a second for any reasonable sized images, especially with the FFT thrown in. At least on a standard PC.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Thanks for the quick answer! Sounds not too bad
My aim is to do a print quality inspection respective a defect detection on prints.
The images may surely be up to 800x600 pixels (also smaller).
I'll be working on RT VxWorks on an x86 Target. Nothing too special.
The quality inspection is done on i.e. business cards, label or something in bank note size.
I want to "learn in" a good template, to which following images are being compared.
Images are being acquired quickly from a camera and have to be matched as fast as possible.
I thought, if the search angle and the scale factor are limited, the computation can get pretty acceptable.
But I'm not sure which method to focus:
-The log-polar transformation seems interesting, but I'm not sure if that obtains acceptable computation times.
30 frames per second would be quite ok!
-Circular/Radial filter seems more complex and intensive and is maybe not the right approach here?!
In principle I do not have to find multiple templates in the images. I just want to relocate the inspection image to
fit to the template and then find out the defect pixels (correlation)! Just a little scalation has to be considered (5%).
Maybe template matching is the wrong approach because most template matching algorithms search for multiple occurences of
small objects.
Or am I though right with my thoughts?
bye, cherry
|
|
|
|
|
Sounds like a first pass would be doing some kind of difference score between the image and your template. I know OpenCV has some template matching functions but I've not played with them. Most of my time so far has been spent in building a framework to all me to quickly build test apps to try things and I spend a lot of time taking Gary's name in vain (along with Bill, Bjarne, and occasionally Julian). My applications are more related to SLAM for robotics.
It sounds like your images will be fairly consistent so I'd see if I could determine some easily detected points to use to determine orientation and scale without having to do anything too general. Then you can apply your matching method with a bit more confidence.
In one of my tests, I'm working with a 360x240 image and trying to isolate and locate an orange traffic cone. I think I'm getting about 20 frames a second on that. Of course, I'm doing a lot of display which takes some time that you might not have to do or could offload in an industrial setting.
OpenCV is great for prototyping and test but one of the drawbacks is that you end up sequentially performing some tasks that could be combined into one pass on the image so you get a bit of loop overhead that could be eliminated once you get it to work and gain some speed that way.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Yes, you're right. It's not necessary for me to find my template in a bigger image. I just thought about the fact you mentioned,
to find some simple objects on which I can relocate the image.
I know the OpenCV template matching functions, they do pretty well.
But they are only for translation invariant pictures, so I need something to find to rotation angle.
The OpenCV template matching only uses some correlation or square difference techniques. I only can use them
in the case my image is rotated the right way.
I also observed, that there's some optimization space in the OpenCV functions, as you said.
How did you locate the traffic cone? How did you find the rotation angle respective scaled cones?
I'd be happy if you could just tell me the keyword of the technique, something I could research...
For now, I only read about techniques of that log-polar stuff and similar things in frequency domain.
I wonder now if there could be another way to relocate the rotation/scalation.
So far, thanks Tim!
|
|
|
|
|
I was looking for the traffic cone as an experiment in seeing how difficult the vision system for a RoboMagellan robot would have to be, also to get some practical exerience in color matching and alternative color schemes, HSV, HSL, etc. I didn't really care about the orientation or size, only position relative to the camera since one way or another the robot has to turn and drive straight to the cone. If I wanted the orientation, I'd use the higher moments of the cone in the image to get its principal axes.
To find the cone, I simply ran through the image tagging pixels as cone or not cone until I had a binary image. I fed that to the blob library and kept the largest blob assuming it was the cone. Since RoboMagellan is run outdoors, finding international orange in your image is a pretty good predictor of it being a cone. You would also have the GPS coordinates of the cone so you have a fair idea where to look, although last year Camp hid one behind a tree. Turns out that any color scheme which separates color information from luminance works way better than native RGB (or BGR as OpenCV insists on ). If you're not familiar with RoboMagellan, the rules are here[^]. Some pictures of an actual even at RoboGames 2009[^] that I took.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
First of all: Thanks Tim for the time you spent on the answers!
I appreciate that very much.
You gave me some interesting issues to think about.
I hope, you'll do further well with the cones and the Robots
|
|
|
|
|
Could someone more experienced with dialog frame sizing clarify for me how does MFC MDI determines the size of the MDIChildFrame?
My modeless dialog is in FormView ( Property Sheet component) and I can re-size that by changing the dialog resource. I am using tabs and the dialog frame follows the largest tab / page.
When I use ResizeParentToFit() in OnInitialUpdate of the FromView I end up with a small frame.
However, when I skip the ResizeParentToFit() and use ShowWindow(SW_SHOWMAXIMIZED) I get different , large, FormView frame.
I stepped thru the ResizeParentToFit() and still do not see where are the view area dimensions coming from. They seems to be the actual dimensions used by ResizeParentToFit() and ShowWindow(SW_SHOWMAXIMIZED) .
What I really want is to maximize the FormView programatically to fit the whole MainFrame.
The automatic sizing the dialog frame itself is fine, but not exactly what I want.
Any constructive help is as always appreciated.
Thanks for your time.
Vaclav
|
|
|
|
|
|
Nice, but...
I wanted to know how does MFC manage the document / view sizing.
Thanks for your input.
Vaclav
|
|
|
|
|
Hi to all.
Is it possible to have a 32x32 images on toolbar while keeping 16x16 in menu.
I created toolbar resource (IDR_TOOLBAR1) and set it's button size as 32x32 and load it:
if (!m_wndToolBar.CreateEx(this,...) ||
!m_wndToolBar.LoadToolBar(IDR_TOOLBAR1 ))
{
...
}
When compiled and started toolbar correctly shows large btn images but menu is also enlarged showing 32x32 item images!? How to have menu images as before (small 16x16)?
My app info: SDI, VS2008
Thanks in advance!
|
|
|
|
|
See here an project sample which use small and big toolbar in the same application ...
|
|
|
|
|
Thaks for yours replay. The sample you pointed to me unfortunaly uses images only on toolbar and not menu. I've pulled some ideas from it so thanks once again!
|
|
|
|
|
I've solved it
if (!m_wndMenuBar.Create(this))
{
TRACE0("Failed to create menubar\n");
return -1;
}
m_wndMenuBar.SetMenuSizes(CSize(22,22), CSize(16,16));
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);
CMFCPopupMenu::SetForceMenuFocus(FALSE);
CMFCToolBarInfo tbInfo;
tbInfo.m_uiColdResID = 0;
tbInfo.m_uiDisabledResID = 0;
tbInfo.m_uiHotResID = 0;
tbInfo.m_uiLargeColdResID = 0;
tbInfo.m_uiLargeDisabledResID = 0;
tbInfo.m_uiLargeHotResID = 0;
tbInfo.m_uiMenuResID = IDR_MAINFRAME_256;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC)
|| !m_wndToolBar.LoadToolBarEx(IDR_TOOLBAR1, tbInfo)) {
TRACE0("Failed to create toolbar\n");
return -1;
}
- Call CMFCMenuBar::SetMenuSizes() before creating toolbar
- Use CMFCToolBarInfo struct leaving all members to 0 except m_uiMenuResID where you pass yours 16x16 sized resource entry
- CallLoadToolBarEx()
Off course IDR_TOOLBAR1 is 32x32 sized
|
|
|
|
|
Hi,
I have an MDI application.I create an a Modeless dialog on a menu click.I would like to make it behave like a Modal dialog box. How should I do that?
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
You can try disabling the parent of the dialog by using EnableWindow(FALSE).
|
|
|
|
|
Hi,
Thanks for the reply. But I also dont want my mainframe window to receive messages.I want the exact behaviour of DoModal.
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
narayanagvs wrote: I want the exact behaviour of DoModal.
Sorry, I don't understand. If you want 'the exact behaviour of DoModal' then why do you create a Modeless dialog?
Ali
|
|
|
|
|
I just want to know. This is a question asked to me.
Satya
Today is a gift, that's why it is called the present.
|
|
|
|