How would you process an image puzzle webapp on either the server side or the client side? [closed] - vue.js

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I am building a web app game which simply takes an image file as an input from the filesystem, divides the image into blocks, then puts the image blocks randomly so that the client-side user can relocate the blocks to restore the original image.
The platform I will be using is Elixir/Phoenix language/framework on the backend and VueJS on the front end. When I tried to manipulate image with Erlang, I had some difficulty to find libraries for pixel manipulation. But then I thought, if every user's puzzle image will have to be created on the server, it will cost a lot of resources anyway.
Do you think it's better to send the image from the server's filesystem to a client-side and create the image blocks on the client-side with Javascript or you would do it with Erlang/Elixir on the server side?
What would be your preferred method on a scientific basis, pros and cons?

This is how i am doing it.
# Args Explantion :
# -resize 72x72! - Resizes the passed Image, `!` means don't care about aspect ratio
# -crop 24x24 - Crops the image
# -scene 1 - Start naming the cropped images starting with index 1
# -%02d - produces output such as 00, 01, 02, 03
# image_size - Actual image size
# seg_size - Size of small segments/cropped images
list = [
"#{img_path}",
"-resize",
"#{image_size} x #{image_size}!",
"-crop",
"#{seg_size} x #{seg_size}",
"-scene",
"1",
"#{new_tmp}/%02d.png"
]
System.cmd("convert", list)

