faceDistortionPack is not completely downloading from the library file - instagram

In Spark Ar it should be 14 or 15 Blend shapes in the faceDistortionPack but it doesn't work, it just downloaded 1 Blend shape - eye-scale.
How can I completely download this pack to work in this application?
enter image description here

Related

Failure to use ml5.js image classification model-Error: Based on the provided shape, [1,64,64,4], the tensor should have 16384 values but has 20155392

I trained an image classification neural network model written in ml5.js. When I try to use the model files in a p5.js web editor, I get an error 'Based on the provided shape, [1,64,64,4], the tensor should have 16384 values but has 20155392'.
The code is in this p5 sketch - https://editor.p5js.org/konstantina1/sketches/85Ny1SC2J (clicking on the arrow in the top right corner will show the files).
When I run a local server on a web page with the same structure, I see 'model ready!' (a confirmation that the model has loaded) and that's it.
I read a lot of comments that the bin file may be corrupt - I saved the model myself producing the bin file so it should be ok.
As suggested here by the author of very similar code, https://www.youtube.com/watch?v=3MqJzMvHE3E, adding pixelDensity(1) in setup() doesn't help.
I am new to machine learning, could someone please help? Thank you in advance.
The model was trained with images 64x64 px so the input test image must be the same size.
1944 (original image width) * 2592 (original image height) * 4 (number of channels) = 20155392. The tensor should have 64 (image width) * 64 (image height) * 4 (number of channels) = 16387 values. This is what the error refers to.
The copy() method used originally didn't resize the input image properly.
The correct way to resize the image is inputImage.resize(IMAGE_WIDTH, IMAGE_HEIGHT).
Working sketch: https://editor.p5js.org/konstantina1/sketches/85Ny1SC2J
A version of the sketch with image file upload: https://editor.p5js.org/konstantina1/sketches/qMNkkkbIm

Compare images for finding the images are visibly same

