using namespace Tizen::Base;
using namespace Tizen::Media;
+using namespace Tizen::Graphics;
+
Camera* CameraTools::__pCamera(null);
Tizen::Graphics::Dimension CameraTools::__choosenResolution;
int CameraTools::__width;
int CameraTools::__height;
Tizen::Media::ICameraEventListener* CameraTools::__pListener(null);
+Tizen::Graphics::PixelFormat CameraTools::__format;
const char* pTag = "CameraTools";
return false;
}
- if (IsFailed(__pCamera->SetPreviewFormat(Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR)))
+ __format = PIXEL_FORMAT_MIN;
+
+ Tizen::Base::Collection::IListT<Tizen::Graphics::PixelFormat>* PreviewList = __pCamera->GetSupportedPreviewFormatListN();
+
+ for (int i = 0; i < PreviewList->GetCount(); i++)
+ {
+ Tizen::Graphics::PixelFormat format;
+
+ PreviewList->GetAt(i,format);
+ if(format == PIXEL_FORMAT_YCbCr420_PLANAR)
+ {
+ __format = PIXEL_FORMAT_YCbCr420_PLANAR;
+ break;
+ }else if (format == PIXEL_FORMAT_NV12)
+ {
+ __format = PIXEL_FORMAT_NV12;
+ }
+ }
+
+
+ if (IsFailed(__pCamera->SetPreviewFormat(__format)))
{
AppSecureLogExceptionTag(pTag, "SetPreviewFormat failed with %s", GetErrorMessage(GetLastResult()));
return false;
{
return __height;
}
+
+Tizen::Graphics::PixelFormat
+CameraTools::GetFormat(void)
+{
+ return __format;
+}
#include <FApp.h>
#include <FIo.h>
+using namespace Tizen::Graphics;
+using namespace Tizen::Base;
+
Tracker::Tracker()
: __pQrRecognizer(0)
, __pRenderer(0)
if (__doRender && !__terminating)
{
bool was_object = false;
- __pQrRecognizer->ProcessImage(previewedData);
+
+ Tizen::Base::ByteBuffer* pBuffer = new (std::nothrow) ByteBuffer();
+ TryReturn(pBuffer != null, , "Failed to create ByteBuffer");
+ /* check the preview format*/
+ if (CameraTools::GetFormat() == PIXEL_FORMAT_NV12)
+ {
+ byte *pSrcArray = null;
+ byte *pDstArray = null;
+ pBuffer->Construct((CameraTools::GetHeight()*CameraTools::GetWidth())*1.5);
+
+ pSrcArray = previewedData.GetPointer();
+ pDstArray = pBuffer->GetPointer();
+
+ ConvertNV12ToYCbCr(pSrcArray,pDstArray,CameraTools::GetHeight(),CameraTools::GetWidth());
+ }/*check the preview format*/
+ else
+ {
+ pBuffer->Construct(previewedData);
+ }
+
+ __pQrRecognizer->ProcessImage(*pBuffer);
+
if (GLtools::startDrawing())
{
- __pRenderer->SetTextureData(CameraTools::GetWidth(), CameraTools::GetHeight(), (unsigned char*) previewedData.GetPointer());
+ __pRenderer->SetTextureData(CameraTools::GetWidth(), CameraTools::GetHeight(), (unsigned char*) pBuffer->GetPointer());
static float zeroBuffer[4][4] = {{ 0, 0, 0, 0}};
static Tizen::Graphics::FloatMatrix4 zeroMatrix(zeroBuffer);
__pRenderer->SetModelViewMatrix(0, &zeroMatrix);
}
__pForm->Draw();
+
+ if(pBuffer)
+ delete pBuffer;
}
else if (__terminating)
{
frames = 0;
}
}
+
+void
+Tracker::ConvertNV12ToYCbCr(byte *src, byte *dst, int width, int height)
+{
+ byte *pSrcStart = src;
+ byte *pDstStart = dst;
+ byte *pDstUStart = dst + width*height;
+ byte *pDstVStart = pDstUStart + width*height/4;
+
+ //Copy Y Components
+ memcpy(pDstStart, pSrcStart, (width*height));
+ pSrcStart += width*height;
+
+ //Copy UV Components
+ for (int i = 0; i < (width*height)/4; i++)
+ {
+ *pDstUStart++ = *pSrcStart++;
+ *pDstVStart++ = *pSrcStart++;
+ }
+
+ return;
+}