c++

C++ program snippet: what is this doing?

I'm trying to figure out how to output hOCR using Tesseract. Documentation is limited, so I am looking into the code. I found this in the main() function: bool output_hocr = tessedit_create_hocr; outfile = argv[2]; outfile += output_hocr ? ".html" : tessedit_create_boxfile ? ".box" : ".txt"; A typical command for Tesseract is this: te...

What should I use in Android when porting C++ code written with libsndfile?

I'm porting a small (<10 classes) C++ project to Java. The project manipulates sound files, and in C++ does this using libsndfile. The code includes stuff like: const int channels = audioFileInfo.channels; ... sf_readf_double( audioFile, inputBuffer, MAX_ECHO ); ... sf_writef_double( outputAudioFile, &currentAudioBuffer[WINDOW_SIZE * ch...

Pointers to objects in a set or in a vector - does it matter?

Hi, just came a across a situation where I needs to store heap-allocated pointers (to a class B) in an STL container. The class that owns the privately held container (class A) also creates the instances of B. Class A will be able to return a const pointers to B instances for clients of A. Now, does it matter if these pointer are stor...

Interfere Win32 message loop with injected DLL code (SetWindowsHookEx)

Hello everybody! After hours of penetrating Google I ended up here. I'll come straight to the point: I'm about to "refresh" my C/C++ skills and gain experience with the unmanaged world again. As a "basic" task I developed a little key logger (which are just a few lines with the Windows API) but now I want to extend it with a "stealth" f...

Assembly code mixed in with my C++ code. How to port to 64 bit

I am porting 32 bit C++ code into 64 bit in VS2008. The old code has mixed code written in assembly. Example: __asm { mov esi, pbSrc mov edi, pbDest ... } I have read somewhere that I need to remove all assembly code and put them all in a separate project and somehow link to it. Can somebody give me the step x step procedur...

convert code c++ to c#

im trying to convert this code to c# for ( int k=0; k < 3; k++ ) if ( anim.jointInfo[j].flags & (1 << k) ) { //.... } flags: int jointInfo: List<> ...

Writing 1 channel images to videos with OpenCV

Hi, I want to write some 1 channel gray images as videos. Here is the code I use: cv::VideoWriter video("file.avi",CV_FOURCC('X','V','I','D'),25,cv::Size(image.cols,image.rows),0); //.... video<<image; I get the following error: highgui/cvcap_ffmpeg.cpp:1065: virtual bool CvVideoWriter_FFMPEG::writeFrame(const IplImage*): Assertion `...

Gdiplusshutdown results in exit code 1.

Hi, when my app is exited i see the following in the debugger console. The thread '_threadstartex' (0xd48) has exited with code 0 (0x0). The thread '_threadstartex' (0xf80) has exited with code 0 (0x0). The thread '_threadstartex' (0x190) has exited with code 0 (0x0). The thread '_threadstartex' (0xaa0) has exited with code 0 (0x0). T...

VC++ 10 complains that alot of types are not defined, C99

Hi, I'm trying to compile an open source project I downloaded, apparently written in VC++ 7.1. After alot of trouble, being novice at C++, I managed to download and fix includes for STLPort that the project uses. However, I get something like 15000 errors that complains that certain types are not defined. A few of them are: u_int32_t ...

High Quality Image Magnification on GPU

I'm looking for interesting algorithms for image magnification that can be implemented on a gpu for real-time scaling of video. Linear and bicubic interpolations algorithms are not good enough. Suggestions? Here are some papers I've found, unsure about their suitability for gpu implementation. Adaptive Interpolation Level Set I've s...

Is there anything you can do in C++ that you cannot do in C#?

I am trying to figure out if there is anything that you can do in c++ that you absolutely cannot do in c#? I know that there are platforms that are targeted to native libraries, but I want to know if the lowest level c# can compare with the lowest level c++. ...

Keeping a reference instead of a pointer?

I have a class which basically is a text manager. It can draw text and whatnot. I basically want the color and text std::string to only be a constant reference. Would it then be alright to do class TextManager { const std::string &text; void draw(const std::string &text) const; public: TextManager(const std::string &text) { this->text...

Does wxwidgets use rosetta in Mac?

Hi, While deciding for a cross platform language for a desktop application I want to do, I came across "wxwidgets" for C++. After testing a demo application in Mac 10.6.4 I noticed the application needed "Rosetta" to run. My concern is: Will I always need "Rosetta" for a C++ application with wxwidgets to run on a Mac? Note: Latest new...

has_member_of_type - template metaprogramming in C++

I suspect this is not possible under the current C++ standards but I'll ask anyway. What I'm trying to achieve is to get the compiler to figure out during compile time if a class contains any member variable of type Base (along with its derivations). e.g. struct Base { }; struct Derived : public Base { }; struct Foo { int x; ...

Your best library for create GUI ( gtk, qt, win32 api, etc ) ?

In your opinion, what is the best way to create gui in Windows ? with gtk or win32 api ? Do you recommend GTK for windows ? Yes ? NO ? Why ? ...

Modern books on native C++ development

I was going through the Hilo tutorial series Developing C++ Applications for Windows 7; seemed pretty interesting. What modern books that go into details of developing C++ based applications for Windows 7? It should show how to take advantage of Windows 7 features and based on "modern" C++ (templates, Unicode, etc.). Not looking for old...

Using Vertex Buffer Objects with C++ OpenGL

I am working on a 3d tile-based strategy game and have read that implementing VBO's will significantly increase the game's frame rate and reduce the cpu usage (sounds great right?). However, among the tutorials I've looked at I can't quite get a handle on how to implement it. Has anyone had experience doing this and can either point me...

loop with if consition

int i, j, c = 0; int num = ring.points_.size(); for (i = 0, j = num-1; i < num; j = i++) { if ((((ring.points_[i].y_ <= pt.y_) && (pt.y_ < ring.points_[j].y_)) || ((ring.points_[j].y_ <= pt.y_) && (pt.y_ < ring.points_[i].y_))) && (pt.x_ < (ring.points_[j].x_ - ring.points_[i].x_) * (pt.y_ - ring.points_[i].y_)...

static pointer to itself!

Hi guys, what's wrong with the following code: class A { public: static A* p; A() { p = this; } }; I got this link error: error LNK2001: unresolved external symbol "public: static class A * A::p" (?p@A@@2PAV1@A) I cannot figure out the point of this problem, please help.. ...

Is it possible to overload a template class?

I found that template method could be overloaded, can I do the same on template classes? If 2 template classes match a template class instantiation, we can use the parameter type in the constructor to deduce which one to use. template <typename T> class A{ A(T){} }; template <typename T> class A{ A(T*){} }; int main(){ A<int*> ...