|
Unfortunately, wfstream can handle Unicode characters and strings passed into the stream but will only produce Ansi output. You need to use the old C-style Stream I/O[^], the stream::write()[^] function to write raw data, or use the CArchive if you have MFC in your project.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
<big><b>
Hy Guys
</b></big>
<pre lang="text">
I wants to maintain previous location of blob.
I have coordinates struct some thing like this
</pre>
<pre lang="c++">
struct coordinate
{
unsigned int x;
unsigned int y;
unsigned int prevX;
unsigned int prevY;
void * data;
};
</pre>
<pre lang="text">
and blob struct like this ,.
</pre>
<pre lang="c++">
struct blob
{
//unsigned int blobId;
coordinate min, max;
coordinate center;
};
</pre>
<pre lang="text">
inside loop for video
</pre>
<pre lang="c++">
// Calculate center
for(map<unsigned int, blob>::iterator i = blobs.begin(); i != blobs.end(); ++i)
{
(*i).second.center.prevX = (*i).second.center.x;
(*i).second.center.prevY = (*i).second.center.y;
(*i).second.center.x = (*i).second.min.x + ((*i).second.max.x - (*i).second.min.x) / 2;
(*i).second.center.y = (*i).second.min.y + ((*i).second.max.y - (*i).second.min.y) / 2;
}
</pre>
<pre lang="text">
But problem is my previous location of blobs always appeared 0 .
you can see in this image attached image :
What am i doing mistake , could any one please help me
</pre>
|
|
|
|
|
Please stop reposting the same thing. Edit this question (use the "Edit" link in the above message) and fix the formatting; use the Preview button to check before posting.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
ok but sir . there is not any preview button.
I am stuck in my problem .
I need to solve it today only .
|
|
|
|
|
My apologies, but you do not need a button as the preview is generated automatically. You can also view your question after it is posted to see that it is correct.
For example, this line is simple text and does not need any tags around it.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Richard MacCutchan wrote: My apologies, but you do not need a button as the preview is generated
automatically.
Presumably you mean *IF* there is no preview button.
Because this very post is not automatically creating a preview. There is however a preview button.
The other browser I use does create a preview automatically.
|
|
|
|
|
Well, I was responding to the OP, who specifically said that there is no preview button.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
love bird wrote: I need to solve it today only .
To put it bluntly... that's your problem not ours. Sorry
Next time, do your homework ahead of time. We're here to help but we all do this for free on our own time, so your time frames are nobody else's problems but your own.
|
|
|
|
|
|
In reply to your message:
Can i send you my question in your email box using msn or gmail or yahoo from any service ?
Sorry, but (like most people here) I do this in my own time and at my own pace, I do not provide private consultancy.
If you have a question that you want help with then you are welcome to post it here, and people will help where they can and in their own time. If you need professional help then you need to find a local consultant or try one of the job sites.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
<pre lang="text"><b>Edited 1 more time :</b></pre>
<pre lang="text">I want to maintain previous location of blob .
so declare a struct of coordinates some thing like this .</pre>
<pre lang="c++">
struct coordinate
{
unsigned int x;
unsigned int y;
unsigned int prevX;
unsigned int prevY;
void * data;
};</pre>
and blob struct is like
<pre lang="c++">struct blob
{
//unsigned int blobId;
coordinate min, max;
coordinate center;
};
</pre>
<pre lang="text">and i used map to maintain each blob as an id . and its location as value of id/.
I calculated each blob previous location some thing like this </pre>
<pre lang="c++">// Calculate center
for(map<unsigned int, blob>::iterator i = blobs.begin(); i != blobs.end(); ++i)
{
(*i).second.center.x = (*i).second.min.x + ((*i).second.max.x - (*i).second.min.x) / 2;
(*i).second.center.y = (*i).second.min.y + ((*i).second.max.y - (*i).second.min.y) / 2;
(*i).second.center.prevX = (*i).second.center.x;
(*i).second.center.prevY = (*i).second.center.y;
}
</pre>
<pre lang="text">
this image link : http://imageshack.us/photo/my-images/192/mainprevposagaingeachbl.png/</pre>
<pre lang="text">Previous location seems like not correct .
If first time current X = 2 and current Y = 5 then previous X and previous Y should be 0
then if an object take one more step then if an object have current X = 10 and current Y = 44
then previous X should have 2 and previous Y should have 5 .
what's wrong ?
Can some one please help me .thanks</pre>
<big><b>New Updated Code :</b></big>
<b>Hy Guys ,</b>
<pre lang="text">I wants to maintain previous location of blob.
I have coordinates struct some thing like this
</pre>
<pre lang="c++">struct coordinate
{
unsigned int x;
unsigned int y;
unsigned int prevX;
unsigned int prevY;
void * data;
};</pre>
<pre lang="text">and blob struct like this ,. </pre>
<pre lang="c++">struct blob
{
//unsigned int blobId;
coordinate min, max;
coordinate center;
};
</pre>
<pre lang="text">inside loop for video</pre>
<pre lang="c++">// Calculate center
for(map<unsigned int, blob>::iterator i = blobs.begin(); i != blobs.end(); ++i)
{
(*i).second.center.prevX = (*i).second.center.x;
(*i).second.center.prevY = (*i).second.center.y;
(*i).second.center.x = (*i).second.min.x + ((*i).second.max.x - (*i).second.min.x) / 2;
(*i).second.center.y = (*i).second.min.y + ((*i).second.max.y - (*i).second.min.y) / 2;
}</pre>
<pre lang="text">But problem is my previous location of blobs always appeared 0 .
you can see in this image attached image :
What am i doing mistake , could any one please help me .</pre>
-- modified 19-Jan-12 9:04am.
|
|
|
|
|
Could you please properly use the code button to format your code and correctly set your links?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
<pre lang="text">Edited and may be good enough to understand Code :</pre>
<pre lang="text">I want to maintain previous location of blob .
so declare a struct of coordinates some thing like this .</pre>
<pre lang="c++">
struct coordinate
{
unsigned int x;
unsigned int y;
unsigned int prevX;
unsigned int prevY;
void * data;
};</pre>
and blob struct is like
<pre lang="c++">struct blob
{
//unsigned int blobId;
coordinate min, max;
coordinate center;
};
</pre>
<pre lang="text">and i used map to maintain each blob as an id . and its location as value of id/.
I calculated each blob previous location some thing like this </pre>
<pre lang="c++">// Calculate center
for(map<unsigned int, blob>::iterator i = blobs.begin(); i != blobs.end(); ++i)
{
(*i).second.center.x = (*i).second.min.x + ((*i).second.max.x - (*i).second.min.x) / 2;
(*i).second.center.y = (*i).second.min.y + ((*i).second.max.y - (*i).second.min.y) / 2;
(*i).second.center.prevX = (*i).second.center.x;
(*i).second.center.prevY = (*i).second.center.y;
}
</pre>
<pre lang="text">
this image link : http://imageshack.us/photo/my-images/192/mainprevposagaingeachbl.png/</pre>
<pre lang="text">Previous location seems like not correct .
If first time current X = 2 and current Y = 5 then previous X and previous Y should be 0
then if an object take one more step then if an object have current X = 10 and current Y = 44
then previous X should have 2 and previous Y should have 5 .
what's wrong ?
Can some one please help me .thanks</pre>
|
|
|
|
|
Please uncheck the 'Treat my content as plain text, not as HTML' checkbox.
BTW I cannot see the issue with just the above code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
From your image the 'previous' position it is simply the 'current' position with x,y swapped.
I suppose you should post more code in order to get better help. But please, please use the 'code' button (just above the input textbox) for proeprly format your code.
Or, alternatively manually write:
<pre lang="C++">
...your code here...
</pre>
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
By using the Preview button, you should have been able to see that your post is far from legible.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
love bird pointed out to me that there is no Preview button anymore; of course the preview is auto-generated.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yeah, the preview pane comes and goes. The button, however, has been around for years so it's hard to not refer to it.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Map is used as id and its value .
i detected blob using map .
so against each id represent as blob and its value represent its location in x and y .
I wanna maintain previous location of each object(id ) .
How can i do that ?
|
|
|
|
|
You already made a similar question (and got answers).
What's the problem, now?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello Guys ,
I wanna to store object current and previous location based on id of objects .
like if there is 1 object moving in video then i will have ids
id 1 have x ,y
if two or 4 objects present in the video then i should have ids like
1. x,y
2. x,y
3. x,y
4. x,y
These are current location.
Now based on each ids current location. i wanna create another lists of ids that have previous location of current locations of ids .
How can i do that ?
Can some one please show me any sample that would help me alot .
thanks
|
|
|
|
|
Not sure if I really understand your question but I believe you can create a vector of IDs.
This way the previous vector element will correspond to the previous ID.
Something like this -
std::vector<std::pair<int, int>> ids;
Now you can store the ids as follows -
ids.push_back(std::make_pair(x, y));
So you can iterate through the vector by using the subscript - ids[0] , ids[1] etc.
Here ids[0] is the previous location of ids[1] .
|
|
|
|
|
well i tried to create a program as you said .
#include <iostream>
#include <map>
#include "vector"
using namespace std;
int main()
{
int x = 5;
int y = 10;
cout<< "Hello " <<endl;
std::vector<std::pair<int , int>> ids;
ids.push_back(std::make_pair(x,y));
for( std::vector<std::pair<int , int>>::iterator it = ids.begin() ;
it != ids.end; ++it)
{
cout<<"ids as " << ids[it] <<endl;
}
}
but there are errors which i do't understood .
can you please test this program .
Rida
|
|
|
|
|
What are the errors that you get?
By the way end is a function - ids.end()
For pair you need to include the utility header - #include <utility> .
|
|
|
|
|
Change this way to have something 'compiler-friendly':
#include <iostream>
#include <map>
#include "vector"
using namespace std;
int main()
{
int x = 5;
int y = 10;
cout<< "Hello " <<endl;
std::vector<std::pair<int , int>> ids;
ids.push_back(std::make_pair(x,y));
for( std::vector<std::pair<int , int>>::iterator it = ids.begin() ;
it != ids.end(); ++it)
{
cout<<"ids as " << it->first << ", " << it->second <<endl;
}
}
However, if you need to record positions of some objects having different IDs, then you need a further indirection step, e.g.
typedef std::vector< std::pair<int , int> > Pos;
vector <Pos> obj;
obj.push_back(Pos()); obj[0].push_back( std::make_pair(5, 10) ); obj[0].push_back( std::make_pair(6, 12) );
obj.push_back(Pos()); obj[1].push_back( std::make_pair(3, 7) ); obj[1].push_back( std::make_pair(-2, 9) );
for ( vector<Pos>::size_type n = 0; n<obj.size(); n++)
{
cout << "object " << n << " positions: " << endl;
for ( Pos::size_type p = 0; p < obj[n].size(); p++)
{
cout << "pos[" << p << "] {" << obj[n][p].first << ", " << obj[n][p].second << "}" << endl;
}
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|