I would go with ImageMagick command line wrapper.
As by cropping documentation, somewhat like below would do:
convert my_image: -repage 60x40-5-3 \
-crop 30x20 +repage my_image_tiles_%d.png`
Although there is an Elixir wrapper for IM, called Mogrify, it implements a limited set of operations, so I usually go with System.cmd/3.
For each input file you might create tiles and next time the file is being accessed, you might start with a check. If the file was already cropped, just serve the tiles, otherwise crop it before serving tiles. This would be basically a clean server-side one-liner, prone to reverse engineering, unlike client-side solutions.

Related

Image comparison and Angle Estimation [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 months ago.
This post was edited and submitted for review 6 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I have a target object and a lot of other objects in an image. Target object is pre-defined with a known shape in advance as shown in figure.
My task is to detect all the target object present in the image and find the angle at which the detected object is oriented with respect to target object. For the object detection purpose I am using YOLO-V5-OBB model which gives me detection confidence and the rotated bounding box coordinates.See the result below
I would like to know how rotation angle is predicted by yolo-obb model in order to make rotated bounding boxes around the detected objects?
For finding the object:
Before using heavy machine learning models, try using classic computer vision algorithms.
For finding the object:
If the object above is the only object you will be searching for:
Use cv2.HoughCircles().
https://docs.opencv.org/3.4/d4/d70/tutorial_hough_circle.html
If you want to be able to search arbitrary objects:
Try using template matching.
https://pyimagesearch.com/2021/03/22/opencv-template-matching-cv2-matchtemplate/
After detecting the objects:
Apply Hough transform to extract the top line and detect the angle by using a line fitting algorithm.
OpenCV line-fitting (Might be deprecated)
I think you may try to use YOLOv5-OBB to train and get the coordinates of bounding box, and then it is easy to find the angle of orientation. Look at the detect.py.
https://www.youtube.com/watch?v=iRkCNo9-slY
https://github.com/hukaixuan19970627/yolov5_obb
# Write results
for *poly, conf, cls in reversed(det):
if save_txt: # Write to file
# xywh =
(xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist()
# normalized xywh

How to make a character with real face unreal engine 4 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
i am a beginner in game development.i used unreal engine4 for making a sample game. i successfully create a running game with the help of some tutorials.
next i need to model a character like me.also i interested to create an environment like my home. i have no idea about this.
is it possible to create real characters using Unreal engine 4 ?
How to create a new material(Real materials eg: Hose wall,floor) ?
How to create a characters like Gta game characters using Unreal engine?
try to using blender, That is more simple for model creation.Then import you model to unreal engine. More fast and more easy
You cannot create completely new characters inside of the Unreal Engine. To create a character you'll need a 3rd-party 3D-Modeling program. As hteshkumar said, Blender is one free possibility. Another currently free program is Fuse by Adobe, which allows you to create, rig and even animate characters.
You can create a new material by right-clicking on a free space in the object brwoser and select the new Material option. If you need a tutorial to get started have a llok at https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/
Same as the answer to question 1, but if you're really a complete beginner I'd advise you to start with something more simple than a character in GTA quality as the development of the three main characters of GTA V alone took 3 years.
You can use MakeHuman software and export in FBX format
My suggestions would be to use Adobe Fuse. It was formerly property of Mixamo but they were bought out. With Adobe/Mixamo Fuse creating characters is super simple in their Free to use app for Windows/OS X. You basically use their tool and make your characters with relative ease, upload to their store and they fully rig it for animation for you. It's important that you get your characters rigged, or else they won't be able to become animated for any said game engine.
In the Mixamo/Adobe Fuse, once it is rigged and submitted to their web site (for free), you can search 1000's of animations, and apply them to your Model/Rig. Then once finished getting animation packs you can download a fully rigged FBX for either Unreal Engine 4 or Unity for import into your project. Once imported into Unreal or Unity you can create Behavior Trees, State Machines, Animation Blueprints, Animation Blends, Physics Assets, etc. It's not all too complicated and it beats the alternative of modelling from scratch or purchasing third party assets from 3D modelers and other companies.
If you go the load less travelled you can model using Maya, Lightwave, 3DSMax, Cinema 4D, Modo, ZBrush, or even Blender (free). This isn't for the faint of heart! You have to model it, and then rig it yourself. This gives you the greatest customization options, however.
www.mixamo.com
Also here is a great video on inserting rigged animated characters in Unreal Engine 4 from Mixamo: https://www.youtube.com/watch?v=zqdqMiCldtg
When you say 'real' you probably mean a character that looks like a person instead of the blue man? Yes, you can model and animate using common programs like Maya / Blender, etc. Doing it well will require a ton of practice, so you should have a look at the Unreal Marketplace for pre-made characters.
If you want to have fun making materials, have a go with Substance Designer/Painter. I've had a lot of fun making procedural stuff and painting it in 3D. It uses a similar physical-based rendering workflow as the Unreal material editor so what you learn would be reusable.
Once again, start with the marketplace then work up to watching youtube videos on Modeling, Animating.

Open jpeg with photoshop and just save it, do i loose quality? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I apologize for what seems a stupid question, but I need to know...
If I open an image with Photoshop, let’s say a jpeg, and save the image without actually doing anything (open the image, click save and that’s all), and i do this over and over again, do I loose quality?
I believe it looses quality when i do changes and save it, but what about opening the image and just save it multiple times without applying any changes?
Usually yes, you do. That is because the quantization in JPEG isn't lossless and will reduce quality up to a fixed point after which no further degradation will occur (depending on the quality you saved at the result will be more or less visible).
However, there is a special case with Photoshop where quality degrades much faster because they tweaked the algorithm. Neal Kravetz of Hacker Factor has an article about exactly that:
I resaved the image repeatedly at 99% quality. (Load, save at 99%, reload, resave at 99%, repeat.) At 99% quality, the changes stop after 11 resaves. (Since Q99 takes very tiny steps, it hits a local minima quickly.) Resaved files #11 through #500 all have the exact same sha1 checksum. At 75% quality, it stops after 54 resaves (saves #54 through #500 are identical).
[...]
I repeated the experiment manually, using Photoshop. I lost count around 12 (doing it manually and the phone rang) [...] With fewer than two dozen resaves, you can already see parts of the walls getting brighter and darker -- much more than the JPEG algorithm can account for.
[...]
Yes, repeatedly saving a JPEG makes the image worse. But repeatedly saving it with Photoshop makes it much worse.
You will lose quality as Photoshop has a default JPEG save quality that is <100%.
Whenever you save an image as JPEG, it will process and compress the image, losing quality as JPEG is a lossy format.
it would execute the same saving code for the same pixels as before, so, no.

Compressing JPG page to PDF with various compressions/settings [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I would like to take a single page jpg, and experiment with various pdf compression settings and other settings (to analyse resultant pdf size and quality) - can anyone point me towards decent tools to do this, and any useful docs/guides?
Adobe Acrobat Distiller, Ghostscript, possibly others. Acrobat has its own manual, Ghostscript documentation can be found at:
http://svn.ghostscript.com/ghostscript/tags/ghostscript-9.02/doc/Ps2pdf.htm
for the current version PostScript to PDF conversion (print your JPEG to a PostScript file before starting).
If your original is a JPEG, then the best quality output will be to do nothing at all to it, simply wrap it up in PDF syntax.
If you insist on downsampling the image data (which is the only way you are going to reduce the size of a JPEG image) then you would be advised not to use DCT (JPEG) compression in the PDF file, as this will introduce objectionable artefacts.
You should use a lossless compression scheme instead, eg *"Flate".
Your best bet would be to go back to an original which has not been stored as a JPEG, downsample in a decent image application and then convert to JPEG and wrap that up in a PDF.
Docotic.Pdf library can be used to add JPEGs (with or without recompression) to PDF.
Please take a look at sample that shows how to recompress images before adding them to PDF. With help of the library you can recompress existing images too.
Disclaimer: I work for Bit Miracle, vendor of the library.
If you're OK working with .NET on Windows, my company, Atalasoft, has tools for creating image PDFs. You can tweak the compression very easily using code like this:
public void WriteJpegPdf(AtalaImage image, Stream outStream)
{
PdfEncoder encoder = new PdfEncoder();
encoder.JpegQuality = 60; // 0 - 100
encoder.Save(outStream, image, PdfCompressionType.Jpeg);
}
This is the simplest way of hitting the jpeg quality. It will override your setting if the image isn't 24 bit rgb or 8 bit gray.
If you are concerned with encoding a bunch of files but want fine-grained control over compression, the encoder has an event, SetEncoderCompression, that is invoked before the image is encoded to let you see what the encoder chose and you can override it if you like.
FWIW, I wrote most of the PDF Encoder and the underlying layer that exports the actual PDF.

Latex using eps images builds slowly [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Working with a latex document with eps images as in the example below...
\documentclass[11pt]{paper}
\usepackage[dvips]{graphicx}
\usepackage{fullpage}
\usepackage{hyperref}
\usepackage{amsmath}
\DeclareMathSizes{8}{8}{8}{8}
\author{Matt Miller}
\title{my paper}
\begin{document}
\begin{figure}[!ht]
\begin{center}
\includegraphics[width=2in] {Figuer.eps}
\end{center}
\caption{Figure\label{fig:myFig}}
\end{figure}
\end{document}
When I got to build my latex document the time it takes to build the document increases with time. Are there any tips or tricks to help speed up this process?
latex paper.tex; dvipdf paper.dvi
Some additional ideas:
try making a simpler figure (e.g. if it's a bitmapped figure, make a lower-resolution one or one with a low-resolution preview)
use pdflatex and have the figure be a .jpg, .png, or .pdf source.
I generally take the latter approach (pdflatex).
How big are the eps files? Latex only needs to know the size of the bounding box, which is at the beginning of the file.
dvips (not dvipdf) shouldn't take too much time since it just needs to embed the eps into the postscript file.
dvipdf, on the other hand has to convert the eps into pdf, which is expensive.
Indeed, you can use directly
pdflatex paper.tex
Few changes are required.
Convert your graphics from EPS to PDF before running pdflatex. You need to do it only once:
epstopdf Figuer.eps
If will produce Figuer.pdf which is suitable for pdflatex. In your example dvipdf does it on every build.
In the document use
\usepackage[pdftex]{graphicx} % not [dvips]
And to include graphics, omit the extension:
\includegraphics[width=2in] {Figuer} % but {Figuer.pdf} works too
It will choose Figuer.pdf when compiled by pdflatex and Figuer.eps when compiled by latex. So the document remains compatible with legacy latex (only remember to chage \usepackage{graphics}).
Reducing the file size of your EPS files might help. Here are some ideas how to do that.
If you have the original image as JPEG, PNG, TIFF, GIF (or any other sampled image), reduce the original file size with whatever tools you have, then convert to EPS using sam2p. sam2p gives you much smaller EPS file sizes than what you get from most popular converters.
If your EPS is vector graphics, convert it to PDF using ps2pdf14 (part of Ghostscript), then convert back to eps using pdftops -eps (part of xpdf). This may reduce the EPS file size a lot.
As a quick fix, try passing the [draft] option to the graphix package.
Are you using a DVI previewer or going straight to pdf?
If you go all the way to pdf, you'll pay the cost of unencoding and reencoding (I used to have that problem with visio diagrams). However, if you can generate PSs most of the time or work straight with the DVI, the experience would be manageable.
Also, some packages will create .pdf files for you from figures, which you can then embed (I do that on my mac)