Giter Club home page Giter Club logo

caire's Introduction

Caire Logo

build Go Reference license release homebrew caire

Caire is a content aware image resize library based on Seam Carving for Content-Aware Image Resizing paper.

How does it work

  • An energy map (edge detection) is generated from the provided image.
  • The algorithm tries to find the least important parts of the image taking into account the lowest energy values.
  • Using a dynamic programming approach the algorithm will generate individual seams across the image from top to down, or from left to right (depending on the horizontal or vertical resizing) and will allocate for each seam a custom value, the least important pixels having the lowest energy cost and the most important ones having the highest cost.
  • We traverse the image from the second row to the last row and compute the cumulative minimum energy for all possible connected seams for each entry.
  • The minimum energy level is calculated by summing up the current pixel value with the lowest value of the neighboring pixels obtained from the previous row.
  • We traverse the image from top to bottom and compute the minimum energy level. For each pixel in a row we compute the energy of the current pixel plus the energy of one of the three possible pixels above it.
  • Find the lowest cost seam from the energy matrix starting from the last row and remove it.
  • Repeat the process.

The process illustrated:

Original image Energy map Seams applied
original sobel debug

Features

Key features which differentiates this library from the other existing open source solutions:

  • GUI progress indicator
  • Customizable command line support
  • Support for both shrinking or enlarging the image
  • Resize image both vertically and horizontally
  • Face detection to avoid face deformation
  • Support for multiple output image type (jpg, jpeg, png, bmp, gif)
  • Support for stdin and stdout pipe commands
  • Can process whole directories recursively and concurrently
  • Use of sobel threshold for fine tuning
  • Use of blur filter for increased edge detection
  • Support for squaring the image with a single command
  • Support for proportional scaling
  • Support for protective mask
  • Support for removal mask
  • GUI debug mode support

Install

First, install Go, set your GOPATH, and make sure $GOPATH/bin is on your PATH.

$ go install github.com/esimov/caire/cmd/caire@latest 

MacOS (Brew) install

The library can also be installed via Homebrew.

$ brew install caire

Usage

$ caire -in input.jpg -out output.jpg

Supported commands:

$ caire --help

The following flags are supported:

