c++

How to track finger position with OpenCV

Hi all, I have a problem with image processing. I have set up a web cam on top of my laptop facing the keyboard so when i touch the LCD the image which get from the web cam bisects by the finger so my idea is to get the positions of the finger when it bisects the image. any help is appreciated (OpenCV, openframework or any other relevant...

stringstream and french locale (French_France.1252)

std::stringstream stream_french; stream_french.imbue(std::locale("")); // French_France.1252 stream_french << 1000; std::string value_french = stream_french.str(); This code will convert 1000 to string "1 000" but the value of value_french[1] is -96 and not 32, why is that ? value_french[0] = 49 value_french[1] = -96 value_french[2] ...

What is the proper way to return an object from a C++ function ?

I am confused between : returning an object (but then the object is copied from the local variable in the function, which consumes memory) returning a pointer (but then you have to remember to delete it, in the calling code, which is weird) returning a reference (but this is not possible because this would be a reference to a local var...

Silly C++ reference question

I do not know how to call a function with a reference in it :( It is a silly noob question I know. The header is let's call it ref.h has a function in it that is: virtual int funcName (Bike &biker, BikeArray &bikearray, int x, int y .... ) Within ref.h there is another header that is called Bike.h. How do I call funcName from my m...

Porting C++ to C#

C++ and C# are quite simmilar programming languages, in my opinion. If a C++ code needs to be ported to platform where C# is the only supported platform, how much work will need to be done? Should I get ready, that most of the C++ code will need to be rewritten to C#? Or, because of language simmilarities, should refactoring be quite ea...

Draw Thick Line with Border

I am trying to draw a thick line using c++, and add a border to this line from all side. I am using moveto, lineto functions, but not sure how to track the line width to draw borders. this is require for generic line. ...

What makes this bucket sort function slow?

The function is defined as void bucketsort(Array& A){ size_t numBuckets=A.size(); iarray<List> buckets(numBuckets); //put in buckets for(size_t i=0;i!=A.size();i++){ buckets[int(numBuckets*A[i])].push_back(A[i]); } ////get back from buckets //for(size_t i=0,head=0;i!=numBuckets;i++){ //size_t bucket_size=buckets[...

Creating native C++ OpenGL 3D editor and using it as a WinForms or WPF control in C#

Hello, I want to create a simple 3D editor program, and I kind of hate C++ windows programming. But I don't want to mess with managed code when using OpenGL, either. So, it is possible to create in native C++ a control which will host the OpenGL 3D drawing surface, with no other controls, and also with an interface (methods and properti...

C++\IronPython integration example code?

I'm looking for a simple example code for C++\IronPython integration, i.e. embedding python code inside a C++, or better yet, Visual C++ program. The example code should include: how to share objects between the languages, how to call functions\methods back and forth etc... Also, an explicit setup procedure would help too. (How to incl...

How to use SQLConnect or SQLDriverConnect

Hello, I am trying to connect to a MS-SQL server on the internet. What should I put on the ServerName parameter of SQLConnect? I've tried this, but it fails: "DRIVER=SQL Server;SERVER=SERVER_IP;DATABASE=sales" SERVER_IP is something like 111.111.111.111,9999 EDIT: I followed Johns advice and here is my current code: SQLCHAR OutCon...

Copying value from char pointer to a char array

I am having a pointer *ip_address_server which holds the ip address of the server : in_addr * address = (in_addr * )record->h_addr; char *ip_address_server = inet_ntoa(* address); Clearly, when I use printf to print the value of it, it gets nicely printed. printf("p address %s" , ip_address_server); But now if I declare...

Avoiding Memory Leaks w/ Exceptions in C++

I allocate objects on the heap and under some circumstances I combine them into a new object (my Foo class mainly contains 2-3 STL containers). (An alternative would be to use copies, but I guess that would be less efficient.) These operations may fail, thus exceptions may be thrown. Unless I release the dynamic memory whenever I throw ...

Platform independent way to get font directory?

Is there a way I could find where fonts are stored on either Windows, OSX, or Linux? If not, is there a way I can guarantee certain paths (such as X:/Windows/Fonts/) for all 3 platforms? What ifdefs would I use for these? Thanks ...

Handle std::basic_string<> with different type arguments

I want to implement a c++ library, and like many other libs I need to take string arguments from the user and giving back strings. The current standard defines std::string and std::wstring (I prefer wstring). Theoretically I have to implement methods with string arguments twice: virtual void foo(std::string // convert internally from ...

WxWidgets: Troubling Callling wxFrame ConstructorE

Okay, I have run into a really bizarre problem. I have a wxWidgets program that has two frames, a main one, and a secondary one. The main one has a button that calls the second one to open. I had trouble with calling a derived class from the second wxframe's class, so I moved the declaration/implementation of the class to before the c...

DDK "Hello World"

How does one begin writing drivers for Windows? Is there some sort of official DDK "Hello World" example out there? While I'm sure it will be way above my head at first, eventually I would like to create a simple MIDI driver, much like the Maple Virtual MIDI Cable where the MIDI messages come from a user application rather than a physi...

versatile pthread based multithread utility library

Hi folks. I don't want to reinvent the wheel, and what I'm looking for most likely already exist in the FOSS world. I'm looking for a pthread bases utility library that implements often used primitives to do communication between threads. My main need is some kind of blocking queue for fixed size messages and the ability to wait for ...

How is reference implemented internally?

Just wonder how is it implemented actually across different compilers and debug/release configurations. Does standard somehow provides recommendations on its implementation? Does it differ anywhere? I tried to run a simple program where i have been returning non-const references and pointers to local variables from functions but it work...

Why can't a function have a reference argument in C?

For example: void foo( int& i ); is not allowed. Is there a reason for this, or was it just not part of the specification? It is my understanding that references are generally implemented as pointers. In C++, is there any functional difference (not syntactic/semantic) between void foo( int* i ) and void foo( int& i )? ...

domain in programming

in the book of Meyers about effective programming(item 38) I found some absract terms: application domain, implementation domain, will be very grateful if somebody explain me the difference, please do not copy from the book I know how to read, thanks in advance ...