Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
"commands": [
"dotnet-fsharplint"
]
},
"fsdocs-tool": {
"version": "19.1.1",
"commands": [
"fsdocs"
]
}
}
}
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Self-hosted_build
if: runner.os != 'Windows'
run: |
chmod +x ./build.sh
./build.sh
env:
CI: true
- name: Self-hosted_build
if: runner.os == 'Windows'
run: ./build.cmd
env:
CI: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,9 @@ coverage.*.xml
.paket/.store
.paket/paket

# FSharp.Formatting
.fsdocs/
output/
temp/

out/
15 changes: 9 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.1.0] - 2017-03-17
First release
## [1.0.0] - 2023-12-19

### Added
- This release already has lots of features
- Processing images by applying filters
- Rotating, reflecting images
- Parallel image processing using agents
- Processing using the CPU or any GPU on your device

[0.1.0]: https://github.com/user/MyCoolNewApp.git/releases/tag/v0.1.0
[Unreleased]: https://github.com/LeonidLodygin/ImageProcessing/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/LeonidLodygin/ImageProcessing/releases/tag/v1.0.0
[0.1.0]: https://github.com/LeonidLodygin/ImageProcessing/releases/tag/v1.0.0
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<PropertyGroup>
<!-- summary is not migrated from project.json, but you can use the <Description> property for that if needed. -->
<PackageTags>f#, fsharp</PackageTags>
<PackageProjectUrl>https://github.com/gsvgit/ImageProcessing</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/gsvgit/ImageProcessing/blob/master/LICENSE.md</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/LeonidLodygin/ImageProcessing</PackageProjectUrl>
<PackageLicense>https://github.com/LeonidLodygin/ImageProcessing/blob/main/LICENSE.md</PackageLicense>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<RepositoryType>git</RepositoryType>
<Authors>gsvgit</Authors>
<RepositoryUrl>https://github.com/gsvgit/ImageProcessing</RepositoryUrl>
<Authors>LeonidLodygin</Authors>
<RepositoryUrl>https://github.com/LeonidLodygin/ImageProcessing</RepositoryUrl>
<!-- owners is not supported in MSBuild -->
</PropertyGroup>
</Project>
61 changes: 26 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,36 @@
# ImageProcessing

Simple image processing on GPGPU in F# using [Brahma.FSharp](https://github.com/YaccConstructor/Brahma.FSharp).

---

## Builds


GitHub Actions |
:---: |
[![GitHub Actions](https://github.com/gsvgit/ImageProcessing/workflows/Build%20master/badge.svg)](https://github.com/gsvgit/ImageProcessing/actions?query=branch%3Amaster) |
[![Build History](https://buildstats.info/github/chart/gsvgit/ImageProcessing)](https://github.com/gsvgit/ImageProcessing/actions?query=branch%3Amaster) |

## NuGet

Package | Stable | Prerelease
--- | --- | ---
ImageProcessing | |
# LeonidLodygin.ImageProcessing


---

### Developing

Make sure the following **requirements** are installed on your system:

- [dotnet SDK](https://dotnet.microsoft.com/en-us/download/dotnet/7.0) 7.0 or higher
- OpenCL-compatible device with respective driver installed.

---
Simple image processing on GPGPU in F# using [Brahma.FSharp](https://github.com/YaccConstructor/Brahma.FSharp).

### Building
## Features
* Apply built-in or custom filters to an image
* Rotating, reflecting the image
* Applying fish-eye to an image
* Image processing using CPU or specific GPU
* Ability to process images in multiple threads using agents (mailbox processor based).
* Process one image or a whole set of images at a time

## Installation
```sh
> dotnet add package LeonidLodygin.ImageProcessing --version 1.0.0
```

## Quick start
```sh
> build.cmd <optional buildtarget> // on windows
$ ./build.sh <optional buildtarget>// on unix
> dotnet run -i *input path* -o *output path* -mod FishEye -gpu AnyGpu
```
## Result
| Original | Fisheye |
|:------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------|
| ![image](https://raw.githubusercontent.com/LeonidLodygin/ImageProcessing/gh-pages/images/example.jpg) | ![image](https://raw.githubusercontent.com/LeonidLodygin/ImageProcessing/gh-pages/images/processed.jpg) |

## Contributors

---
- Leonid Lodygin (Github: [@LeonidLodygin](https://github.com/LeonidLodygin))
- Semyon Grigorev (Github: [@gsvgit](https://github.com/gsvgit))

### Build Targets
## License

For details look at [MiniScaffold](https://github.com/TheAngryByrd/MiniScaffold), we use it in our project.
This project licensed under MIT License. License text can be found in the
[license file](https://github.com/LeonidLodygin/ImageProcessing/blob/main/LICENSE.md).
244 changes: 244 additions & 0 deletions build/FsDocs.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
namespace Fake.DotNet

open Fake.Core
open Fake.IO
open Fake.IO.FileSystemOperators

/// <summary>
/// Contains tasks to interact with <a href="https://fsprojects.github.io/FSharp.Formatting/">fsdocs</a> tool to
/// process F# script files, markdown and for generating API documentation.
/// </summary>
[<RequireQualifiedAccess>]
module Fsdocs =

/// <summary>
/// Fsdocs build command parameters and options
/// </summary>
type BuildCommandParams =
{
/// Input directory of content (default: docs)
Input: string option

/// Project files to build API docs for outputs, defaults to all packable projects
Projects: seq<string> option

/// Output Directory (default <c>output</c> for <c>build</c> and <c>tmp/watch</c> for <c>watch</c>)
Output: string option

/// Disable generation of API docs
NoApiDocs: bool option

/// Evaluate F# fragments in scripts
Eval: bool option

/// Save images referenced in docs
SaveImages: bool option

/// Add line numbers
LineNumbers: bool option

/// Additional substitution parameters for templates
Parameters: seq<string * string> option

/// Disable project cracking.
IgnoreProjects: bool option

/// In API doc generation qualify the output by the collection name, e.g. 'reference/FSharp.Core/...' instead of 'reference/...' .
Qualify: bool option

/// The tool will also generate documentation for non-public members
NoPublic: bool option

/// Do not copy default content styles, javascript or use default templates
NoDefaultContent: bool option

/// Clean the output directory
Clean: bool option

/// Display version information
Version: bool option

/// Provide properties to dotnet msbuild, e.g. <c>--properties Configuration=Release Version=3.4</c>
Properties: string option

/// Additional arguments passed down as otherflags to the F# compiler when the API is being generated.
/// Note that these arguments are trimmed, this is to overcome a limitation in the command line argument
/// processing. A typical use-case would be to pass an addition assembly reference.
/// Example <c>--fscoptions " -r:MyAssembly.dll"</c>
FscOptions: string option

/// Fail if docs are missing or can't be generated
Strict: bool option

/// Source folder at time of component build (<c>&lt;FsDocsSourceFolder&gt;</c>)
SourceFolder: string option

/// Source repository for github links (<c>&lt;FsDocsSourceRepository&gt;</c>)
SourceRepository: string option

/// Assume comments in F# code are markdown (<c>&lt;UsesMarkdownComments&gt;</c>)
MdComments: bool option
}

/// Parameter default values.
static member Default = {
Input = None
Projects = None
Output = None
NoApiDocs = None
Eval = None
SaveImages = None
LineNumbers = None
Parameters = None
IgnoreProjects = None
Qualify = None
NoPublic = None
NoDefaultContent = None
Clean = None
Version = None
Properties = None
FscOptions = None
Strict = None
SourceFolder = None
SourceRepository = None
MdComments = None
}

/// <summary>
/// Fsdocs watch command parameters and options
/// </summary>
type WatchCommandParams =
{
/// Do not serve content when watching.
NoServer: bool option

/// Do not launch a browser window.
NoLaunch: bool option

/// URL extension to launch <c>http://localhost:/%s</c>.
Open: string option

/// Port to serve content for <c>http://localhost</c> serving.
Port: int option

/// Build Commands
BuildCommandParams: BuildCommandParams option
}

/// Parameter default values.
static member Default = {
NoServer = None
NoLaunch = None
Open = None
Port = None
BuildCommandParams = None
}

let internal buildBuildCommandParams (buildParams: BuildCommandParams) =
let buildSubstitutionParameters (subParameters: seq<string * string>) =
let subParameters =
subParameters
|> Seq.map (fun (key, value) -> (sprintf "%s %s" key value))
|> String.concat " "

sprintf "--parameters %s" subParameters

System.Text.StringBuilder()
|> StringBuilder.appendIfSome buildParams.Input (sprintf "--input %s")
|> StringBuilder.appendIfSome
buildParams.Projects
(fun projects ->
sprintf
"--projects %s"
(projects
|> String.concat " ")
)
|> StringBuilder.appendIfSome buildParams.Output (sprintf "--output %s")
|> StringBuilder.appendIfSome buildParams.NoApiDocs (fun _ -> "--noapidocs")
|> StringBuilder.appendIfSome buildParams.Eval (fun _ -> "--eval")
|> StringBuilder.appendIfSome buildParams.SaveImages (fun _ -> "--saveimages")
|> StringBuilder.appendIfSome buildParams.LineNumbers (fun _ -> "--linenumbers")
|> StringBuilder.appendIfSome
buildParams.Parameters
(fun parameters -> buildSubstitutionParameters parameters)
|> StringBuilder.appendIfSome buildParams.IgnoreProjects (fun _ -> "--ignoreprojects")
|> StringBuilder.appendIfSome buildParams.Qualify (fun _ -> "--qualify")
|> StringBuilder.appendIfSome buildParams.NoPublic (fun _ -> "--nonpublic")
|> StringBuilder.appendIfSome buildParams.NoDefaultContent (fun _ -> "--nodefaultcontent")
|> StringBuilder.appendIfSome buildParams.Clean (fun _ -> "--clean")
|> StringBuilder.appendIfSome buildParams.Version (fun _ -> "--version")
|> StringBuilder.appendIfSome buildParams.Properties (sprintf "--properties %s")
|> StringBuilder.appendIfSome buildParams.FscOptions (sprintf "--fscoptions %s")
|> StringBuilder.appendIfSome buildParams.Strict (fun _ -> "--strict")
|> StringBuilder.appendIfSome buildParams.SourceFolder (sprintf "--sourcefolder %s")
|> StringBuilder.appendIfSome buildParams.SourceRepository (sprintf "--sourcerepo %s")
|> StringBuilder.appendIfSome buildParams.MdComments (fun _ -> "--mdcomments")
|> StringBuilder.toText
|> String.trim

let internal buildWatchCommandParams (watchParams: WatchCommandParams) =
System.Text.StringBuilder()
|> StringBuilder.appendIfSome watchParams.NoServer (fun _ -> "--noserver")
|> StringBuilder.appendIfSome watchParams.NoLaunch (fun _ -> "--nolaunch")
|> StringBuilder.appendIfSome watchParams.Open (sprintf "--open %s")
|> StringBuilder.appendIfSome watchParams.Port (sprintf "--port %i")
|> StringBuilder.appendIfSome watchParams.BuildCommandParams buildBuildCommandParams
|> StringBuilder.toText
|> String.trim


let cleanCache (workingDirectory) =
Shell.cleanDirs [
workingDirectory
</> ".fsdocs"
]

/// <summary>
/// Build documentation using <c>fsdocs build</c> command
/// </summary>
///
/// <param name="dotnetOptions">Function used to overwrite the dotnetOptions.</param>
/// <param name="setBuildParams">Function used to overwrite the build command default parameters.</param>
///
/// <example>
/// <code lang="fsharp">
/// Fsdocs.build (fun p -> { p with Clean = Some(true); Strict = Some(true) })
/// </code>
/// </example>
let build dotnetOptions setBuildParams =
let buildParams = setBuildParams BuildCommandParams.Default
let formattedParameters = buildBuildCommandParams buildParams

// let dotnetOptions = (fun (buildOptions: DotNet.Options) -> buildOptions)
let result = DotNet.exec dotnetOptions "fsdocs build" formattedParameters

if
0
<> result.ExitCode
then
failwithf "fsdocs build failed with exit code '%d'" result.ExitCode

/// <summary>
/// Watch documentation using <c>fsdocs watch</c> command
/// </summary>
///
/// <param name="dotnetOptions">Function used to overwrite the dotnetOptions.</param>
/// <param name="setWatchParams">Function used to overwrite the watch command default parameters.</param>
///
/// <example>
/// <code lang="fsharp">
/// Fsdocs.watch (fun p -> { p with Port = Some(3005) })
/// </code>
/// </example>
let watch dotnetOptions setWatchParams =
let watchParams = setWatchParams WatchCommandParams.Default
let formattedParameters = buildWatchCommandParams watchParams

// let dotnetOptions = (fun (buildOptions: DotNet.Options) -> buildOptions)
let result = DotNet.exec dotnetOptions "fsdocs watch" formattedParameters

if
0
<> result.ExitCode
then
failwithf "fsdocs watch failed with exit code '%d'" result.ExitCode
Loading