jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What type of project did you select? Make a new project with Win32 Console as the type.

Don't select empty project, and you can uncheck Precompiled Headers.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So now just use the .c_str() to get back the const char * representation, cvLoadImage(line.c_str());

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure why you're using anything but fstream across the board to do your file reading. See http://www.cplusplus.com/doc/tutorial/files/ for a good tutorial. Do everything C++ style up until the last step, once you have your std::string and have done all of the necessary manipulations, only then use the .c_str() method to finally pass it to the OpenCV function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't know about database securities and how to implement them.

Just to pick on your one example, it's very good to know the theory of these types of things and be aware of them. However, unless this is your passion, leave the implementation up to people that spend their days in database security, and reap the benefits of their expertise by using their libraries!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Read training.txt into another vector of strings, call it trainingVec or something.

Return just personNames[nearest-1] (so you have it in a std::string representation.

Step through trainingVec, using the .find() method of each of the strings to see if it contains personNames[nearest-1] If it does, use .find() on that same element of trainingVec to locate the '/' , and using .substr() to grab the portion of the string after '/' .

Then, use the .c_str() method to convert to a C-string for use in the OpenCV function. That way, the mainstay of your manipulations can be done with the std::string .

Probably clear as mud, so take a crack at it, and post back with your revised code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Which is faster to get through midtown traffic, a car or a bicycle? If cars are already bumper to bumper, you definitely want the bike. What qualifications are you using to measure "better"?

(Ed: not implying anything about C or C++ here as being analogous to either one, just trying to help you think about what you are asking)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure whatever global function Show() is will do the job. Instantiate a form2 object and call it's method:

form2^ fm2 = gcnew fm2();
fm2->Show();

should work. If you want fm2 to persist outside of the current method, declare it as a private member of form1

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes. All of the controls have an .Enabled property that will allow them to be active or inactive (grayed out). You can also use the .Visible property to take them out of the form temporarily.

Having the logic carried out in a particular order could be done simply by checking to see if there is anything in the TextBox.Text property before allowing the user to change the radiobutton, or as sophisticated as setting a boolean variable during one of the Textbox events, and ultimately checking if it's true in the CheckChanged event of the radio button.

Start playing around with some of the simpler aspects of the UI (how do I gray out or hide one button by pushing another), or if you're beyond that point, take a crack at some of what you describe and post back with specific problems.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You said you ran a project under Ubuntu. Were you able to access the camera from there?

Update: It looks like there were some significant changes to that file in the last month. You may want to pop over to the official user group on Yahoo (you have to join, but if you're getting into this, it's not a bad idea, and it's an active group) http://tech.groups.yahoo.com/group/OpenCV/messages. I put in that source filename as a query and didn't get anything, but someone might know right off the bat.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There are two ways to fix that. The first would be to go to Project/<myproject>Properties/Configuration Properties/Debugging and specify the working directory as `c:\<pathtoyourDLLs>. The only downside to this is, if you program writes out any files, they will end up cluttering your dll directory.

A more permanent solution is to copy the necessary .dll files into your <myprojfolder>/<myprojfolder>/debug and <myprojfolder>/<myprojfolder>/release directories. Copy over the .dlls associated with the header files that you have included.

Nick Evan commented: Good effort in this thread +16
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'll give you full details of what i did, if you want to know.

Like I had said, just the broad strokes, but slightly more specific than you were.

The exact error messages would be helpful. I'm assuming you used CMake or something on the source files. Were there any errors with dependencies, etc? In other words, did you get a project which you then opened with Visual Studio? Did you build all of the projects successfully? Were there any errors during compilation(there are usually a boatload of warnings with this type of thing, unfortunately)?

If the static libraries were successful, did you have the .dlls in a place where the program could find them?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try n go for EmguCV ..Its a wrapper for OpenCV for VS

Emgu is a .NET wrapper for the OpenCV library. I don't believe that is what the OP is after in this case.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How did you specify the header's and library's directories in the Visual Studio settings?

After you built the source, you should have had the static libraries (.lib) files and the DLLs (which I think come prebuilt with the installer if you go that route).

You don't have to go into excruciating detail, but it will be helpful to find out more about what you tried, so you don't have to start over from the very beginning.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster


He had too few Geek genes

Perhaps he should have tried khakis.

jingda commented: lol +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Welcome Kerry!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

O rly?

You save your chatspeak for when you're digging up earthworms and trading bubble gum cards with the other boys. :D

What if the user has to successfully complete a demo post using the tags properly?

There have been lots of suggestions to that end. I dug up one that was talking about auto-code tags, http://www.daniweb.com/community-center/daniweb-community-feedback/threads/328643/1402885#post1402885, which is not directly what you are proposing, but I think Dani's point in that case was that putting additional barriers into the process of posting is just going to cause more frustration.

Believe you me, I'm honestly all for your suggestion, but is it really going to help? Would someone pass the tutorial, put tags once, and go back to their usual plain text

#INCLUDE <IOSTREAM.H>
#INCLUDE <CONIO.H>
#INCLUDE <GRAPHICS.H>
void main()
{
CLRSCR();
GOTOXY(1,25);
}

the very next time?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Time to ban ardav for overuse of sarcasm.

Boooy, THAT'll be the day! Uh-oh! Me? (*ducks and covers)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Post your code between the code tags like so: /* code tags intro */

I think your idea is great, but you could plaster that statement diagonally across the page in glowing "emergency orange" arial bold (I know, that's not really a web font), and people would still ignore it.

That collapsible function is likely to work on in languages with curly braces.

Is there really any other kind? ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Glad to see you're back! I just figured this out, as I happened to run into one of your old posts and saw that your avatar changed. Good times.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I stumbled across this searching for gift ideas. Thanks!

For me...? You shouldn't have. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

From the member rules

Keep it Clear
-Do post in full-sentence English

Since you are on the thread already you can remind the user that this is the case.


Otherwise the punishment is being forced to interact with the site using a 1980 Motorola cell phone with a one line screen.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Welcome!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Up in the middle of the Form1.h where all of the pictureboxes, etc. are declared. Add:

private: Bitmap ^ map;
private: Graphics ^g;

Make a method:

private static void resetGraphics()
{
   map = gcnew Bitmap(375,307); //though you should code these based on dimensions of 
                                //your pictures
   g = Graphics::FromImage(map);
}

And in your form's constructor, call resetGraphics();

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's going to be some difficulty right off the bat when you are mixing the unmanaged C++ (the std::vector ) and the managed form (which uses an offbeat dialect of C++ called C++/CLI, so some of the data structures and syntax are different).

The GUI uses something called event-driven programming (which isn't unique to Winforms, most GUIs use it in some way), but essentially, you're not moving through your code linearly, you are doing something in response to someone clicking a checkbox, typing in a textbox, or clicking a button. So, rather than getline, you could, for example, have the user type something in the textbox, and once they select a radiobutton, your code will read the text into variable xyz.

Instead of using a vector (which is theoretically possible, but requires some juggling in most cases), you should use a cli::array (see http://www.functionx.com/cppcli/index.htm) for some decent tutorials) or a .NET List object.

So, that's probably a lot to digest... A lot of the good tutorials for .NET are written for C#, but you can still reference them, as the classes and member methods are all the same, except for the -> and :: notation used in C++ with pointers and namespaces.

Post back as you run into any issues.

ddanbe commented: Nice explanation, but I still hate the word GUI! :) +14
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you declare Map and g as private member variables of your form, you can make a function that instantiates them (sets the values to gcnew Bitmap(375,307) and Graphics::FromImage(Map) respectively. Call this function once from the forms constructor, and any subsequent times you need to "clear" your map. In unmanaged code, any subsequent calls to the function would cause a tremendous memory leak, but the garbage collector will free the memory.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

30 days hath September, April, June, and November ;)

What code have you tried so far?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Paste in one of your case statements and a screenshot of your control (if available), and someone should be able to run you through it. You might be able to shortcut some of your logic based on the characteristics of the controls.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm having a hard time finding information on it with examples for C++.

Yes, this is a chronic problem for doing winforms in C++/CLI. You're best bet is to look for similar C# examples and translate them, as it's really the same .NET framework for both. One of the best I've found is here.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry it took me so long to get back. I had tried to reinstall VC++ 2008 on my computer so I could get better intellisense, but I wasn't able to, so I cobbled this together in VC++ 2010 today.

I never liked to mess around with the Paint handlers unless I knew I was redrawing something over and over. You end up having to invalidate it to get it to redraw.

I'll give my rationale in the comments, you may need to retool this a bit to get what you need.

int combinedwidth = pictureBox1->Width + pictureBox2->Width;
int maxheight = Math::Max(pictureBox1->Height,pictureBox2->Height);
//this assumes the pictureboxes will be mapped right next to each other
//so grab the combined length and get the highest height


Bitmap ^ bmp = gcnew Bitmap(combinedwidth,maxheight);
//We're going to draw on this bitmap

Graphics ^ g = Graphics::FromImage(bmp);
//create a graphics instance and link it up with our premade bitmap

Rectangle rectpb1 = Rectangle(Point(0,0),pictureBox1->Size);
Rectangle rectpb2 = Rectangle(Point(pictureBox1->Width+1,0),pictureBox2->Size);
//Since the 2 original bitmaps had been scaled down to fit the pictureboxes, I'm //building two rectangles the same size of the picturebox, but 2nd is offset the //width of the first picture
//Obviously you can determine the offsets directly from the variables if you need to

g->DrawImage(pictureBox1->BackgroundImage,rectpb1);
g->DrawImage(pictureBox2->BackgroundImage,rectpb2);
//Draw the images right onto the graphics instance

bmp->Save("C:\\Users\\XXXXX\\Pictures\\workofart.jpg");

See if that overall technique works better. Before this code, I had preset the jpgs to the BackgroundImage property of the pictureboxes, and used ImageLayout::Stretch so they were …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Welcome back, Davey! :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where is the code for the overloaded operator? Please make some attempt at that code and post back.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

to save the images in more then one Picturebox at a time?

I'm assuming you're doing this as a winforms project? (it seems like that, but there's some ambiguity).

To save more than one picturebox into a bitmap at a time, you're going to have to make a Graphics instance and assign a bitmap to it that that has dimensions big enough to hold all of picturebox images.

You can then use Graphics.DrawImage to place each of those images from the picturebox into the bitmap and save it out like you indicated in your post.

Post back if you're not using Winforms to do this or if any issues crop up.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The first few errors are due to the fact that you don't have a constructor that takes an argument.
In addition to what you have:
You need a constructor that takes an int argument.
(in your class declaration): MyStack(int sz); and defined as:

MyStack<T>::MyStack(int sz)
{	
    top=-1;
    items=new T[sz];	//and whatever else you deem fit to put in
}

For the last few errors note that myError is not the same as MyError .

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Nobody is going to do it for you. What tonyjv says is true, you must show some effort before anyone is going to help you. As it stands, you have dumped off a handful of programs with no other explanation. The only way we can interpret that is "do this for me."

Pick one of the problems, make an attempt, and post back with something along the lines of "my program is supposed to do X, when I run it, it does Y, I think the problem is around line Z."

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm still having a hard time understanding what information you are after. I recommend that you pick a basic tutorial (could even be Wikipedia) and get a basic feel for the language. Once you've done that, you will no doubt have specific issues, and you can post those to your heart's content.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You are trying to read "RXBytes" into one character (since you are using %c and rec is just a character).

I would read the whole line in using fgets and copy out/parse the portions that you need based on the fact that your have an equals sign, followed by a space, followed by a number (since the text is the same each time you don't really need to keep copying it out). You're not limited to fgets, as you're using C++, so you could possibly look into using a stringstream as well.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Go to the designer and select your form. Go over to the properties window and select the lightning bolt (to get the events). Find "Form closing" (not "Form closed") and double click the cell to the right of it. This will put the event handler code into your Form1.h and you can flesh that out as you see fit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

hey Jonsca, i think i figured it out already. thanks for helping me! :) i really appreciate it :)

No problem.

it seems to workout,thanks to you

By and large, you solved it on your own, so give yourself credit too! :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you don't rework insertNode() like I was saying, of course it's not going to sort. Get the insert procedure correct and the deleting will be trivial. Do you have access to a debugger? (I don't remember how good the one was in VC6). You need to step through your code and watch as the nodes are added. I've given you a pointer, but I'm not going to rewrite it for you. Take another crack at it and post back your new insertNode() function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You reset head pointer to null on line 38. Why? It's guaranteed to follow the path of that first if statement each time, and what if there already is a valid head pointer? (hint pass it into your function) That may not be the problem, but it's one of the first places I would look.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 28:

newNodePtr->pengarang = pengarang;

You are only copying the pointer over, not the contents of the string. Use strcpy(newNodePtr->pengarang,pengarang); instead (or better, since you don't know how large your source string is, use strncpy).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think it's a typo made by the author, as DCBlength is actually a member of the DCB struct (see http://msdn.microsoft.com/en-us/library/aa363214(v=vs.85).aspx). The author mentions that giving the struct it's own length is a quirk. It's probably meant to be dcbSerialParams.DCBlength = sizeof(dcbSerialParams);

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the partations of c++?

Please clarify what you mean by "partations".

What kind of programmes I can built with?

Go through some open source projects and see what languages they use. Something like this can give you some idea

And why it's the best programming languages?

That's a highly subjective question. It's definitely not the best choice in all situations.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What was the code that you were using for the bubble sort, and where did you place it?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I ran it through a couple of times:

Is the ohm a decimal? Enter Y : y

Please enter 0 first then the decimal point. (Ex. 0.1)
Please enter the desired resistance
value in ohms (0.01 ohms to 100,000,000 ohms): 1.0

Please enter the desired tolerance as a percentage(5, 10, or 20): 10

Results:
Closest Standard Value = 0.10
Color Band A : brown
Color Band B : black

-------------------------------------------------------------

Is the ohm a decimal? Enter Y : y

Please enter 0 first then the decimal point. (Ex. 0.1)
Please enter the desired resistance
value in ohms (0.01 ohms to 100,000,000 ohms): 2.25

Please enter the desired tolerance as a percentage(5, 10, or 20): 20

Results:
Closest Standard Value = 0.33
Color Band A : orange
Color Band B : orange

The only thing I changed was your itoa s into sprintf s for compatibility purposes.

There may be other issues going on with it, but it doesn't quit after the tolerances on my machine.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, only high school kids from Singapore... ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Those sorts of low-level direct I/O calls (in the spirit of inp()/outp()) no longer work under Windows (as of NT and later) without a special device driver.

For an alternative look into the Win32 API functions like CreateFile.

See this PDF as the author seems to go through those functions step by step.

Nick Evan commented: Yup. +16
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Not to interject now that this is solved, but give chapter 35 of the C++ FAQ (particularly question 12 a read. It's one of the clearer explanations I've run across.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is what i was showing you. Since you have to use strings to input the data, you could do something close to lines 1-4 and then do the calculation like in line 6

if(Manta[loop]='two')

if(Manta[loop]=="two")

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hint: "one" is at position 0 of the Manta array, "two" is at position 1, etc.