HOW TO CREATE A CAMERA APPLICATION ON MAC?

0

Hello.

I want to create a camera application in c++ builder 10.2.1 on MacOS.

This is my code:

//Unit1.h
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include 
#include 
#include 
#include 
#include 
#include 
#include 
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TCameraComponent *CameraComponent1;
	TImage *Image1;
	void __fastcall FormCreate(TObject *Sender);
	void __fastcall CameraComponent1SampleBufferReady(TObject *Sender, const TMediaTime ATime);
	void __fastcall FormClose(TObject *Sender, TCloseAction &Action);

private:	// User declarations
    void __fastcall GetImage();
public:		// User declarations
	__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

//Unit1.cpp
#include 
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
	CameraComponent1->Quality = TVideoCaptureQuality::HighQuality;
	CameraComponent1->Active = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::GetImage()
{
	CameraComponent1->SampleBufferToBitmap(Image1->Bitmap, true);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CameraComponent1SampleBufferReady(TObject *Sender, const TMediaTime ATime)
{
    TThread::Synchronize(TThread::Current, GetImage);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
    CameraComponent1->Active = false;
}
//---------------------------------------------------------------------------

It works fine only when it is in foreground.

If it is in background, it would crash.

How can I make it work fine in background?

Best Regards,

Dean

  • Accepted Answer

    Friday, March 02 2018, 12:19 PM - #Permalink
    0

    HAve you tried the sample Camera application:  C:\Users\Public\Documents\Embarcadero\Studio\19.0\Samples\CPP\Mobile Snippets\AccessCameraApp\

    The reply is currently minimized Show
  • Responses (0)
    • There are no replies here yet.
    Your Reply

    Please login to post a reply.........