| Thread Tools | Search this thread |
|---|
| bedhead | August 11, 2008 4:45 AM PDT UMC and OpenCv | ||||
I am trying to decode an avi file using UMC. End of my code i wanted to see video frames by using highgui library of opencv. However, all i can see is nothing but a gray window. I did steps which are given in the UMC document using sample codes. Here is my code: #include <stdio.h> #include <stdlib.h> #include "ippdefs.h" #include "ipps.h" #include "ippi.h" #include "ippj.h" #include "ippcc.h" #include "vm_time.h" #include "umc_defs.h" #include "umc_structures.h" #include "umc_data_reader.h" #include "umc_splitter.h" #include "umc_video_decoder.h" #include "umc_mpeg4_video_decoder.h" #include "umc_video_data.h" #include "umc_file_reader.h" #include "umc_fio_reader.h" #include "umc_avi_splitter.h" #include "cv.h" #include "highgui.h" #include "ippimage.h" using namespace UMC; UMC::Status InitDataReader(DataReader *data_reader, char *file_name) { FileReaderParams reader_params; reader_params.m_portion_size = 0; strcpy(reader_params.m_file_name, file_name); return data_reader->Init(&reader_params); } IplImage* InitializeImage(int width, int height, int bitDepth, int channels) { IplImage* imgTmp = NULL ; imgTmp = cvCreateImageHeader(cvSize( width, height), bitDepth, channels );//iplCreateImageHeader(1, 0, IPL_DEPTH_32S, "ARGB", "ARGB", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_4BYTES, 768, 576, NULL, NULL, NULL, NULL); imgTmp->imageData=(char *)malloc(imgTmp->height*imgTmp->widthStep);//(IMAGE_WIDTH*IMAGE_HEIGHT*channels*4); return imgTmp; } UMC::Status InitAviSplitter(Splitter *avi_splitter, DataReader *data_reader) { SplitterParams splitter_params; splitter_params.m_lFlags = UMC::VIDEO_SPLITTER; splitter_params.m_pDataReader = data_reader; return avi_splitter->Init(splitter_params); } UMC::Status InitMPEG4VDecoder(VideoDecoder *video_decoder, VideoStreamInfo *video_info) { if(video_info->stream_type != UMC::MPEG4_VIDEO) return UMC_ERR_FAILED; VideoDecoderParams decoder_params; decoder_params.info = *video_info; decoder_params.lFlags = 0; return video_decoder->Init(&decoder_params); } UMC::Status DecodeVideo(char* input_file) { Ipp32u track=0; FIOReader src; AVISplitter avi_spl; SplitterInfo *spl_info; VideoStreamInfo *video_info; MPEG4VideoDecoder dec; MediaData in; VideoData out; IplImage *img = InitializeImage(768, 576, IPL_DEPTH_8U, 4); UMC::Status umcRes; umcRes = InitDataReader(&src, input_file); if(umcRes != UMC_OK) return umcRes; umcRes = InitAviSplitter(&avi_spl, &src); if(umcRes != UMC_OK) return umcRes; umcRes = avi_spl.GetInfo(&spl_info); if(umcRes != UMC_OK) return umcRes; for(track=0; track < spl_info->m_nOfTracks; track++) if(spl_info->m_ppTrackInfo[track]->m_Type == UMC::TRACK_MPEG4V) break; if(track >= spl_info->m_nOfTracks) return UMC_ERR_INVALID_STREAM; video_info = (VideoStreamInfo *)spl_info->m_ppTrackInfo[track]->m_pStreamInfo; video_info->color_format = UMC::YUY2; umcRes = InitMPEG4VDecoder(&dec, video_info); if(umcRes != UMC_OK) return umcRes; umcRes = out.Init(video_info->clip_info.width, video_info->clip_info.height, video_info->color_format); if(umcRes != UMC_OK) return umcRes; umcRes = out.Alloc(); if(umcRes != UMC_OK) return umcRes; cvNamedWindow("Display"); while(UMC_OK==umcRes || UMC_ERR_NOT_ENOUGH_DATA == umcRes) { while(UMC_ERR_NOT_ENOUGH_DATA == (umcRes = avi_spl.GetNextData(&in, track))) vm_time_sleep(5); if(UMC_OK != umcRes) break; umcRes = dec.GetFrame(&in, &out); if(umcRes != UMC_OK) break; memcpy(img->imageData, out.m_pbAllocated, out.GetMappingSize()); cvShowImage("Display", img); cvWaitKey(0); } return umcRes; } int main() { ippStaticInit(); char inp[] = "C:\Documents and Settings\cagri\My Documents\Visual Studio 2005\Projects\Disk\pb.avi"; DecodeVideo(inp); return 0; } I put m_pbAllocated variable of VideoData Class to public.My code can decode the file successfully. In this point my question is: 1- Is my problem on the getting frames from decoder? 2-Or is my problem is on transferring data from out(VideoData) yo img(IplImage)? Thanks in advance... | |||||
|
|||||||||||||
| 8488 users have contributed to 31627 threads and 100752 posts to date. |
|---|
| In the past 24 hours, we have 33 new thread(s) 138 new posts(s), and 198 new user(s). In the past 3 days, the most popular thread for everyone has been gemm(A,A,A) like possible? The most posts were made to Crash when loading skeleton The post with the most views is Dear Steve, excuse me for a d Please welcome our newest member chat1983 |