Skip to content

Instantly share code, notes, and snippets.

@s-mage
Created March 12, 2013 15:43
Show Gist options
  • Save s-mage/5143984 to your computer and use it in GitHub Desktop.
Save s-mage/5143984 to your computer and use it in GitHub Desktop.
Pornodance with openCV and mathcad possibility tu create user DLL. I don't know, how to compile it in windows.
#include "MCADINCL.H"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
// Reading frame and convert it into MathCad matrix(complexarray).
//
LRESULT video2MathCad(COMPLEXARRAY * const result, const char * path_to_video,
const int frame_number)
{
CvCapture* capture = cvCreateFileCapture(path_to_video);
cvSetCaptureProperty(capture, CV_CAP_PROP_POS_FRAMES, frame_number);
IplImage* frame = cvQueryFrame(capture);
char* data = frame->imageData;
// Allocate memory for MathCad matrix. Built-in MathCad method.
//
MathcadArrayAllocate(result, frame->width, frame->height, true, false);
for(int i = 0; i < frame->width; i++)
for(int j = 0; j < frame->height; j++) {
result->hReal[i][j] = data[i * frame->height + j];
}
return 0;
}
FUNCTIONINFO frame = { frame, "path_to_video, frame_number",
(LPCFUNCTION)video2MathCad; COMPLEX_ARRAY, 2,
{ char*, int } };
bool WINAPI DllEntryPoint (HISTANCE hDLL, DWORD dwReason, LPVOID lpreserved)
{
CreateUserFunction(hDLL, &frame);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment