28.11.2012 Views

Procesamiento digital de video en tiempo real y - Maestría en ...

Procesamiento digital de video en tiempo real y - Maestría en ...

Procesamiento digital de video en tiempo real y - Maestría en ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Procesami<strong>en</strong>to</strong> <strong>digital</strong> <strong>de</strong> vi<strong>de</strong>o <strong>en</strong> <strong>tiempo</strong> <strong>real</strong> y “vi<strong>de</strong>o wall” con la PC 100<br />

// Copia la propiedad Discontinuity<br />

hr = pSource->IsDiscontinuity();<br />

if (hr == S_OK) {<br />

pDest->SetDiscontinuity(TRUE);<br />

}<br />

else if (hr == S_FALSE) {<br />

pDest->SetDiscontinuity(FALSE);<br />

}<br />

else { // un error inesperado ocurrió...<br />

return E_UNEXPECTED;<br />

}<br />

// Copia la longitud <strong>de</strong> datos actual<br />

long lDataL<strong>en</strong>gth = pSource->GetActualDataL<strong>en</strong>gth();<br />

pDest->SetActualDataL<strong>en</strong>gth(lDataL<strong>en</strong>gth);<br />

return NOERROR;<br />

} // Copy<br />

//<br />

// Transformación (in place)<br />

//<br />

// Se aplica el efecto a la imag<strong>en</strong> <strong>en</strong> el modo 'in place' dado que la muestra<br />

// <strong>de</strong> salida no es mayor que la <strong>de</strong> <strong>en</strong>trada<br />

HRESULT CEZrgb24::Transform(IMediaSample *pMediaSample) //Objeto COM Media Sample<br />

{<br />

AM_MEDIA_TYPE* pType = &m_pInput->Curr<strong>en</strong>tMediaType(); // Esctructura que conti<strong>en</strong>e el<br />

bloque <strong>de</strong> formato<br />

VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *) pType->pbFormat; //Estructura con informacion<br />

sobre la imag<strong>en</strong> y por consigui<strong>en</strong>te razon <strong>de</strong> datos permisible<br />

BYTE *pData; // Char sin signo, apunta al buffer <strong>de</strong> imag<strong>en</strong> actual<br />

long lDataL<strong>en</strong>; // Conti<strong>en</strong>e la longitud <strong>de</strong> una muestra dada<br />

unsigned int grey,grey2; // Se usan para efectuar efectos <strong>de</strong> gris<br />

int iPixel, jPixel; // Utilizado para circular por los pixeles <strong>de</strong> la imag<strong>en</strong><br />

int temp,x,y; // Contadores <strong>de</strong> ciclos para transformaciones<br />

RGBTRIPLE *prgb; // Manti<strong>en</strong>e un apuntador al pixel actual la estructura<br />

conti<strong>en</strong>e los compon<strong>en</strong>tes RGB<br />

congela<br />

pMediaSample->GetPointer(&pData);<br />

lDataL<strong>en</strong> = pMediaSample->GetSize();<br />

// Obti<strong>en</strong>e las propieda<strong>de</strong>s <strong>de</strong> la imag<strong>en</strong> usando BITMAPINFOHEADER<br />

int cxImage = pvi->bmiHea<strong>de</strong>r.biWidth; // Ancho <strong>de</strong> la imag<strong>en</strong><br />

int cyImage = pvi->bmiHea<strong>de</strong>r.biHeight; // Altura <strong>de</strong> la imag<strong>en</strong><br />

int numPixels = cxImage * cyImage;<br />

int i = 0;<br />

// int iPixelSize = pvi->bmiHea<strong>de</strong>r.biBitCount / 8;<br />

// int cbImage = cyImage * cxImage * iPixelSize;<br />

// Incluyo la imag<strong>en</strong> <strong>en</strong> un arreglo <strong>de</strong> estructuras<br />

RGBQUAD bmiColors[61][99]; // Es importante no exce<strong>de</strong>r eswte limite <strong>de</strong> matriz o se<br />

// Para cargar la imag<strong>en</strong> .bmp<br />

HBITMAP hbitmap = (HBITMAP)LoadImage(NULL, "C:\\Mis docum<strong>en</strong>tos\\UAM6.bmp",<br />

IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);<br />

// Crea un dc <strong>de</strong> memoria<br />

HDC hMemDC = ::CreateCompatibleDC(NULL);<br />

//Selecciona el mapa <strong>de</strong> bits <strong>en</strong> el dc <strong>de</strong> memoria<br />

SelectObject(hMemDC, hbitmap);<br />

for(iPixel = 0; iPixel < 61; iPixel++)<br />

for(jPixel = 0; jPixel < 99; jPixel++){

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!