Ask Your Question
0

How to show UIImage in processImage:(Mat&)image method

asked 2013-04-07 12:49:23 -0600

Costantino gravatar image

updated 2013-04-07 12:56:52 -0600

Hi all, I want to show a UIImage in processImage:(Mat&)image method, but it does not work. I used this code:

UIImage *imgSegnale = [UIImage imageNamed:@"testImage.png"];
self.imgViewSegnale.image = imgSegnale;

If I add this code in viewDidLod method, it works. Also work if I add this code in a (IBAction) method (using a button). But it don't work if I add this code in processImage:(Mat&)image method.

Any suggestion?

Best regards Costantino

edit retag flag offensive close merge delete

Comments

Is this C++ or Java or Python code? Havent seen these structures yet, so it looks kind of weird in the openCV context.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-07 13:22:16 -0600 )edit

This is Objective-C code. I followed this tutorial http://docs.opencv.org/doc/tutorials/ios/video_processing/video_processing.html#opencviosvideoprocessing and in "processImage:(Mat&)image" method I used grabCut() function. So, I converted cv::Mat resulting image in UIImage structure to display it in UIImageView (imgViewSegnale in the code that I wrote before ). Well, the captured image is not displayed. So I tried to display a "static" image (testImage.png) instead of the captured image, but nothing.

(I'm sorry but I do not know English very well and I find it hard to express myself)

Costantino gravatar imageCostantino ( 2013-04-07 13:47:11 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-04-11 05:15:02 -0600

ske gravatar image

updated 2013-04-11 05:17:20 -0600

Hi,

try to get main thread.

dispatch_sync(dispatch_get_main_queue(), ^{
    UIImage *imgSegnale = [UIImage imageNamed:@"testImage.png"];
    [self.imgViewSegnale setImage:imgSegnale];
    [self.view setNeedsDisplay];
});
edit flag offensive delete link more

Comments

It works, thanks a lot.

Costantino gravatar imageCostantino ( 2013-04-12 13:29:47 -0600 )edit
1

answered 2013-04-07 14:33:43 -0600

AlexanderShishkov gravatar image

Are you sure that processImage method is called? Try to add some output to Console, e.g. through NSLog.

edit flag offensive delete link more

Comments

processImage is called. In fact in this method I perform many operations (space color conversion from RGB to HVS, find contour, shape detection and grabCut) and I see result of operations.

Costantino gravatar imageCostantino ( 2013-04-07 15:23:06 -0600 )edit

Question Tools

Stats

Asked: 2013-04-07 12:49:23 -0600

Seen: 1,071 times

Last updated: Apr 11 '13