Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
K

khrstopher

@khrstopher
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • memory usage keeps going up when retrieving webcam image
    K khrstopher

    I've written a JAva program that uses JNI to call some C++ methods to retrieve webcam images using video for windows. The problem is that every time I retrieve an image, memory usage keeps going up. I'm still a noob to C++ so the problem may be something really simple. Here's my code: code: HWND m_capWindow; int connectedIndex; LRESULT PASCAL callbackProc(HWND hWnd, LPVIDEOHDR lpVHdr); LRESULT PASCAL callbackProc(HWND hWnd, LPVIDEOHDR lpVHdr) { return 0; } JNIEXPORT void JNICALL Java_client_desktop_dateclick_Test_connect (JNIEnv *, jobject, jint index) { m_capWindow = capCreateCaptureWindow ("", WS_CHILD, 0, 0, 0, 0, GetDesktopWindow(), 10); //m_capWindow = capCreateCaptureWindow ("Capture", WS_CHILD | WS_VISIBLE, 50, 50, 480, 360, GetDesktopWindow(), 10); // connect to the new driver BOOL rval = capDriverConnect (m_capWindow, index); capSetCallbackOnFrame(m_capWindow, callbackProc); capPreview(m_capWindow, FALSE); } JNIEXPORT jbyteArray JNICALL Java_client_desktop_dateclick_Test_getImage (JNIEnv *env, jobject) { CString fileName; int contentLength; BYTE *frame; capGrabFrame(m_capWindow); //capGrabFrameNoStop(m_capWindow); fileName = "capframe.bmp"; //and use this file... capFileSaveDIB( m_capWindow, (LPCTSTR)fileName); CFile jpegTemp; // now read the resulting file into a buffer jpegTemp.Open("capframe.bmp", CFile::modeRead); contentLength = (UINT)jpegTemp.GetLength(); //allocate the buffer for the jpeg frame frame = new BYTE[contentLength]; //now read in the jpeg file jpegTemp.Read(frame, contentLength); jpegTemp.Close(); jbyteArray ba = env->NewByteArray(contentLength); env->SetByteArrayRegion(ba, 0, contentLength, (jbyte*) frame); delete frame return ba; } JNIEXPORT void JNICALL Java_client_desktop_dateclick_Test_disconnect (JNIEnv *env, jobject) { capDriverDisconnect(m_capWindow); }

    C / C++ / MFC c++ java delphi database performance
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups