GPUImage: GPUImageGaussianSelectiveBlur apply to large size image will black in the area being excluded blur - gpuimage

I am trying to apply GPUImageGaussianSelectiveBlurFilter to GPUImagePicture. But there seems to have a problem.
Initial GPUImagePicture with "[[GPUImagePicture alloc] initWithImage:image smoothlyScaleOutput:NO]". And,when the image size is larger (maybe width > 1024px ),the area being excluded from the blur on the image may become black whiteout anything (define by excludeCircleRadius property in GPUImageGaussianSelectiveBlurFilter)!
This problem will without exist if I smaller the image size (example: 640 * 960 px).
Could somebody tell me what may cause this problem please? Thank you very much!Thank you!

I seems to solve the problem. The key is that GPUImagePicture will get conserveMemoryForNextFrame use "if (MAX(pixelSizeOfImage.width, pixelSizeOfImage.height) > 1000.0)" This mean that the image can not be over 1000px size.

Related

Vulkan output RGBA color to BGRA color attachment

I wrote a simple Vulkan demo with BGRA images queried from swapchain. If I output RGBA pixels to it, the R channel and G channel in final result were swapped.
But when I checked the demo in Vulkan SDK dir, I found that it also use a BGRA image view for color output (I checked this in code and RenderDoc), but the final result is correct!
So, when did the conversion happen? Did I miss something?
vulkan demo output
Vulkan demo has a BGRA format output
My poor result
Edit:
Sorry about the lack of the code. The first answer gave me a hint to find the real problem in loading image from disk by FreeImage. Images it loads are stored as BGRA format with default setting on windows:
Thanks for your help and advice, #opa and #solidpixel.
You're either setting up your texture reads incorrectly, or you're setting up your swapchain writes incorrectly. If I had to guess you're uploading data into the wrong texture format, but without a complete example it's hard to tell.

Vuforia video playback with fixed dimension

I am using vuforia video playback demo with cloud recognition.
I have combined both projects and it is working properly. But currently video dimension is according to detected object. But i need fixed width and height when video plays.
Can anyone help me ?
Thanks in advance.
Well apparently Vuforia fixes the width and height at the start of the game no matter what the size of the object is. I could not find when exactly this operation is conducted but it is done at beginning of your game. When you change the size of the ImageTarget in runtime it is not fixed anymore. Add these lines to your OnTrackingFound function of DefaultTrackableEventHandler.cs
if (this.name == "WhateverTheNameOfYourRelatedImageTarget"&& !isScaled)
{
//Increase the size however you want i just added 1 to each dimension
this.transform.localScale += Vector3.one;
// make isScaled true not to scale every time it is found initially it shoud be false
isScaled = true;
}
Good luck!
What i usually do is , instead of Videoplayback , i play the video on canvas object and hook this object to Defaulttrackableeventhandler script. So when target is found, gameobject.setactive(true) and gameobject.setactive(false) when target is lost. By this method the size of the gameobject is fixed and it stays in a fixed location .
I just made an example you can get here (have to import it to any project and open the scene Assets/VideoExample/Examples). You can see there a bit clearer what the ScreenSpace - Overlay does ... it might be better to just switch to ScreenSpace - Camera in general

knitr: setting 'out.height' does suddenly not keep aspect ratio