Flag Default Description
in - Input file
out - Output file
width n/a New width
height n/a New height
preview true Show GUI window
perc false Reduce image by percentage
square false Reduce image to square dimensions
blur 4 Blur radius
sobel 2 Sobel filter threshold
debug false Use debugger
face false Use face detection
angle float Plane rotated faces angle
mask string Mask file path
rmask string Remove mask file path
color string Seam color (default #ff0000)
shape string Shape type used for debugging: circle,line (default circle)

Face detection

The library is capable of detecting human faces prior resizing the images by using the lightweight Pigo (https://github.com/esimov/pigo) face detection library.

The image below illustrates the application capabilities for human face detection prior resizing. It's clearly visible that with face detection activated the algorithm will avoid cropping pixels inside the detected faces, retaining the face zone unaltered.

Original image With face detection Without face detection
Original With Face Detection Without Face Detection

Sample image source

GUI progress indicator

GUI preview

A GUI preview mode is also incorporated into the library for in time process visualization. The Gio GUI library has been used because of its robustness and modern architecture. Prior running it please make sure that you have installed all the required dependencies noted in the installation section (https://gioui.org/#installation) .

The preview window is activated by default but you can deactivate it any time by setting the -preview flag to false. When the images are processed concurrently from a directory the preview mode is deactivated.

Face detection to avoid face deformation

In order to detect faces prior rescaling, use the -face flag. There is no need to provide a face classification file, since it's already embedded into the generated binary file. The sample code below will resize the provided image with 20%, but checks for human faces in order tot avoid face deformations.

For face detection related settings please check the Pigo documentation.

$ caire -in input.jpg -out output.jpg -face=1 -perc=1 -width=20

Support for stdin and stdout pipe commands

You can also use stdin and stdout with -:

$ cat input/source.jpg | caire -in - -out - >out.jpg

in and out default to - so you can also use:

$ cat input/source.jpg | caire >out.jpg
$ caire -out out.jpg < input/source.jpg

You can provide also an image URL for the -in flag or even use curl or wget as a pipe command in which case there is no need to use the -in flag.

$ caire -in <image_url> -out <output-folder>
$ curl -s <image_url> | caire > out.jpg

Process multiple images from a directory concurrently

The library can also process multiple images from a directory concurrently. You have to provide only the source and the destination folder and the new width or height in this case.

$ caire -in <input_folder> -out <output-folder>

Support for multiple output image type

There is no need to define the output file type, just use the correct extension and the library will encode the image to that specific type. You can export the resized image even to a Gif file, in which case the generated file shows the resizing process interactively.

Other options

In case you wish to scale down the image by a specific percentage, it can be used the -perc boolean flag. In this case the values provided for the width and height are expressed in percentage and not pixel values. For example to reduce the image dimension by 20% both horizontally and vertically you can use the following command:

$ caire -in input/source.jpg -out ./out.jpg -perc=1 -width=20 -height=20 -debug=false

Also the library supports the -square option. When this option is used the image will be resized to a square, based on the shortest edge.

When an image is resized on both the X and Y axis, the algorithm will first try to rescale it prior resizing, but also will preserve the image aspect ratio. The seam carving algorithm is applied only to the remaining points. Ex. : given an image of dimensions 2048x1536 if we want to resize to the 1024x500, the tool first rescale the image to 1024x768 and then will remove only the remaining 268px.

Masks support:

  • -mask: The path to the protective mask. The mask should be in binary format and have the same size as the input image. White areas represent regions where no seams should be carved.
  • -rmask: The path to the removal mask. The mask should be in binary format and have the same size as the input image. White areas represent regions to be removed.
Mask Mask removal
mask.mp4
rmask.mp4

Caire integrations

snapcraft caire

Results

Shrunk images

Original Shrunk
broadway_tower_edit broadway_tower_edit
waterfall waterfall
dubai dubai
boat boat

Enlarged images

Original Extended
gasadalur gasadalur
dubai dubai

Useful resources

Author

License

Copyright © 2018 Endre Simo

This project is under the MIT License. See the LICENSE file for the full license text.

caire's People

Contributors

benjamin-s avatar calebdoxsey avatar donatj avatar esimov avatar im-kulikov avatar nvictor avatar southclaws avatar testwill avatar whereswaldon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

caire's Issues

caire never completes

Hello,
I just gave caire a try against one of my images and it seems to be spinning non-stop.

./caire -in ./source.JPG -out ./dest.JPG -width 480 -height 720

And, I then changed to perc 20 and this worked but produced the image that is almost 3 times the original size.

Not sure what I am missing. Also, -debug doesn't print anything ...

Let me know what additional info you need ...

Thanks!

Suggesting support for pipes

It would be ideal if pipes were usable with the CLI for enabling more expanded use-cases. After having worked with ImageMagick in the past - I could see this being a highly requested feature.

With ImageMagick you can have the input arrive from a pipe, or have the output sent to a pipe.

Examples:

Pipe to file:

caire -in bridge.jpg -scale -perc 70 > small_bridge.jpg

Input from pipe:

caire -scale -perc 70 -out smaller_bridge.jpg < small_bridge.jpg

Input and output from pipe:

cat small_bridge.jpg | caire -scale -perc 70 > smaller_bridge.jpg

There are usages of pipes in the OpenFaaS CLI (also in Go) if that helps. https://github.com/openfaas/faas-cli

Reducing memory usage when processing images

I'm using this library in a project of mine, and I realized that resizing was using an incredible amount of RAM, much more than I would have expected to process one image. I decided to run a memory profiler to confirm my suspicions. I tested this image, rescaling from from 2048x1536 to 1920x1080. These were the results [pdf] I got after running caire with pprof. Specifically, here was the code I used:

func resize(in io.Reader, out io.Writer) {
	defer profile.Start(profile.MemProfile).Stop()
	p := &caire.Processor {
		NewWidth:  1920,
		NewHeight: 1080,
		Scale: true,
	}

	err := p.Process(in, out)
	check(err)
}

As you can see, caire used 3.4 GB of RAM to process this one image. I decided to investigate further on what it was using this memory for, and focused on the reduce() function, which is the main function which is called repeatedly when resizing an image:

reduce := func() {
	width, height := img.Bounds().Max.X, img.Bounds().Max.Y
	c = NewCarver(width, height)
	c.ComputeSeams(img, p)
	seams := c.FindLowestEnergySeams()
	img = c.RemoveSeam(img, seams, p.Debug)
	imgs = append(imgs, img)
}

The program appends each iteration it creates to an imgs slice, which from my understanding is only used when the input is a gif, since that slice will be used to reconstruct the frames of the gif. Since I was processing a jpg, I removed the line and ran the program through a profiler again, and here were the results [pdf]. Removing this one line reduces the memory usage from 3.4 GB to only 232 MB.

I tested the change on another image and found a similar reuction, from [1.8 GB] to [231 MB]. More testing could be done, but I would propose adding another parameter to the Processor struct, like 'IsGIF', then only appending the images to the slice if this is given as true, such as

if (p.IsGIF) {
	imgs = append(imgs, img)
}

Embed the cascade classifier for face detection

Is your feature request related to a problem? Please describe.

Because Go 1.16 offers support for embedded files, it's desirable to embed the cascade face classifier directly into the generated binary file. This way we can avoid having to provide the face classifier as a parameter for the CLI application.

Suggesting golang module

In order to make it easy to use caire as a library it would be to nice to have caire using golang modules.

Suggestion: Continuous Fuzzing

Hi, I'm Yevgeny Pats Founder of Fuzzit - Continuous fuzzing as a service platform.

We have a free plan for OSS and I would be happy to contribute a PR if that's interesting.
The PR will include the following

  • go-fuzz fuzzers (This is generic step not-connected to fuzzit)
  • Continuous Fuzzing of master branch which will generate new corpus and look for new crashes
  • Regression on every PR that will run the fuzzers through all the generated corpus and fixed crashes from previous step. This will prevent new or old bugs from crippling into master.

You can see our basic example fuzzitdev/example-go and you can see an example of "in the wild" integration google/syzkaller.

Let me know if this is something worth working on.

Cheers,
Yevgeny

index out of range on scale for jpg

imageFile, err := os.Open(inPath)
if err != nil {
	return err
}
defer imageFile.Close()

outFile, err := os.Create(outPath)
if err != nil {
	return err
}
defer outFile.Close()

p := &caire.Processor{NewWidth: width, Scale: true}
return p.Process(imageFile, outFile)

I have a function along the lines of that, I've removed some superflous details.

panic: runtime error: index out of range

goroutine 217 [running]:
github.com/esimov/caire.(*Carver).get(...)
        D:/Golibs/src/github.com/esimov/caire/carver.go:62
github.com/esimov/caire.(*Carver).ComputeSeams(0xc042f36240, 0xc0426cb140, 0xc0426e3300, 0xc0421aad80, 0x30, 0x30)
        D:/Golibs/src/github.com/esimov/caire/carver.go:201 +0xf1b
github.com/esimov/caire.(*Processor).Resize.func1()
        D:/Golibs/src/github.com/esimov/caire/process.go:74 +0x112
github.com/esimov/caire.(*Processor).Resize(0xc0426e3300, 0xc0426cb140, 0xc0426e3340, 0xc042121e00, 0xbb4c00, 0xc042cb4000)
        D:/Golibs/src/github.com/esimov/caire/process.go:159 +0x892
github.com/esimov/caire.Resize(0xc58c20, 0xc0426e3300, 0xc0426e3340, 0xc042121e00, 0xb79560, 0x4, 0x0)
        D:/Golibs/src/github.com/esimov/caire/process.go:41 +0x42
github.com/esimov/caire.(*Processor).Process(0xc0426e3300, 0xc59860, 0xc042fb6030, 0xc59880, 0xc042fb6038, 0x0, 0x4)
        D:/Golibs/src/github.com/esimov/caire/process.go:177 +0x85

Processing does not finish

I was trying to resize an png image of the dimension 1200 × 750 to 120 x 120. However, the terminal output stuck at Processing... - for minutes.

Usage in go code.

Can this library be used in go code. If yes, there is no link for documentation.

runtime error: index out of range

Failed when scaling a jpg image of 204x383 to png of 408x766.
Tried to caire -in in.jpg -out out.jpg -square, that was fine.

$ caire -in in.jpg -out out.png -width=408 -height=766
Processing... -panic: runtime error: index out of range

goroutine 1 [running]:
github.com/esimov/caire.(*Carver).get(...)
	/home/beenotung/goroot/src/github.com/esimov/caire/carver.go:49
github.com/esimov/caire.(*Carver).ComputeSeams(0xc420b9c0c0, 0xc420058800, 0xc42001c1e0, 0xc420a6d600, 0x198, 0x198)
	/home/beenotung/goroot/src/github.com/esimov/caire/carver.go:109 +0x6e9
github.com/esimov/caire.(*Processor).Resize.func1()
	/home/beenotung/goroot/src/github.com/esimov/caire/process.go:66 +0x116
github.com/esimov/caire.(*Processor).Resize(0xc42001c1e0, 0xc420058800, 0xc4200e0080, 0xc420058340, 0xffffffffffffffff, 0xc4201d8000)
	/home/beenotung/goroot/src/github.com/esimov/caire/process.go:122 +0x51f
github.com/esimov/caire.Resize(0x5ac2c0, 0xc42001c1e0, 0xc420058340, 0xc4200e0080, 0x51cdb0, 0x4, 0x0)
	/home/beenotung/goroot/src/github.com/esimov/caire/process.go:35 +0x3b
github.com/esimov/caire.(*Processor).Process(0xc42001c1e0, 0x5ac4c0, 0xc42000c080, 0x5ac500, 0xc42000c088, 0x0, 0x0)
	/home/beenotung/goroot/src/github.com/esimov/caire/process.go:138 +0x7e
main.main()
	/home/beenotung/goroot/src/github.com/esimov/caire/cmd/caire/main.go:121 +0x54c

wrong resize dimension

my input image is of size 204x383 (portrait).

Whenever I run

caire -in in.jpg -out out.jpg -width=$((204*3/2)) -height=$((383*3/2))

or

caire -in in.jpg -out out.jpg -width=$((383*3/2)) -height=$((204*3/2))

The output image is in landscape (though it doesn't looks the same).

Input Size Resize Size Actual Output Size
204x383 306x574 306x192
204x383 574x306 574x306

how to use Pigo face detector when run caire command

Hi
since caire provide the flag '-face', but when I specified this flag, caire will report a error that is 'please provide a face classifier file'. I know Pigo is face detector which can be used here, but I don't know how to use it. Could you please help me ? Thanks in advance.

Enhancement: Proportional scaling first

When generating an image at, for example, half "resolution", this tool creates undesirable effects as it tries to remove half the image data while keeping everything at it's current resolution, resulting in rather mangled output. The solution to this is to first resize the image using a traditional scaling method without applying any cropping, then passing the data to this tool to apply the cropping to the image.

It would be nice to see a flag, that when set, would automatically pre-scale an image before applying this algorithm to it.

eg:
Given an image of dimensions 2048x1536 if I supply a command similar to the following:
caire -in image.jpg -out thumb.jpg -width=1024 -height=500 -scale=1
it would be nice to see the tool first resize the image to 1024x768, then utilize it's existing algorithms to remove the final 268 pixels instead of its current implementation on trying to keep everything the same scale and having to remove much more data.

I don't know if keeping the original resolution image is beneficial for calculating better seems however.

console color not reset after finish

after I run the resize successfully, it print out:

Rescaled in: 17.47s
Saved as: out.jpg 

where 17.47s and out.jpg are in green color, other are same as console default color.
But the reset of the console (username:folder$ ) are still in green color.

output format is not respecting the filename

Action performed

resize an png image to a smaller image

Expected behavior

the generated image should be a png file

Actual behavior

the generated image is jpeg file

Example

beenotung:caire$ caire -in 'ctrl police esc chasing.png' -out 'ctrl police esc chasing.1.png' -perc -width 20 -height 20
Processing... |
Rescaled in: 21.94s
Saved as: ctrl police esc chasing.1.png 

beenotung:caire$ file ctrl\ police\ esc\ chasing*
ctrl police esc chasing.1.png: JPEG image data, baseline, precision 8, 690x262, frames 3
ctrl police esc chasing.png:   PNG image data, 863 x 328, 8-bit/color RGB, non-interlaced

Wrap CAIRE up into an app

Hey!
I feel it'd be great having this as tool as a Web App for general public to make use of. Would you be interested in building a backend over this so that a Web App (which I could build) could use it as an API.

Anyone interested in such a project feel free start a discussion cause I see potential in this!

-ajayns

New method with more flexibility?

It would be nice, if there was a method on Processor like Processor.Resize which took image.Image or something like Processor.Process which lets you control what you want to encode the image as.

Performance improvement on using the face detection functionality

For performance reasons we shouldn't encode each time the image raw pixel data into an image file when running the face detector. This way we can avoid to generate a new image at each iteration and also we can avoid of using a global TempImage variable available across the whole codebase.

Enlarge doesn't work

Describe the bug

I installed it from the AUR (`yay -S caire).

When I'm trying this command:

caire -perc=0 -width 3840 -height 1080 -in everyone.png -out test.png

than I'm getting this:

⚡ CAIRE is resizing the image... ✔
Error resizing the image:
	Reason: scale option can not be used on image enlargement

How can I expand the image to 3840x1080?

API related bug

I don't really know what to write here... (I'm not familiar with go)

Expected behavior

That I'm getting the same image just bigger.

Screenshots

  • [Screenshots, logs or errors]

image

Bug with the Desktop version (please complete the following information):

  • Sytem information like OS: [e.g. macOS, Ubuntu]
  • You are using the binary file from the uploaded releases or you are doing a manual build?

As I said in the beginning I installed it from the AUR and run it via CLI.

Additional context

enlarge by percentage is not supported

$ caire -in in.png -out out.jpg -perc=1 -width=150 -height=150 -debug=false
Processing... -
Error rescaling image: in.png. Reason: The generated image size should be less than original image size.

while specifying the enlargement size also have other problems as mentioned in #24

Using -square seems to take forever

I used caire with a couple of images, and aside from the girl example in the README, I haven't gotten it to actually provide an output with any of the images I tried, even after 10-15mins. I have tried using different flags to make it faster, but it seems to be stuck processing forever.

Here's an example to reproduce my issue:

wget -O input.jpg "https://unsplash.com/photos/CaDoHQ3fB8w/download?force=true"
caire -in input.jpg -out output.jpg -face=false -scale -square -width=500 -height=500 -blur=0

Any suggestions?

Homebrew Installation is Out of Date

Trying to take the library for a spin, but it seems like the Homebrew installation is out of date. After installing and running caire --help I get the following output:

Usage of caire:
  -blur int
    	Blur radius (default 1)
  -debug
    	Use debugger
  -height int
    	New height
  -in string
    	Source
  -out string
    	Destination
  -perc
    	Reduce image by percentage
  -sobel int
    	Sobel filter threshold (default 10)
  -square
    	Reduce image to square dimensions
  -width int
    	New width

Some notable flags missing are -scale and -face. I've tried to use both of these as my images never seem to finish processing.

I tried the alternative installation method, but when I run go get -u -f github.com/esimov/caire/cmd/caire I get the following error (could open a separate issue for this if needed):

# gocv.io/x/gocv
imgproc.cpp:27:26: error: expected '(' for function-style cast or type construction
imgproc.cpp:30:19: error: expected '(' for function-style cast or type construction
imgproc.cpp:133:28: error: expected '(' for function-style cast or type construction

Anyone else experiencing something similar?

Leaky ASCII colours

Hi there, I resized an image and the yellow/green highlight got left on. I guess this may be a bug in terminator code? Is an expression missing?

screen shot 2018-08-13 at 4 35 02 pm

Thanks,

Alex

how to enlarge

I do not see in the docs how to enlarge an image (for example -perc1 -width 20 reduce the width in 20%)

[minor] Image example labelled "scotland" is not Scotland.

FYI, the image labeled "scotland" is in fact Gásadalur in the Faroe Islands, which is easily corroborated by a google image search. It's a beautiful place which I have been to many times, so I'd appreciate if the caption was fixed.

This project does look very interesting! I'd know that view from anywhere, though, so I thought I'd let you know.

Processing... /panic: runtime error: index out of range

14:21:32:/Users/balupton/Dropbox/Ben, Helen/Artwork Exports/Exports:master
> caire -in 3x -out 1024h -height=1024 -scale=true
Processing... /panic: runtime error: index out of range

goroutine 1 [running]:
github.com/esimov/caire.(*Carver).get(...)
	/Users/esimov/Go/src/github.com/esimov/caire/carver.go:62
github.com/esimov/caire.(*Carver).ComputeSeams(0xc4200765a0, 0xc420053800, 0xc420052400, 0xc4231ee000, 0x400, 0x400)
	/Users/esimov/Go/src/github.com/esimov/caire/carver.go:201 +0xfa2
github.com/esimov/caire.(*Processor).Resize.func1()
	/Users/esimov/Go/src/github.com/esimov/caire/process.go:74 +0x116
github.com/esimov/caire.(*Processor).Resize(0xc420052400, 0xc420053800, 0x0, 0xc4200520c0, 0xffffffffffffffff, 0xc42138e000)
	/Users/esimov/Go/src/github.com/esimov/caire/process.go:147 +0x8f6
github.com/esimov/caire.Resize(0x11db2a0, 0xc420052400, 0xc4200520c0, 0xc420052480, 0x113b93a, 0x3, 0x0)
	/Users/esimov/Go/src/github.com/esimov/caire/process.go:41 +0x3b
github.com/esimov/caire.(*Processor).Process(0xc420052400, 0x11db4a0, 0xc42000c090, 0x11db4e0, 0xc42000c098, 0x0, 0x0)
	/Users/esimov/Go/src/github.com/esimov/caire/process.go:177 +0x7e
main.main()
	/Users/esimov/Go/src/github.com/esimov/caire/cmd/caire/main.go:143 +0x5c5
[2]:14:28:12:/Users/balupton/Dropbox/Ben, Helen/Artwork Exports/Exports:master
> 
> caire --version
flag provided but not defined: -version

┌─┐┌─┐┬┬─┐┌─┐
│  ├─┤│├┬┘├┤
└─┘┴ ┴┴┴└─└─┘

Content aware image resize library.
    Version: 1.1.0

  -blur int
    	Blur radius (default 1)
  -cc string
    	Cascade classifier
  -debug
    	Use debugger
  -face
    	Use face detection
  -height int
    	New height
  -in string
    	Source
  -out string
    	Destination
  -perc
    	Reduce image by percentage
  -scale
    	Proportional scaling
  -sobel int
    	Sobel filter threshold (default 10)
  -square
    	Reduce image to square dimensions
  -width int
    	New width
> uname -a
Darwin balbook-2018.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64

caire:command not found

I have finished go install and it have no errors. But I use caire --help to test, it show -bash: caire: command not found. Please give me some instructions. Thank you.

Improve the generated image output when vertical and horizontal resize is used at the same time.

Describe the bug

When an image is resized both horizontally and vertically, the seam carving algorithm first will resize horizontally then vertically, but sometimes, depending on the image, this results with some unpleasant outcome. If we would process the image by applying the seam carving algorithm on horizontal and vertical axis intermittently normally the output would be much better.

Implement own face detection library to remove opencv dependency

In your readme you said

i'm planning to implement my own face detection library to minimize the dependency tree

I wanted to create this ticket so I could watch it and get notified when this is done. I'd love to be able to just install th binary and not have to use homebrew or install any dependencies.

Thanks

Unable to install from source

Hi, I get the same error every time I try to $ go get:

$ export GOPATH="$HOME/go"
$ export PATH="$PATH:$GOPATH/bin"
$ go get -u -f github.com/esimov/caire/cmd/caire
# gocv.io/x/gocv
core.cpp: In function ‘cv::Mat* Mat_ConvertFp16(Mat)’:
core.cpp:80:5: error: ‘convertFp16’ is not a member of ‘cv’
     cv::convertFp16(*m, *dst);
     ^
core.cpp: In function ‘void Mat_EigenNonSymmetric(Mat, Mat, Mat)’:
core.cpp:344:5: error: ‘eigenNonSymmetric’ is not a member of ‘cv’
     cv::eigenNonSymmetric(*src, *eigenvalues, *eigenvectors);
     ^
core.cpp: In function ‘void Rotate(Mat, Mat, int)’:
core.cpp:380:5: error: ‘rotate’ is not a member of ‘cv’
     cv::rotate(*src, *dst, rotateCode);
     ^
core.cpp:380:5: note: suggested alternatives:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/opencv2/core/core.hpp:56,
                 from /usr/include/opencv2/opencv.hpp:47,
                 from core.h:24,
                 from core.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:1431:5: note:   ‘std::_V2::rotate’
     rotate(_ForwardIterator __first, _ForwardIterator __middle,
     ^
/usr/include/c++/5/bits/stl_algo.h:1431:5: note:   ‘std::_V2::rotate’

Could someone explain what am I doing wrong?

Use Github actions instead of travis

Is your feature request related to a problem? Please describe.

Because Github Actions offer more customization than Travis we can consider to migrate the CI part.

caire-openfaas - Error received during build

Looks like building caire using openfaas is 31 step process. I am getting the following error at Step 15.
Screen Shot 2020-06-02 at 11 27 34 AM

Errors received during build:

  • [caire-image-resizer] received non-zero exit code from build, error: The command '/bin/sh -c test -z "$(gofmt -l $(find . -type f -name '.go' -not -path "./vendor/" -not -path "./function/vendor/*"))" || { echo "Run "gofmt -s -w" on your Golang code"; exit 1; }' returned a non-zero code: 1

How do I go about this?

Square option problem

Hi, when I try to resize an image with size 2400 * 2400 with setting New_width = 180, scale = true, Square = true, face detection = true, it will not resize the image and output the original image after process, if Square option is removed, then it will resize the image correctly. I wonder if it is config problem or others?

Thank you

Installation on macOS

I'm new to Go. I have this version installed:

go version go1.9.3 darwin/amd64

I followed the basic installation instructions from the README:

$ go get github.com/esimov/caire/cmd/caire
$ go install

Afte running the go get command, I end up with a go folder in my filesystem's root. I'm not sure where I should execute go install or what should happen next. Should I simply put the caire executable in a specific folder to make it work?

Thanks for your help.
Roel

Option to hide seams on output

Great work on this, I'm having fun just messing around with it.

Forgive me if this is obvious - but is there a way to hide the seams on the output file? Each result I have includes the red seams on the image.

Thanks!

Free image after processing

Hi,

thank you for this awesome library. I aspire to use it in my application for "cropping" profile images to squares when they are not uploaded as squares.

But: The library does not seem to free its used memory when it's done processing which means my server hits memory limit after two or three users uploaded their image. (200MB to 1.5GB, depending on the image)

The code I used to resize images

Please remind me if I have missed something and there is an option to cleanup.

index out of range when scaling up

I'm playing around with this as a library rather than a command-line utility, I wanted to do stuff in-memory without files and unfortunately Process doesn't take an io.Writer (PR incoming!) so for now, I simply copied this code:

	src, _, err := image.Decode(file)
	if err != nil {
		return nil, err
	}
	img := imgToNRGBA(src)
	res, err := Resize(p, img)
	if err != nil {
		return nil, err
	}

Now this works fine going down in size but when going up in size, this happens:

panic: runtime error: index out of range

goroutine 1 [running]:
	/Users/southclaws/go/src/github.com/esimov/caire/carver.go:108 +0xb4b
github.com/esimov/caire.(*Processor).Resize.func1()
	/Users/southclaws/go/src/github.com/esimov/caire/process.go:65 +0x15d
github.com/esimov/caire.(*Processor).Resize(0xc420094090, 0xc420058840, 0x0, 0x0, 0x0, 0x0)
	/Users/southclaws/go/src/github.com/esimov/caire/process.go:115 +0x8c4
github.com/esimov/caire.Resize(0x11cd280, 0xc420094090, 0xc42008a140, 0x0, 0x0, 0x0, 0x0)
	/Users/southclaws/go/src/github.com/esimov/caire/process.go:35 +0x9c
main.resize(0x11cd480, 0xc420096070, 0x11cd4c0, 0xc420096078, 0x3fe999999999999a, 0x3fe0000000000000, 0x0, 0x0)
	/Users/southclaws/Desktop/untitled folder/main.go:65 +0xabc
main.main()
	/Users/southclaws/Desktop/untitled folder/main.go:27 +0x2ae

algorithm bug?

I am using below example to test caire. According to my understanding of the algorithm, the output doesn't match the expectation.

input

input

output

output

expected output

expected output

Logo for caire

Thinking about creating a logo for this repo. If anybody can came up with a nice idea can post it on this thread.

Extremely slow

I tried to rescale an image of the dimensions 2100 x 1300, scaling it down by 20 percent.
It took fifty minutes:

caire -in s.jpg -out out.jpg -perc=1 -width 20 -height 20
Processing... |
Rescaled in: 2952.92s
Saved as: out.jpg 

Working on a recent macbook, go version go1.7.1 darwin/amd64
Am I doing something wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.