我正在尝试使用从网络流中读取帧libvlc
,然后使用opencv
. 这是我用来检索帧的代码:
struct ctx
{
IplImage* image;
HANDLE mutex;
uchar* pixels;
};
void *lock(void *data, void**p_pixels)
{
struct ctx *ctx = (struct ctx*)data;
WaitForSingleObject(ctx->mutex, INFINITE);
*p_pixels = ctx->pixels;
return NULL;
}
void display(void *data, void *id)
{
(void) data;
assert(id == NULL);
}
void unlock(void *data, void *id, void *const *p_pixels){
struct ctx *ctx = (struct ctx*)data;
// VLC just rendered the video, but we can also render stuff
uchar *pixels = (uchar*)*p_pixels;
cvShowImage("image", ctx->image);
ReleaseMutex(ctx->mutex);
assert(id == NULL); // picture identifier, not needed here
}
int main()
{
cvNamedWindow("image", CV_WINDOW_AUTOSIZE);
libvlc_media_t* media = NULL;
libvlc_media_player_t* mediaPlayer = NULL;
//char const* vlc_argv[] = {"--plugin-path", "C:\\Users\\Oscar\\Documents\\libvlc\\vlc-1.1.4"};
libvlc_instance_t* instance = libvlc_new(0,NULL);
mediaPlayer = libvlc_media_player_new(instance);
media = libvlc_media_new_location(instance, "rtsp://134.202.84.79:554/user=a&password=abcdef&channel=6&stream=0.sdp/");
struct ctx* context = ( struct ctx* )malloc( sizeof( *context ) );
context->mutex = CreateMutex(NULL, FALSE,NULL);
//context->image = cvCreateImage(cvSize(libvlc_video_get_height(mediaPlayer), libvlc_video_get_width(mediaPlayer)), IPL_DEPTH_8U, 4);
context->image = cvCreateImage(cvSize(640,480), IPL_DEPTH_8U, 4);
context->pixels = (unsigned char *)context->image->imageData;
libvlc_media_player_set_media( mediaPlayer, media);
libvlc_video_set_callbacks(mediaPlayer, lock, unlock, display, context);
libvlc_video_set_format(mediaPlayer, "RV32", 640, 480, 640*4);
libvlc_media_player_play(mediaPlayer);
while(true)
{
if (waitKey(30)==27)
{
break;
}
}
return 0;
}
问题是这在调试模式下工作正常,但是当我切换到发布模式时,它说:
无法在动态链接库 libvlc.dll 中找到过程入口点 cvCreateImage。
我也尝试更改链接器优化标志,但问题仍然存在。