by using knitr::include_graphics with option out.height='50px' in a rmarkdown ioslides presentation the aspect ratio is not kept on my machine. Does anyone has an idea how to solve this problem?
Interestingly, this morning it worked. But not after I installed the
R packages ggsn, ggmap, plotKML. Later I removed them, but the problem remains.
I use: Ubuntu 16.04.4, R version 3.4.4, current rmarkdown
Minimal example is:
---
title: "Untitled"
author: "Me"
date: "May 24, 2018"
output: ioslides_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo =T)
```
## R Markdown
setting out.height does NOT keep aspect ratio
```{r, out.height='50px', dpi=200}
knitr::include_graphics("rect_circ.png")
```
setting out.width keeps aspect ratio
```{r, out.width='50px', dpi=200}
knitr::include_graphics("rect_circ.png")
```
I guess you installed the png package by chance (it may be a dependency of the packages you mentioned). When png is available, include_graphics() will try to set the chunk option out.width to match your dpi setting. In your case, you set the out.height option, which leads to the problem of a distorted aspect ratio (the automatically calculated width is 96, and your manual height is 50).
If you have a desired figure size in the output, you may call
knitr::include_graphics("rect_circ.png", dpi = NA)
to avoid the automatic adjustment of out.width. If you have a desired DPI, you should leave out out.height, e.g.,
```{r}
knitr::include_graphics("rect_circ.png", dpi = 200)
``
Within in my ioslides_presentation I created a row of jpg-graphics. For this to look nice I needed to set the out.height option, so that the pictures build a rectangular block. Usually this worked:
```{r, out.height="200px",dpi=200}
maps=c("map_1.jpg","map_2.jpg","map_3.jpg")
knitr::include_graphics(maps)
```
But with the png package installed the aspect ratio of the pictures was not kept. Applying the above mentioned changes, the chunk which workes looks like this:
```{r, out.height="200px"}
maps=c("map_anthroms_full.jpg","map_anthroms_rangelands.jpg")
knitr::include_graphics(maps, dpi=NA)
```
Note: Setting a resolution within include_graphics() or ```{r, ...} produces the same error.

NSTextView will resize but parent NSScrollView not Resizing with setFrameSize

First let me say I'm coming from the iOS world and am trying to make my first OSX app. So apologies for the question if the answer is obvious. :)
I'm trying to setup an NSTextView to resize according to the amount of text in it. I've been successful at getting the NSTextView to resize properly but it's superview (NSScrollView) won't resize.
This is what I have so far...
[self.messageBodyTextView setVerticallyResizable:YES];
[self.messageBodyTextView.layoutManager ensureLayoutForTextContainer:self.messageBodyTextView.textContainer];
[self.messageBodyTextView.layoutManager boundingRectForGlyphRange:NSMakeRange(0, [self.messageBodyTextView.layoutManager numberOfGlyphs]) inTextContainer:self.messageBodyTextView.textContainer];
NSRect rect = [self.messageBodyTextView.layoutManager usedRectForTextContainer:self.messageBodyTextView.textContainer];
[self.messageBodyTextView.textContainer setContainerSize:rect.size];
[self.messageBodyTextView setMaxSize:NSMakeSize(self.messageBodyTextView.bounds.size.width, rect.size.height)];
[self.messageBodyTextView.textContainer setHeightTracksTextView:YES];
[self.messageBodyScrollView.documentView setFrameSize:rect.size];
[self.messageBodyScrollView.documentView setFrame:rect];
[self.messageBodyScrollView setFrameSize:rect.size];
self.messageBodyTextView resizes just fine with all this code (I have a feeling a have a bunch of redundant code in there). But self.messageBodyScrollView either doesn't resize at all or if I try to use setBounds then it not only resizes messageBodyTextView to messageBodyScrollView's full size but it also stretches out the text inside.
note: messageBodyTextView and messageBodyScrollView are both attached to my IB doc as IBOutlets.
My code used to be a lot shorter but this is where I've gotten to by adding in anything I can find to make these two views match up.
Any help would be very much appreciated!

When I load an image in OpenCV it is always darker than the original. Why?

So I load a color .png file that has been taken with an iphone using cvLoadImage. And after it's been loaded, when I immediately display it in my X11 terminal, the image is definitely darker than the original png file.
I currently use this to load the image:
IplImage *img3 = cvLoadImage( "bright.png", 1);
For the second parameter I have tried all of the following:
CV_LOAD_IMAGE_UNCHANGED
CV_LOAD_IMAGE_GRAYSCALE
CV_LOAD_IMAGE_COLOR
CV_LOAD_IMAGE_ANYDEPTH
CV_LOAD_IMAGE_ANYCOLOR
but none of these have worked. Grayscale definitely made the image grayscale. But as suggested from http://www.cognotics.com/opencv/docs/1.0/ref/opencvref_highgui.htm, even using CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR to load the image as truthfully as possible resulted in a darker image being displayed in the terminal.
Does anyone have any ideas on how to get the original image to display properly?
Thanks a lot in advance.
Yes, OpenCV does not apply Gamma correction.
// from: http://gegl.org/
// value: 0.0-1.0
static inline qreal
linear_to_gamma_2_2 (qreal value){
if (value > 0.0030402477)
return 1.055 * pow (value, (1.0/2.4)) - 0.055;
return 12.92 * value;
}
// from: http://gegl.org/
static inline qreal
gamma_2_2_to_linear (qreal value){
if (value > 0.03928)
return pow ((value + 0.055) / 1.055, 2.4);
return value / 12.92;
}
It only happens when you load it in OpenCV? Opening with any other viewer doesn't show a difference?
I can't confirm this without a few tests but I believe the iPhone display gamma is 1.8 (source: http://www.colorwiki.com/wiki/Color_on_iPhone#The_iPhone.27s_Display). Your X11 monitor probably is adjusted for 2.2 (like the rest of the world).
If this theory holds, yes, images are going to appear darker on X11 than on the iPhone. You may change your monitor calibration or do some image processing to account for the difference.
Edit:
I believe OpenCV really does not apply gamma correction. My reference to this is here:
http://permalink.gmane.org/gmane.comp.lib.opencv.devel/837
You might want to implement it yourself or "correct" it with ImageMagick. This page instructs you on how to do so:
http://www.4p8.com/eric.brasseur/gamma.html
I usually load an image with:
cvLoadImage("file.png", CV_LOAD_IMAGE_UNCHANGED);
One interesting test you could do to detect if OpenCV is really messing with the image data, is simply creating another image with cvCreateImage(), then copy the data to this newly created image and save it to another file with cvLoadImage().
Maybe, it's just a display error. Of course, I would suggest you to update to the most recent version of OpenCV.

Resources