How to make remap of particular area in OpenCV - image

I am facing the performance drop issue. I made some research and it seems that remap function takes too much time. Image size is VGA, but interesting area has about about 1/4 of this area. Therefore, I want to use remap() only for this region and finally get image with about 1/4 of VGA area.
This is image input in VGA resolution -green rect is trackableArea Rect
Desired output but in VGA
Generated by:
remap(originalCornersSamples[i], rview, map1, map2, INTER_NEAREST);
When I try to make remap only on specific area:
remap(frame_bgr, rview, map1(trackableArea), map2(trackableArea), INTER_NEAREST);
I got as expected - stretched desired image with desired resolution of the trackableArea rect.
map1 and map2 were generated from getPerspectiveTransform to get only TV screen from the input image. The trackableArea is a Rect like here (green lines):
Any ideas how to make it possible or how the remap() should look like?

I answer to myself :) So this helped:
resize(map1,modified,Size(trackableArea.width,trackableArea.height), 0, 0, INTER_CUBIC );
remap(frame_bgr, rview, modified, map2(trackableArea), INTER_NEAREST);

Related

Image in anychart doesn't fix the stage

I'm trying to put some logos in a chart for print them, but depending of the screen resolution logo at the right sometimes is out of the chart area and sometimes is far of the edge. I'm using stage and putting the logo with graphics.image. This is the code anychart v 8.2.1
var image = anychart.graphics.image("logo_mues2020.png", "12%", "9%",102, 43);
image.parent(container);
image = anychart.graphics.image("gepp2020.jpg", "72%", "9%", 155, 47);
image.parent(container);
container is a stage
And these are the examples in two different devices
https://imagizer.imageshack.com/img924/5741/tmDgQA.png
https://imagizer.imageshack.com/img923/7563/QuQJcI.png
does somebody has made something similar?
is there a way to fix it with the chart area or make it fit more better and really responsive?
Thanks in advance
It happens because the image size is applied in pixels, not percents. it means that the image is not resized along with the container and when the container has a small width the image goes beyond the chart.
To solve that you should use percents for the image size and apply the align setting. For details, check the sample and pay attention to lines 17 and 19.
Try to resize the chart view to see how it works.

D3D output filpped and rotated

I am trying to get a D3D capture using ID3D11DeviceContext::Map() function.
But the output is flipped and rotated.
Is this the default behavior? What is the simplest/efficient way to fix this?
D3D11_MAPPED_SUBRESOURCE desc;
hr = context->Map(pRes, subres , D3D11_MAP_READ_WRITE, 0, &desc);
// use desc.pData
context->Unmap(target, subres);
Thanks
Your code looks fine. More than likely you're simply interpreting the resulting data incorrectly. Texture data starts at the top-left and goes right, then down. For example the layout of a 4x2 texture looks like this:
[0][1][2][3]
[4][5][6][7]
Alternatively, the source texture may indeed be flipped and rotated, and is simply being corrected elsewhere in the pipeline (e.g. by rotating in the vertex shader).

drawing in Windows memory device context - resolution?

I am trying to export a plot generated by my program in the form of a bitmap. No problem with creating a bitmap in memory (with CreateDIBSection) and saving it on the disk (using GDI+). To draw I have to use device context, and the only one that is easily available is compatible with the screen. So I create a compatible dc, select the bitmap I already created into this device context and I am ready to draw and print into the bitmap. And it works - but it gives me no control over the size of the plot (note: size of the plot, not size of the bitmap). If I understand correctly what is happening mapping modes follow DPI of the screen DC which in turn means size of the plot (and text I put on the plot) is different on different computers.
Is there any way of changing the DPI resolution for the device context? Or perhaps there exist a better way of doing what I am trying to do? Perfect solution would be to ask user for the pixel bitmap size and be able to draw a plot that nicely fits the bitmap.
You don't have to use device context to draw now that you already use Gdiplus over GDI. You just associate your Gdiplus::Graphics object with a Gdiplus::Bitmap instead of HDC. Units and transformations let alone bitmap size are all independent of the device. Hope that helps.
Gdiplus::Bitmap bitmap( L"miranda_kerr.png" ); // draw over existing
Gdiplus::Graphics graphics( &bitmap );
Gdiplus::Pen pen( Gdiplus::Color(255,0,0));
Gdiplus::Status status = graphics.DrawLine( &pen, 20, 20, 100, 500 );
//...

Drawing an image with a color tint in MonoTouch

What do I need to read up on to tint the image I draw with a predefined color. Alternatively just adjust the alpha value? I've played around with BlendMode but I basically don't know what I'm doing. :)
Simplyfied code below
_backgroundImage = UIImage.FromFile ("whiteblock.png");
var ctx = UIGraphics.GetCurrentContext ();
// What do I do here to tint or adjust alpha of the image
ctx.DrawImage (rect, _backgroundImage.CGImage);
Thanks
AnkMannen
I recommend starting with the Core Image Filter reference docs (see also CIFilter).
(Note that depending on the version of the OS, not all filters may be available.)
You probably want to focus on the filters in the CICategoryColorAdjustment category.
In particular, the CITemperatureAndTint filter can adjust the tint of the image, as you ask. But, it is not straightforward to use.* There are other questions on StackOverflow describing it, like this one: Input parameters of CITemperatureAndTint (CIFilter)
Finally check out the MonoTouch docs for a code example with CITemperatureAndTint. (I believe the image attached to the examples given there are wrong, as they show a scaled image, not a tinted image.)
*It takes two parameters, each a 2D CIVector. I believe the first component of the vector is temperature and should be in the ballpark of (1k ... 30k). I believe the second component is wavelength, so in the ballpark of (380 ... 700). If someone knows better, correct me.

QGraphicsView / QGraphicsScene image size

I want to display an image in a QGraphicsView with a QGraphicsScene. My code is very basic :
QGraphicsScene* scene = new QGraphicsScene(this);
scene->addPixmap(QPixmap(qApp->applicationDirPath() +"/france.gif"));
ui->myGraphicsView->setScene(scene);
ui->myGraphicsView->fitInView(scene->sceneRect());
My problem is that my picture has a wrong size. It is very small, with wrong proportions and on the center of my GraphicsView. With qDebug i kwow that my picture is load successfully and it has a size of about 100x800px. My graphicsView is smaller so i want to resize my picture to adjust it with my GraphicsView size.
The graphicsView is set in the mainwindow Form and the scene is declared in the header : "QGraphicsScene scene;"
I try everything is possible in the world (i think) but the graphicsView is alaways blank or contains the small version of the picture. When I copy/paste some codes of internet i always get this problem. I also try with this example : Qt GUI Development - Displaying a 2D grid using QGraphicsView , same problem...
Maybe i'm very very very tired but i really don't understand what is wrong. Help me please :)
sceneRect() may not be what you think it is unless you specifically set it. Also you are missing aspectRatioMode in fitInview call which can distort it image, sometimes resulting in "small" appearance.
QGraphicsScene* scene = new QGraphicsScene(this);
QGraphicsPixmapItem p = scene->addPixmap(QPixmap(qApp->applicationDirPath() +"/france.gif"));
ui->myGraphicsView->setScene(scene);
ui->myGraphicsView->fitInView(p, Qt::KeepAspectRatio);
From my experience, a shown image is very small if we try to fitInView before the scene window is displayed. Technically, the sceneRect size is not set in the way we want until it is actually shown. Therefore, we need to let the scene window shows up before we can properly use fitInView.
Well, I think the solution is available here
Qt5 C++ QGraphicsView: Images don't fit view frame

Resources