How to embedd qr codes over existing image? - qr-code

Sample image of qr code embedded over given image
So i am working with qr codes in my project and I need to superimpose my qr code over an image. Example image is attached. I generated this from an online qr code generator. Which libraries can i use to generate such such images either in a web application or a mobile application?

You can use any GD library provided by any programming language. What you're looking for is Watermarking. Some examples are:
C#
You can follow this article using GDI for .NET.
PHP
Example directly from manual.
<?php
// Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefrompng('stamp.png');
$im = imagecreatefromjpeg('photo.jpeg');
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// Copy the stamp image onto our photo using the margin offsets and the photo
// width to calculate positioning of the stamp.
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

Related

Read a locally stored image as the background image for subtraction

I'm using Emgu.CV and planning to use background subtraction. I want to do something fairly simple and read two background images from my local disk, and use one of them as the background image and the other one as the overlay to compare with / the mask.
I haven't got far though, because the signature of the method is very different than just accepting a file. I'm guessing I'm missing some conversion from a File.Read to IInputArray
IBackgroundSubtractor backgroundSubtractor = new BackgroundSubtractorMOG2();
IInputArray inputImage; // how do I create an instance of an InputArray from a local file?
IOutputArray mask;
backgroundSubtractor.Apply(imputImage, mask);
How do I go from a file in C:\<somepath>\someimage1.png to formats IInputArray, IOutputArray below?
EmguCv offers different methods to load images from file (see V1 and V2 below). For the mask you just need to define a new Mat object and it will be allocated and filled automatically when you call backgroundSubtractor.Apply(input1, mask);
//V1 load image
var input1 = new Mat(#"C:\<somepath>\someimage1.png");
//V2 load image
Mat input2 = CvInvoke.Imread(#"C:\<somepath>\someimage1.png", ImreadModes.AnyColor);
var mask = new Mat();
IBackgroundSubtractor backgroundSubtractor = new BackgroundSubtractorMOG2();
backgroundSubtractor.Apply(input1, mask);
The Mat class implements IInputtArray as well as IOutputArray.

Reduce WAV file size using cscore library

I want to reduce WAV file using cscore libary without loosing audio, something like NAudio
var pcmStream = WaveFormatConversionStream.CreatePcmStream(inputSteam);
var wavCompressedStream = new WaveFormatConversionStream(target, pcmStream);
You can change the format of a wave file with by opening the existing audio data as IWaveSource, changing its format and writing it back to any stream or file.
For example:
IWaveSource waveSource = ...
waveSource
.ToMono() //for example, convert to mono
.ChangeSampleRate(44100) // specify samplerate
.ToSampleSource()
.ToWaveSource(16) //specify bits per sample
.WriteToWavStream(stream);
But keep in mind that you probably will loose audio quality by downsampling, changing bits per sample, ...

Load and Save opaque 8 bit PNG Files using ImageSharp

I am trying to Load -> Manipulate byte array directly -> Save an 8 bit png image.
I would like to use ImageSharp to compare its speeds to my current library, however in their code example they require the pixel type to be defined (they use Rgba32):
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
// Image.Load(string path) is a shortcut for our default type.
// Other pixel formats use Image.Load<TPixel>(string path))
using (Image<Rgba32> image = Image.Load("foo.jpg"))
{
image.Mutate(x => x
.Resize(image.Width / 2, image.Height / 2)
.Grayscale());
image.Save("bar.jpg"); // Automatic encoder selected based on extension.
}
I looked through the pixel types: https://github.com/SixLabors/ImageSharp/tree/master/src/ImageSharp/PixelFormats
But there is no grayscale 8 bit pixel type.
As of 1.0.0-beta0005 There's no Gray8 pixel format because we couldn't decide what color model to use when converting from Rgb (We need that internally). ITU-R Recommendation BT.709 seems like the sensible solution because that is what png supports and what we use when saving an image as an 8bit grayscale png so it's on my TODO list.
https://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
So... currently you need to use either Rgb24 or Rgba32 when decoding the images.
Update.
As of 1.0.0-dev002094 this is now possible! We have two new pixel formats. Gray8 and Gray16 that carry only the luminance component of a pixel.
using (Image<Gray8> image = Image.Load<Gray8>("foo.png"))
{
image.Mutate(x => x
.Resize(image.Width / 2, image.Height / 2));
image.Save("bar.png");
}
Note. The png encoder by default will save the image in the input color type and bit depth. If you want to encode the image in a different color type you will need to new up an PngEncoder instance with the ColorType and BitDepth properties set.

Windows Small System Icon Height Incorrect

I'm running on Windows 10, but using Delphi 7 (yes, I know it's quite old).
I want to use the system icons in Windows and have gone about this by defining a TImageList called SystemIcons which I initialize as follows:
var
fileInfo: TSHFileInfo;
begin
SystemIcons.Handle := ShGetFileInfo('', 0, fileInfo, SizeOf(fileInfo),
SHGFI_ICON or SHGFI_SMALLICON or SHGFI_SYSICONINDEX);
...
I have SystemIcons properties set statically as a TImageList component with width and height set to 16.
Elsewhere, I wish to retrieve an icon from this image list given a valid shell object's image index. Because these are "small system icons", I expect them to be 16x16. The result of calling GetSystemMetrics(SM_CYSMICON) yields 16. Oddly, the dimensions depend upon whether I retrieve them as a bitmap or an icon.
...
var
icon: TIcon;
bm: TBitmap;
begin
...
icon := TIcon.Create;
SystemIcons.GetIcon(imgIndex, icon);
bm := TBitmap.Create;
SystemIcons.GetBitmap(imgIndex, bm);
The imgIndex is correct and the same in both cases. The image retrieved is the same in each case, as expected. The dimensions of the bitmap (bm.Width and bm.Height) are also as expected: 16x16. However, the dimensions of the icon (icon.Width and icon.Height) are not. They are 32x32.
When I paint the icon on a canvas it appears as 16x16. So it's only its Height and Width values that appear incorrect. Very odd.
Why are these different?
The images are likely actually 32x32 to begin with.
Internally, TImageList.GetIcon() simply retrieves an HICON for the chosen image directly from the underlying Win32 ImageList API, using ImageList_GetIcon(), and assigns that to the TIcon.Handle property.
TImageList.GetBitmap(), on the other hand, is a bit different. It sizes the TBitmap to the dimensions of the TImageList (16x16), and then stretch draws the chosen image onto the TBitmap.Canvas using TImageList.Draw(), which in turn uses ImageList_DrawEx().

Cocos3d: Texture not displaying

I have created a Cocos3d iOS project and facing issue on texture display. My project has been kept under this link-> https://www.yousendit.com/download/UVJpWmdzTkwzMW40WjhUQw
If we run this project, we can see a sample house model output, where roof shows in plain white color in the house. But, actually i have added a roof texture in blender, and converted in pod. I don't know why the roof texture display not displaying when running the code in simulator. Could please download my sample project https://www.yousendit.com/download/UVJpWmdzTkwzMW40WjhUQw and suggest me. This project source also contains the .blend, .dae, .pod files which its using.
CC3PODResourceNode* podRezNode = [CC3PODResourceNode nodeWithName: #"RobotPODRez"];
podRezNode.resource = [IntroducingPODResource resourceFromFile: #"DieCube.pod"];
// If you want to stop the robot arm from being animated, uncomment the following line.
// [podRezNode disableAllAnimation];
podRezNode.shouldCullBackFaces = NO;
podRezNode.location = cc3v(0.0, 0.0, 0.0);
podRezNode.isTouchEnabled = YES;
[self addChild: podRezNode];
Your DAE files do not reference any textures:
TestHouse.dae:
<library_images/>
So, you must have not exported them from Blender.

Resources