mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Add low quality mode for juce CameraDevice
This commit is contained in:
parent
26b6f01ce3
commit
c21716499c
5 changed files with 22 additions and 12 deletions
|
|
@ -22,8 +22,9 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
CameraDevice::CameraDevice (const String& nm, int index, int minWidth, int minHeight, int maxWidth, int maxHeight)
|
||||
: name (nm), pimpl (new Pimpl (name, index, minWidth, minHeight, maxWidth, maxHeight))
|
||||
CameraDevice::CameraDevice (const String& nm, int index, int minWidth, int minHeight, int maxWidth, int maxHeight,
|
||||
bool highQuality)
|
||||
: name (nm), pimpl (new Pimpl (name, index, minWidth, minHeight, maxWidth, maxHeight, highQuality))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -77,10 +78,12 @@ StringArray CameraDevice::getAvailableDevices()
|
|||
|
||||
CameraDevice* CameraDevice::openDevice (int index,
|
||||
int minWidth, int minHeight,
|
||||
int maxWidth, int maxHeight)
|
||||
int maxWidth, int maxHeight,
|
||||
bool highQuality)
|
||||
{
|
||||
ScopedPointer<CameraDevice> d (new CameraDevice (getAvailableDevices() [index], index,
|
||||
minWidth, minHeight, maxWidth, maxHeight));
|
||||
minWidth, minHeight, maxWidth, maxHeight,
|
||||
highQuality));
|
||||
|
||||
if (d->pimpl->openedOk())
|
||||
return d.release();
|
||||
|
|
|
|||
|
|
@ -58,10 +58,15 @@ public:
|
|||
The size constraints allow the method to choose between different resolutions if
|
||||
the camera supports this. If the resolution cam't be specified (e.g. on the Mac)
|
||||
then these will be ignored.
|
||||
|
||||
On Mac, if highQuality is false, then the camera will be opened in preview mode
|
||||
which will allow the OS to drop frames if the computer cannot keep up in processing
|
||||
the frames.
|
||||
*/
|
||||
static CameraDevice* openDevice (int deviceIndex,
|
||||
int minWidth = 128, int minHeight = 64,
|
||||
int maxWidth = 1024, int maxHeight = 768);
|
||||
int maxWidth = 1024, int maxHeight = 768,
|
||||
bool highQuality = true);
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the name of this device */
|
||||
|
|
@ -147,7 +152,7 @@ private:
|
|||
friend struct ViewerComponent;
|
||||
|
||||
CameraDevice (const String& name, int index,
|
||||
int minWidth, int minHeight, int maxWidth, int maxHeight);
|
||||
int minWidth, int minHeight, int maxWidth, int maxHeight, bool highQuality);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CameraDevice)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ extern Image juce_createImageFromCIImage (CIImage*, int w, int h);
|
|||
|
||||
struct CameraDevice::Pimpl
|
||||
{
|
||||
Pimpl (const String&, const int index, int /*minWidth*/, int /*minHeight*/, int /*maxWidth*/, int /*maxHeight*/)
|
||||
Pimpl (const String&, const int index, int /*minWidth*/, int /*minHeight*/, int /*maxWidth*/, int /*maxHeight*/,
|
||||
bool useHighQuality)
|
||||
: input (nil),
|
||||
audioDevice (nil),
|
||||
audioInput (nil),
|
||||
|
|
@ -66,8 +67,9 @@ struct CameraDevice::Pimpl
|
|||
if (err == nil)
|
||||
{
|
||||
resetFile();
|
||||
imageOutput = useHighQuality ? [[QTCaptureDecompressedVideoOutput alloc] init] :
|
||||
[[QTCaptureVideoPreviewOutput alloc] init];
|
||||
|
||||
imageOutput = [[QTCaptureDecompressedVideoOutput alloc] init];
|
||||
[imageOutput setDelegate: callbackDelegate];
|
||||
|
||||
if (err == nil)
|
||||
|
|
@ -263,7 +265,7 @@ struct CameraDevice::Pimpl
|
|||
QTCaptureDeviceInput* audioInput;
|
||||
QTCaptureSession* session;
|
||||
QTCaptureMovieFileOutput* fileOutput;
|
||||
QTCaptureDecompressedVideoOutput* imageOutput;
|
||||
QTCaptureOutput* imageOutput;
|
||||
NSObject* callbackDelegate;
|
||||
String openingError;
|
||||
int64 firstPresentationTime, averageTimeOffset;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster
|
|||
{
|
||||
Pimpl (const String&, int index,
|
||||
int minWidth, int minHeight,
|
||||
int maxWidth, int maxHeight)
|
||||
int maxWidth, int maxHeight, bool /*highQuality*/)
|
||||
: isRecording (false),
|
||||
openedSuccessfully (false),
|
||||
imageNeedsFlipping (false),
|
||||
|
|
|
|||
|
|
@ -597,10 +597,10 @@ private:
|
|||
if (wc->isRegistered())
|
||||
{
|
||||
DWORD exstyle = 0;
|
||||
DWORD type = WS_CHILD;
|
||||
DWORD windowType = WS_CHILD;
|
||||
|
||||
hwnd = CreateWindowEx (exstyle, wc->getWindowClassName(),
|
||||
L"", type, 0, 0, 0, 0, parentToAddTo, 0,
|
||||
L"", windowType, 0, 0, 0, 0, parentToAddTo, 0,
|
||||
(HINSTANCE) Process::getCurrentModuleInstanceHandle(), 0);
|
||||
|
||||
if (hwnd != 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue