Merge remote-tracking branch 'origin/2.4' into merge-2.4
Conflicts: modules/calib3d/include/opencv2/calib3d/calib3d.hpp modules/core/include/opencv2/core/core.hpp modules/core/include/opencv2/core/cuda/limits.hpp modules/core/include/opencv2/core/internal.hpp modules/core/src/matrix.cpp modules/nonfree/test/test_features2d.cpp modules/ocl/include/opencv2/ocl/ocl.hpp modules/ocl/src/hog.cpp modules/ocl/test/test_haar.cpp modules/ocl/test/test_objdetect.cpp modules/ocl/test/test_pyrup.cpp modules/ts/src/precomp.hpp samples/ocl/facedetect.cpp samples/ocl/hog.cpp samples/ocl/pyrlk_optical_flow.cpp samples/ocl/surf_matcher.cpp
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* cap_ios.h
|
||||
* For iOS video I/O
|
||||
/* For iOS video I/O
|
||||
* by Eduard Feicho on 29/07/12
|
||||
* Copyright 2012. All rights reserved.
|
||||
*
|
||||
@@ -90,6 +88,12 @@
|
||||
- (void)createVideoPreviewLayer;
|
||||
- (void)updateOrientation;
|
||||
|
||||
- (void)lockFocus;
|
||||
- (void)unlockFocus;
|
||||
- (void)lockExposure;
|
||||
- (void)unlockExposure;
|
||||
- (void)lockBalance;
|
||||
- (void)unlockBalance;
|
||||
|
||||
@end
|
||||
|
||||
@@ -116,6 +120,7 @@
|
||||
BOOL grayscaleMode;
|
||||
|
||||
BOOL recordVideo;
|
||||
BOOL rotateVideo;
|
||||
AVAssetWriterInput* recordAssetWriterInput;
|
||||
AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor;
|
||||
AVAssetWriter* recordAssetWriter;
|
||||
@@ -128,6 +133,7 @@
|
||||
@property (nonatomic, assign) BOOL grayscaleMode;
|
||||
|
||||
@property (nonatomic, assign) BOOL recordVideo;
|
||||
@property (nonatomic, assign) BOOL rotateVideo;
|
||||
@property (nonatomic, retain) AVAssetWriterInput* recordAssetWriterInput;
|
||||
@property (nonatomic, retain) AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor;
|
||||
@property (nonatomic, retain) AVAssetWriter* recordAssetWriter;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
* cap_ios_abstract_camera.mm
|
||||
* For iOS video I/O
|
||||
* by Eduard Feicho on 29/07/12
|
||||
* by Alexander Shishkov on 17/07/13
|
||||
* Copyright 2012. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -405,4 +406,89 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)lockFocus;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isFocusModeSupported:AVCaptureFocusModeLocked]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.focusMode = AVCaptureFocusModeLocked;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for locked focus configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) unlockFocus;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.focusMode = AVCaptureFocusModeContinuousAutoFocus;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for autofocus configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)lockExposure;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isExposureModeSupported:AVCaptureExposureModeLocked]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.exposureMode = AVCaptureExposureModeLocked;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for locked exposure configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) unlockExposure;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.exposureMode = AVCaptureExposureModeContinuousAutoExposure;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for autoexposure configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)lockBalance;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeLocked]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.whiteBalanceMode = AVCaptureWhiteBalanceModeLocked;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for locked white balance configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) unlockBalance;
|
||||
{
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance]) {
|
||||
NSError *error = nil;
|
||||
if ([device lockForConfiguration:&error]) {
|
||||
device.whiteBalanceMode = AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance;
|
||||
[device unlockForConfiguration];
|
||||
} else {
|
||||
NSLog(@"unable to lock device for auto white balance configuration %@", [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
* cap_ios_video_camera.mm
|
||||
* For iOS video I/O
|
||||
* by Eduard Feicho on 29/07/12
|
||||
* by Alexander Shishkov on 17/07/13
|
||||
* Copyright 2012. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -30,7 +31,6 @@
|
||||
|
||||
#import "opencv2/highgui/cap_ios.h"
|
||||
#include "precomp.hpp"
|
||||
|
||||
#import <AssetsLibrary/AssetsLibrary.h>
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
@synthesize videoDataOutput;
|
||||
|
||||
@synthesize recordVideo;
|
||||
@synthesize rotateVideo;
|
||||
//@synthesize videoFileOutput;
|
||||
@synthesize recordAssetWriterInput;
|
||||
@synthesize recordPixelBufferAdaptor;
|
||||
@@ -85,6 +86,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
if (self) {
|
||||
self.useAVCaptureVideoPreviewLayer = NO;
|
||||
self.recordVideo = NO;
|
||||
self.rotateVideo = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -269,13 +271,8 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma mark - Private Interface
|
||||
|
||||
|
||||
|
||||
- (void)createVideoDataOutput;
|
||||
{
|
||||
// Make a video data output
|
||||
@@ -389,6 +386,38 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
[self.parentView.layer addSublayer:self.customPreviewLayer];
|
||||
}
|
||||
|
||||
- (CVPixelBufferRef) pixelBufferFromCGImage: (CGImageRef) image
|
||||
{
|
||||
|
||||
CGSize frameSize = CGSizeMake(CGImageGetWidth(image), CGImageGetHeight(image));
|
||||
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:NO], kCVPixelBufferCGImageCompatibilityKey,
|
||||
[NSNumber numberWithBool:NO], kCVPixelBufferCGBitmapContextCompatibilityKey,
|
||||
nil];
|
||||
CVPixelBufferRef pxbuffer = NULL;
|
||||
CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault, frameSize.width,
|
||||
frameSize.height, kCVPixelFormatType_32ARGB, (CFDictionaryRef) CFBridgingRetain(options),
|
||||
&pxbuffer);
|
||||
NSParameterAssert(status == kCVReturnSuccess && pxbuffer != NULL);
|
||||
|
||||
CVPixelBufferLockBaseAddress(pxbuffer, 0);
|
||||
void *pxdata = CVPixelBufferGetBaseAddress(pxbuffer);
|
||||
|
||||
|
||||
CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
CGContextRef context = CGBitmapContextCreate(pxdata, frameSize.width,
|
||||
frameSize.height, 8, 4*frameSize.width, rgbColorSpace,
|
||||
kCGImageAlphaPremultipliedFirst);
|
||||
|
||||
CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image),
|
||||
CGImageGetHeight(image)), image);
|
||||
CGColorSpaceRelease(rgbColorSpace);
|
||||
CGContextRelease(context);
|
||||
|
||||
CVPixelBufferUnlockBaseAddress(pxbuffer, 0);
|
||||
|
||||
return pxbuffer;
|
||||
}
|
||||
|
||||
#pragma mark - Protocol AVCaptureVideoDataOutputSampleBufferDelegate
|
||||
|
||||
@@ -522,7 +551,8 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
}
|
||||
|
||||
if (self.recordAssetWriterInput.readyForMoreMediaData) {
|
||||
if (! [self.recordPixelBufferAdaptor appendPixelBuffer:imageBuffer
|
||||
CVImageBufferRef pixelBuffer = [self pixelBufferFromCGImage:dstImage];
|
||||
if (! [self.recordPixelBufferAdaptor appendPixelBuffer:pixelBuffer
|
||||
withPresentationTime:lastSampleTime] ) {
|
||||
NSLog(@"Video Writing Error");
|
||||
}
|
||||
@@ -543,9 +573,12 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
|
||||
- (void)updateOrientation;
|
||||
{
|
||||
NSLog(@"rotate..");
|
||||
self.customPreviewLayer.bounds = CGRectMake(0, 0, self.parentView.frame.size.width, self.parentView.frame.size.height);
|
||||
[self layoutPreviewLayer];
|
||||
if (self.rotateVideo == YES)
|
||||
{
|
||||
NSLog(@"rotate..");
|
||||
self.customPreviewLayer.bounds = CGRectMake(0, 0, self.parentView.frame.size.width, self.parentView.frame.size.height);
|
||||
[self layoutPreviewLayer];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -583,3 +616,4 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -2473,35 +2473,33 @@ void DefaultViewPort::saveView()
|
||||
if (!fileName.isEmpty()) //save the picture
|
||||
{
|
||||
QString extension = fileName.right(3);
|
||||
|
||||
// (no need anymore) create the image resized to receive the 'screenshot'
|
||||
// image2Draw_qt_resized = QImage(viewport()->width(), viewport()->height(),QImage::Format_RGB888);
|
||||
|
||||
QPainter saveimage(&image2Draw_qt_resized);
|
||||
this->render(&saveimage);
|
||||
|
||||
// Create a new pixmap to render the viewport into
|
||||
QPixmap viewportPixmap(viewport()->size());
|
||||
viewport()->render(&viewportPixmap);
|
||||
|
||||
// Save it..
|
||||
if (QString::compare(extension, "png", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
image2Draw_qt_resized.save(fileName, "PNG");
|
||||
viewportPixmap.save(fileName, "PNG");
|
||||
return;
|
||||
}
|
||||
|
||||
if (QString::compare(extension, "jpg", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
image2Draw_qt_resized.save(fileName, "JPG");
|
||||
viewportPixmap.save(fileName, "JPG");
|
||||
return;
|
||||
}
|
||||
|
||||
if (QString::compare(extension, "bmp", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
image2Draw_qt_resized.save(fileName, "BMP");
|
||||
viewportPixmap.save(fileName, "BMP");
|
||||
return;
|
||||
}
|
||||
|
||||
if (QString::compare(extension, "jpeg", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
image2Draw_qt_resized.save(fileName, "JPEG");
|
||||
viewportPixmap.save(fileName, "JPEG");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2651,17 +2649,16 @@ void DefaultViewPort::paintEvent(QPaintEvent* evnt)
|
||||
//Now disable matrixWorld for overlay display
|
||||
myPainter.setWorldMatrixEnabled(false);
|
||||
|
||||
//overlay pixel values if zoomed in far enough
|
||||
if (param_matrixWorld.m11()*ratioX >= threshold_zoom_img_region &&
|
||||
param_matrixWorld.m11()*ratioY >= threshold_zoom_img_region)
|
||||
{
|
||||
drawImgRegion(&myPainter);
|
||||
}
|
||||
|
||||
//in mode zoom/panning
|
||||
if (param_matrixWorld.m11() > 1)
|
||||
{
|
||||
if (param_matrixWorld.m11() >= threshold_zoom_img_region)
|
||||
{
|
||||
if (centralWidget->param_flags == CV_WINDOW_NORMAL)
|
||||
startDisplayInfo("WARNING: The values displayed are the resized image's values. If you want the original image's values, use CV_WINDOW_AUTOSIZE", 1000);
|
||||
|
||||
drawImgRegion(&myPainter);
|
||||
}
|
||||
|
||||
drawViewOverview(&myPainter);
|
||||
}
|
||||
|
||||
@@ -2887,22 +2884,24 @@ void DefaultViewPort::drawStatusBar()
|
||||
//accept only CV_8UC1 and CV_8UC8 image for now
|
||||
void DefaultViewPort::drawImgRegion(QPainter *painter)
|
||||
{
|
||||
|
||||
if (nbChannelOriginImage!=CV_8UC1 && nbChannelOriginImage!=CV_8UC3)
|
||||
return;
|
||||
|
||||
qreal offsetX = param_matrixWorld.dx()/param_matrixWorld.m11();
|
||||
double pixel_width = param_matrixWorld.m11()*ratioX;
|
||||
double pixel_height = param_matrixWorld.m11()*ratioY;
|
||||
|
||||
qreal offsetX = param_matrixWorld.dx()/pixel_width;
|
||||
offsetX = offsetX - floor(offsetX);
|
||||
qreal offsetY = param_matrixWorld.dy()/param_matrixWorld.m11();
|
||||
qreal offsetY = param_matrixWorld.dy()/pixel_height;
|
||||
offsetY = offsetY - floor(offsetY);
|
||||
|
||||
QSize view = size();
|
||||
QVarLengthArray<QLineF, 30> linesX;
|
||||
for (qreal _x = offsetX*param_matrixWorld.m11(); _x < view.width(); _x += param_matrixWorld.m11() )
|
||||
for (qreal _x = offsetX*pixel_width; _x < view.width(); _x += pixel_width )
|
||||
linesX.append(QLineF(_x, 0, _x, view.height()));
|
||||
|
||||
QVarLengthArray<QLineF, 30> linesY;
|
||||
for (qreal _y = offsetY*param_matrixWorld.m11(); _y < view.height(); _y += param_matrixWorld.m11() )
|
||||
for (qreal _y = offsetY*pixel_height; _y < view.height(); _y += pixel_height )
|
||||
linesY.append(QLineF(0, _y, view.width(), _y));
|
||||
|
||||
|
||||
@@ -2910,27 +2909,25 @@ void DefaultViewPort::drawImgRegion(QPainter *painter)
|
||||
int original_font_size = f.pointSize();
|
||||
//change font size
|
||||
//f.setPointSize(4+(param_matrixWorld.m11()-threshold_zoom_img_region)/5);
|
||||
f.setPixelSize(10+(param_matrixWorld.m11()-threshold_zoom_img_region)/5);
|
||||
f.setPixelSize(10+(pixel_height-threshold_zoom_img_region)/5);
|
||||
painter->setFont(f);
|
||||
QString val;
|
||||
QRgb rgbValue;
|
||||
|
||||
QPointF point1;//sorry, I do not know how to name it
|
||||
QPointF point2;//idem
|
||||
|
||||
for (int j=-1;j<height()/param_matrixWorld.m11();j++)//-1 because display the pixels top rows left colums
|
||||
for (int i=-1;i<width()/param_matrixWorld.m11();i++)//-1
|
||||
for (int j=-1;j<height()/pixel_height;j++)//-1 because display the pixels top rows left columns
|
||||
for (int i=-1;i<width()/pixel_width;i++)//-1
|
||||
{
|
||||
point1.setX((i+offsetX)*param_matrixWorld.m11());
|
||||
point1.setY((j+offsetY)*param_matrixWorld.m11());
|
||||
// Calculate top left of the pixel's position in the viewport (screen space)
|
||||
QPointF pos_in_view((i+offsetX)*pixel_width, (j+offsetY)*pixel_height);
|
||||
|
||||
matrixWorld_inv.map(point1.x(),point1.y(),&point2.rx(),&point2.ry());
|
||||
// Calculate top left of the pixel's position in the image (image space)
|
||||
QPointF pos_in_image = matrixWorld_inv.map(pos_in_view);// Top left of pixel in view
|
||||
pos_in_image.rx() = pos_in_image.x()/ratioX;
|
||||
pos_in_image.ry() = pos_in_image.y()/ratioY;
|
||||
QPoint point_in_image(pos_in_image.x() + 0.5f,pos_in_image.y() + 0.5f);// Add 0.5 for rounding
|
||||
|
||||
point2.rx()= (long) (point2.x() + 0.5);
|
||||
point2.ry()= (long) (point2.y() + 0.5);
|
||||
|
||||
if (point2.x() >= 0 && point2.y() >= 0)
|
||||
rgbValue = image2Draw_qt_resized.pixel(QPoint(point2.x(),point2.y()));
|
||||
QRgb rgbValue;
|
||||
if (image2Draw_qt.valid(point_in_image))
|
||||
rgbValue = image2Draw_qt.pixel(point_in_image);
|
||||
else
|
||||
rgbValue = qRgb(0,0,0);
|
||||
|
||||
@@ -2943,29 +2940,29 @@ void DefaultViewPort::drawImgRegion(QPainter *painter)
|
||||
painter->drawText(QRect(point1.x(),point1.y(),param_matrixWorld.m11(),param_matrixWorld.m11()/2),
|
||||
Qt::AlignCenter, val);
|
||||
*/
|
||||
QString val;
|
||||
|
||||
val = tr("%1").arg(qRed(rgbValue));
|
||||
painter->setPen(QPen(Qt::red, 1));
|
||||
painter->drawText(QRect(point1.x(),point1.y(),param_matrixWorld.m11(),param_matrixWorld.m11()/3),
|
||||
painter->drawText(QRect(pos_in_view.x(),pos_in_view.y(),pixel_width,pixel_height/3),
|
||||
Qt::AlignCenter, val);
|
||||
|
||||
val = tr("%1").arg(qGreen(rgbValue));
|
||||
painter->setPen(QPen(Qt::green, 1));
|
||||
painter->drawText(QRect(point1.x(),point1.y()+param_matrixWorld.m11()/3,param_matrixWorld.m11(),param_matrixWorld.m11()/3),
|
||||
painter->drawText(QRect(pos_in_view.x(),pos_in_view.y()+pixel_height/3,pixel_width,pixel_height/3),
|
||||
Qt::AlignCenter, val);
|
||||
|
||||
val = tr("%1").arg(qBlue(rgbValue));
|
||||
painter->setPen(QPen(Qt::blue, 1));
|
||||
painter->drawText(QRect(point1.x(),point1.y()+2*param_matrixWorld.m11()/3,param_matrixWorld.m11(),param_matrixWorld.m11()/3),
|
||||
painter->drawText(QRect(pos_in_view.x(),pos_in_view.y()+2*pixel_height/3,pixel_width,pixel_height/3),
|
||||
Qt::AlignCenter, val);
|
||||
|
||||
}
|
||||
|
||||
if (nbChannelOriginImage==CV_8UC1)
|
||||
{
|
||||
|
||||
val = tr("%1").arg(qRed(rgbValue));
|
||||
painter->drawText(QRect(point1.x(),point1.y(),param_matrixWorld.m11(),param_matrixWorld.m11()),
|
||||
QString val = tr("%1").arg(qRed(rgbValue));
|
||||
painter->drawText(QRect(pos_in_view.x(),pos_in_view.y(),pixel_width,pixel_height),
|
||||
Qt::AlignCenter, val);
|
||||
}
|
||||
}
|
||||
|
@@ -522,7 +522,6 @@ private:
|
||||
|
||||
CvMat* image2Draw_mat;
|
||||
QImage image2Draw_qt;
|
||||
QImage image2Draw_qt_resized;
|
||||
int nbChannelOriginImage;
|
||||
|
||||
//for mouse callback
|
||||
|
Reference in New Issue
Block a user