Need to find the images are same , even if it has different resolution and size. No need of a pixel to pixel comparison, need to find all the images , texts, color etc. are same in the other image also.
Tried with different python packages to compare, but all are asking for same resolution. One of my image is screenshotted from Mac and other is from Ubuntu. Even both are same html, the contrast and resolution difference of the machines causing the images to become different when compare.
Tried.
Perceptual diff,
Image Hash etc.
• PDIFFER – Python wrapper for perceptualdiff tool (https://pypi.org/project/pdiffer/)
Problem - pip install pdiffer failed to install in the Macs for the latest as well as old versions
• NEEDLE - Installed needle (https://needle.readthedocs.io/en/latest/) This one has an option to specify comparison engine to be perceptualdiff/Imagemagick instead of default PIL.
Problem Found - Has an option to save baseline image first and then run assertions on them. It works when baseline is saved and then compared. I didn’t find anything that would compare the screenshots with existing images.
• OPENCV – Histogram based comparison. This converts images into grayscale, and into histograms and compares the histograms. Returns a value between -1 and 1 (-1 means not similar at all and 1 means highly similar) (https://www.pyimagesearch.com/2014/07/14/3-ways-compare-histograms-using-opencv-python/ )
Findings - I tested two images by converting into histograms and compared them Which returned a value of 0.8 (meaning somewhat similar).
Below code i tried using imagehash:
from PIL import Image import imagehash
image_one = 'result.png'
img = Image.open(image_one) image_one_hash = imagehash.whash(img)
print(image_one_hash)
image_two = 'not-found-02.png'
img2 = Image.open(image_two) image_two_hash = imagehash.whash(img2)
print(image_two_hash)
similarity = image_one_hash - image_two_hash print(similarity)

Want to find the way to generate the thumbnail image for a given pdf file

I'm currently looking for a way to generate the thumbnail image for a given pdf file, which shows several pages in the same image. The output should like what shows in the arxiv sanity website. I want to know if there is any npm package which supports this functionality. Thanks.
In ImageMagick command line, you can do that as follows. Suppose you want 8 pages from the PDF.
Input PDF from http://www.arxiv-sanity.com:
convert image.pdf[0-7] -thumbnail 140x140 -background white +smush 20 -bordercolor white -border 10 result.jpg
This takes the first 8 pages, makes thumbnails of size 140x140 and appends them side-by-side with a 20 pixels white spacing between them and adds a 10 pixel white border around it all.
Sorry, I do not know Node.js. But apparently there is a module that integrates ImageMagick. See https://github.com/yourdeveloper/node-imagemagick
var PDFImage = require("pdf-image").PDFImage; //pdf to image convert
var pdfImage = new PDFImage("1120.pdf");
pdfImage.convertPage(0).then(function (imagePath) {
},(err)=>{
console.log("err",err)
})
//##jimp Npm use thumbnail image generate
//if auth error Follow this step :
-> In /etc/ImageMagick-6/policy.xml (or /etc/ImageMagick/policy.xml) find the following line
->
and change it to allow reading and writing by the PDF coder in ImageMagick:

How to extract all images from a "read-protected" PDF from Linux command line?

I'm trying to extract images from a PDF which is read protected.
With normal PDFs the Poppler library extracts images fine, and from read-protected PDFs it can also extract the text just fine. The images are a different story though. It either doesn't extract all images, or extracts all of them in vague grey or black colors.
On the following PDF (original PDF here) which has as you can see in the thumbnail below a lot of images:
I tried the pdfimages command from the Poppler library:
$ pdfimages -j ticket.pdf i
and the pdftohtml command from mupdf:
$ pdftohtml -nodrm ticket.pdf
But both libs only extract one of the many images. That image is extracted correctly though. From other PDFs I get all images, but all of them are grey or black.
Since read-protection is supposedly only a flag in the PDF document, and not an actual scrambling or encryption of the source (in the end your computer can show the images without putting in a password) it should be possible somehow to extract the images individually. I can even create a thumbnail from the whole PDF using ImageMagick (convert ticket.pdf ticket.jpg), so why not individual images?
Does anybody know how I can extract all images from read-protected PDFs? All tips are welcome!
Not everything what looks like an image also IS an image.
Take, for example, the red-blue-yellow-green logo on the top left corner with the black+white "ticket-service" text: It is a series of vector graphics (each of the red, blue, yellow and green patches is a separate object, as is the text).
The only "real" (raster) images are the ones listed by the following command:
$ pdfimages -list ticket.pdf
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 642 462 index 1 8 image no 38 0 151 151 107K 37%
2 1 image 642 462 index 1 8 image no 38 0 151 151 107K 37%
Both these (listed) images are represented by the same PDF object with the number/generation 38 0 (so it IS only 1 image embedded in the PDF).
Just because the page is colorful doesn't mean there are a lot of images embedded!
Also, there is no "read-protection" on the PDF (whatever that may mean for you), and there also is no (user or owner) password with companion encryption on that PDF, as is shown by the following command:
$ pdfinfo ticket.pdf
Title: TicketFast
Author: Ticketmaster
Creator: TCT 4.4.4
Producer: PDFlib+PDI 5.0.4 (C++/Linux)
CreationDate: Wed May 5 18:21:29 2010
ModDate: Thu Apr 30 16:02:21 2015
Tagged: no
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 2
Encrypted: no
Page size: 595.275 x 841.89 pts (A4)
Page rot: 0
File size: 364994 bytes
Optimized: no
PDF version: 1.4
If there WAS password/encryption set on the PDF, it would report so with the line Encrypted: yes.
Some comments about PDF protection
"[....] read-protection is supposedly only a flag in the PDF document [....]"
First, there is no such thing as "read-protection". You probably mean "password protection".
Second, IF a PDF is password protected, it is also encrypted. There are two passwords:
The owner password which is required to make changes to the security/password/encryption status of the document.
The user password which is required to open and look at the document.
However, there are (quite common) cases when the user password is left "empty". All PDF readers know that, and they try that empty user "password" first. If it works, they de-crypt and open the PDF. PDFs with an empty user password may still be protected by limiting copy'n'paste, printing, modifying etc. To change that status you'd need to know the owner password...

Inaccurate results while retrieving results from image taken from iphone 4 camera

I am using ABBYY mobile SDK to retrieve text from image. if i use the image taken by my iphone 4 camera and then i place this image in resource folder of my project, it gives me correct result(refer: How to get coordinates using abbyy mobile sdk for iphone) but taking image from camera and directly processing it with SDK APIs do not give me accurate results. For eg. the result is somthing like:
"-55",
"!l",
II,
lie,
n3,
"S S--1",
"I -S s",
"^ o :=",
"'ABBYY>",
"^ Q) U",
"^ -5 -S",
"i ii",
"CL
for image (attached).
Which is not correct. I do understand the same image if i use in resource folder of my project will give me correct result . But do not give me correct result if i take this image directly from camera and process it using ABBYY SDK apis.
Please guide.
Most probably you're trying to recognize jpeg image with EXIF information about the image rotation. It is left for user to apply this rotation to the image.
The easiest solution is to use MIPO_DetectPageOrientation flag for MobileOCR recognition manager:
[fineManager setProcessingOptions:MIPO_DetectPageOrientation];
So the MobileOCR engine will try to detect page orientation.
But be aware that recognition with MIPO_DetectPageOrientation flag is over 2 times slower than without it.

Resources