propagated some fixes from 2.3 to trunk

This commit is contained in:
Vadim Pisarevsky
2011-06-23 12:00:09 +00:00
parent d4fbb2c4fb
commit 49467947ac
26 changed files with 378 additions and 318 deletions

View File

@@ -87,6 +87,8 @@ Thanks to:
*/
/////////////////////////////////////////////////////////
#include "precomp.hpp"
#if _MSC_VER >= 1400
#pragma warning(disable: 4995)
#endif
@@ -100,7 +102,6 @@ Thanks to:
#include <vector>
//Include Directshow stuff here so we don't worry about needing all the h files.
#ifdef _MSC_VER
#include "DShow.h"
@@ -111,7 +112,7 @@ Thanks to:
#else
#include "dshow/dshow.h"
#include "dshow/dvdmedia.h"
#include "bdatypes.h"
#include "dshow/bdatypes.h"
interface IEnumPIDMap : public IUnknown
{
@@ -155,8 +156,6 @@ interface IMPEG2PIDMap : public IUnknown
#define _WIN32_WINNT 0x400
#endif
#include <windows.h>
/*
MEDIASUBTYPE_I420 : TGUID ='{30323449-0000-0010-8000-00AA00389B71}';

View File

@@ -433,7 +433,9 @@ bool CvCapture_FFMPEG::reopen()
return true;
}
#ifndef AVSEEK_FLAG_FRAME
#define AVSEEK_FLAG_FRAME 0
#endif
bool CvCapture_FFMPEG::open( const char* _filename )
{

View File

@@ -795,6 +795,7 @@ double CvCaptureFile::getProperty(int property_id){
double retval;
QTTime t;
//cerr << "get_prop"<<endl;
switch (property_id) {
case CV_CAP_PROP_POS_MSEC:
[[mCaptureSession attributeForKey:QTMovieCurrentTimeAttribute] getValue:&t];
@@ -815,6 +816,9 @@ double CvCaptureFile::getProperty(int property_id){
case CV_CAP_PROP_FPS:
retval = currentFPS;
break;
case CV_CAP_PROP_FRAME_COUNT:
retval = movieDuration*movieFPS/1000;
break;
case CV_CAP_PROP_FOURCC:
default:
retval = 0;

View File

@@ -74,6 +74,7 @@ CV_IMPL int cvWaitKey (int maxWait) {return 0;}
using namespace std;
const int TOP_BORDER = 7;
const int MIN_SLIDER_WIDTH=200;
static NSApplication *application = nil;
static NSAutoreleasePool *pool = nil;
@@ -182,7 +183,7 @@ CV_IMPL void cvDestroyWindow( const char* name)
//cout << "cvDestroyWindow" << endl;
CVWindow *window = cvGetWindow(name);
if(window) {
[window performClose:nil];
[window close];
[windows removeObjectForKey:[NSString stringWithFormat:@"%s", name]];
}
[localpool drain];
@@ -193,10 +194,10 @@ CV_IMPL void cvDestroyAllWindows( void )
{
//cout << "cvDestroyAllWindows" << endl;
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
for(NSString *key in windows) {
[[windows valueForKey:key] performClose:nil];
}
[windows removeAllObjects];
NSDictionary* list = [NSDictionary dictionaryWithDictionary:windows];
for(NSString *key in list) {
cvDestroyWindow([key cStringUsingEncoding:NSASCIIStringEncoding]);
}
[localpool drain];
}
@@ -221,8 +222,16 @@ CV_IMPL void cvShowImage( const char* name, const CvArr* arr)
[[window contentView] setImageData:(CvArr *)arr];
if([window autosize] || [window firstContent] || empty)
{
//Set new view size considering sliders (reserve height and min width)
NSRect vrectNew = vrectOld;
vrectNew.size = [[[window contentView] image] size];
int slider_height = 0;
for(NSString *key in [window sliders]) {
slider_height += [[[window sliders] valueForKey:key] frame].size.height;
}
vrectNew.size.height = [[[window contentView] image] size].height + slider_height;
vrectNew.size.width = std::max<int>([[[window contentView] image] size].width, MIN_SLIDER_WIDTH);
[[window contentView] setFrameSize:vrectNew.size]; //adjust sliders to fit new window size
rect.size.width += vrectNew.size.width - vrectOld.size.width;
rect.size.height += vrectNew.size.height - vrectOld.size.height;
rect.origin.y -= vrectNew.size.height - vrectOld.size.height;
@@ -393,7 +402,7 @@ CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name
if(trackbar_name == NULL || window_name == NULL)
CV_ERROR( CV_StsNullPtr, "NULL trackbar or window name" );
if(pos <= 0)
if(pos < 0)
CV_ERROR( CV_StsOutOfRange, "Bad trackbar maximal value" );
if (localpool5 != nil) [localpool5 drain];
@@ -645,17 +654,26 @@ CV_IMPL int cvWaitKey (int maxWait)
// Save slider
[sliders setValue:slider forKey:cvname];
[[self contentView] addSubview:slider];
//update contentView size to contain sliders
NSSize viewSize=[[self contentView] frame].size,
sliderSize=[slider frame].size;
viewSize.height += sliderSize.height;
viewSize.width = std::max<int>(viewSize.width, MIN_SLIDER_WIDTH);
// Update slider sizes
[[self contentView] setFrameSize:[[self contentView] frame].size];
[[self contentView] setFrameSize:viewSize];
[[self contentView] setNeedsDisplay:YES];
//update window size to contain sliders
NSRect rect = [self frame];
rect.size.height += [slider frame].size.height;
rect.size.width = std::max<int>(rect.size.width, MIN_SLIDER_WIDTH);
[self setFrame:rect display:YES];
int height = 0;
for(NSString *key in sliders) {
height += [[sliders valueForKey:key] frame].size.height;
}
[self setContentMinSize:NSMakeSize(0, height)];
}
- (CVView *)contentView {
@@ -755,6 +773,7 @@ CV_IMPL int cvWaitKey (int maxWait)
NSSlider *slider = [[cvwindow sliders] valueForKey:key];
NSRect r = [slider frame];
r.origin.y = height - r.size.height;
r.size.width = [[cvwindow contentView] frame].size.width;
[slider setFrame:r];
height -= r.size.height;
}
@@ -773,7 +792,7 @@ CV_IMPL int cvWaitKey (int maxWait)
}
NSRect imageRect = {{0,0}, {self.frame.size.width, self.frame.size.height-height-6}};
NSRect imageRect = {{0,0}, {[image size].width, [image size].height}};
if(image != nil) {
[image drawInRect: imageRect
@@ -803,9 +822,9 @@ CV_IMPL int cvWaitKey (int maxWait)
value = NULL;
userData = NULL;
[self setFrame:NSMakeRect(0,0,200,25)];
[self setFrame:NSMakeRect(0,0,200,30)];
name = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0,120, 20)];
name = [[NSTextField alloc] initWithFrame:NSMakeRect(10, 0,110, 25)];
[name setEditable:NO];
[name setSelectable:NO];
[name setBezeled:NO];
@@ -814,7 +833,7 @@ CV_IMPL int cvWaitKey (int maxWait)
[[name cell] setLineBreakMode:NSLineBreakByTruncatingTail];
[self addSubview:name];
slider = [[NSSlider alloc] initWithFrame:NSMakeRect(120, 0, 76, 20)];
slider = [[NSSlider alloc] initWithFrame:NSMakeRect(120, 0, 70, 25)];
[slider setAutoresizingMask:NSViewWidthSizable];
[slider setMinValue:0];
[slider setMaxValue:100];
@@ -825,7 +844,7 @@ CV_IMPL int cvWaitKey (int maxWait)
[self setAutoresizingMask:NSViewWidthSizable];
[self setFrame:NSMakeRect(12, 0, 182, 30)];
//[self setFrame:NSMakeRect(12, 0, 100, 30)];
return self;
}