Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
7d006e36
Commit
7d006e36
authored
Jul 06, 2010
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed image rendering and memory leak in waitKey (thanks to Bart Nabbe and Steve Bushell)
parent
e1c2e72e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
4 deletions
+29
-4
window_cocoa.mm
modules/highgui/src/window_cocoa.mm
+29
-4
No files found.
modules/highgui/src/window_cocoa.mm
View file @
7d006e36
...
@@ -491,8 +491,8 @@ CV_IMPL int cvWaitKey (int maxWait)
...
@@ -491,8 +491,8 @@ CV_IMPL int cvWaitKey (int maxWait)
{
{
//cout << "cvWaitKey" << endl;
//cout << "cvWaitKey" << endl;
int returnCode = -1;
int returnCode = -1;
double start = [[NSDate date] timeIntervalSince1970];
NSAutoreleasePool *localpool = [[NSAutoreleasePool alloc] init];
NSAutoreleasePool *localpool = [[NSAutoreleasePool alloc] init];
double start = [[NSDate date] timeIntervalSince1970];
while(true) {
while(true) {
if(([[NSDate date] timeIntervalSince1970] - start) * 1000 >= maxWait && maxWait>0)
if(([[NSDate date] timeIntervalSince1970] - start) * 1000 >= maxWait && maxWait>0)
...
@@ -686,7 +686,7 @@ CV_IMPL int cvWaitKey (int maxWait)
...
@@ -686,7 +686,7 @@ CV_IMPL int cvWaitKey (int maxWait)
cvimage = cvCreateMat(arrMat->rows, arrMat->cols, CV_8UC3);
cvimage = cvCreateMat(arrMat->rows, arrMat->cols, CV_8UC3);
cvConvertImage(arrMat, cvimage, CV_CVTIMG_SWAP_RB);
cvConvertImage(arrMat, cvimage, CV_CVTIMG_SWAP_RB);
CGColorSpaceRef colorspace = NULL;
/*
CGColorSpaceRef colorspace = NULL;
CGDataProviderRef provider = NULL;
CGDataProviderRef provider = NULL;
int width = cvimage->width;
int width = cvimage->width;
int height = cvimage->height;
int height = cvimage->height;
...
@@ -703,15 +703,40 @@ CV_IMPL int cvWaitKey (int maxWait)
...
@@ -703,15 +703,40 @@ CV_IMPL int cvWaitKey (int maxWait)
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithCGImage:imageRef];
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithCGImage:imageRef];
if(image) {
if(image) {
[image release];
[image release];
}*/
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:cvimage->width
pixelsHigh:cvimage->height
bitsPerSample:8
samplesPerPixel:3
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bytesPerRow:(cvimage->width * 4)
bitsPerPixel:32];
int pixelCount = cvimage->width * cvimage->height;
unsigned char *src = cvimage->data.ptr;
unsigned char *dst = [bitmap bitmapData];
for( int i = 0; i < pixelCount; i++ )
{
dst[i * 4 + 0] = src[i * 3 + 0];
dst[i * 4 + 1] = src[i * 3 + 1];
dst[i * 4 + 2] = src[i * 3 + 2];
}
}
if( image )
[image release];
image = [[NSImage alloc] init];
image = [[NSImage alloc] init];
[image addRepresentation:bitmap];
[image addRepresentation:bitmap];
[bitmap release];
[bitmap release];
CGColorSpaceRelease(colorspace);
/*
CGColorSpaceRelease(colorspace);
CGDataProviderRelease(provider);
CGDataProviderRelease(provider);
CGImageRelease(imageRef);
CGImageRelease(imageRef);
*/
cvReleaseMat(&cvimage);
cvReleaseMat(&cvimage);
[localpool drain];
[localpool drain];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment