有没有办法用open cv读取mms流进行直接分析?
我正在尝试用c ++做一个小项目。我不知道如何将mms插入opencv。
我觉得不需要在visual studio中添加一个库。
mms流上只有视频正在阅读:
mms://s3ewm.castup.net/991450009-52.wmv?ct=IL&rg=BZ&aid=145&tkn=20120201230602&ts=0&cu=FC1B06E9-7ABE-4B1C-9B2A-7A5C6019E99F
更新
我找到了这个链接:Microsoft msdn
答案 0 :(得分:0)
here有人确实通过vlc包获得了mms。
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(2,vlc_argv);
mediaPlayer = libvlc_media_player_new(instance);
media = libvlc_media_new_path(instance, "mms://81.89.49.210/musicbox");
struct ctx* context = ( struct ctx* )malloc( sizeof( *context ) );
context->mutex = CreateMutex(NULL, FALSE,NULL);
context->image = cvCreateImage(cvSize(VIDEO_WIDTH, VIDEO_HEIGHT), 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", VIDEO_WIDTH, VIDEO_HEIGHT, VIDEO_WIDTH*4);
libvlc_media_player_play(mediaPlayer);
while(1)
{
}
return 0;
}