gecko0307 / dlib Goto Github PK
View Code? Open in Web Editor NEWAllocators, I/O streams, math, geometry, image and audio processing for D
Home Page: https://gecko0307.github.io/dlib
License: Boost Software License 1.0
Allocators, I/O streams, math, geometry, image and audio processing for D
Home Page: https://gecko0307.github.io/dlib
License: Boost Software License 1.0
Don't know whether it appeared there on memory-related refactoring or was from the very beginning.
Changing line 42 in /dlib/image/package.d to import dlib.core.image;
fixes compilation for now.
The compiler error is as below:
/dlib-master/dlib/image/package.d(42): Error: module dlib.core.image from file ../../../.dub/packages/dlib-master/dlib/image/unmanaged.d must be imported with 'import dlib.core.image;'
Upon building an application using Dlib for unit test (e.g. dub --build=unittest
), the compilation fails with following errors:
..\..\..\dlib\dlib\core\bst.d(110): Error: Cannot modify 'this'
..\..\..\dlib\dlib\core\bst.d(115): Error: Cannot modify 'this'
..\..\..\dlib\dlib\core\aarray.d(72): Error: template instance dlib.core.aarray.AArray!string error instantiating
..\..\..\dlib\dlib\functional\combinators.d(76): Error: no property 'filter' for type 'int[]'
..\..\..\dlib\dlib\functional\combinators.d(78): Error: no property 'filter' for type 'int[]'
Error executing command run: DMD compile run failed with exit code 1
Am I missing something or are these actual errors in the code?
DMD64 D Compiler v2.068.0
dlib - 0.6.2
Linux
/dlib/filesystem/stdfs.d(73): Error: function core.stdc.stdio.fseek (shared(_IO_FILE)* stream, long offset, int whence) is not callable using argument types (shared(_IO_FILE)*, fpos_t, int)
/dlib/math/vector.d(525): Warning: int *= float is performing truncating conversion
/dlib/math/vector.d(525): Warning: uint *= float is performing truncating conversion
/dlib/math/vector.d(525): Warning: int *= float is performing truncating conversion
/dlib/math/vector.d(525): Warning: uint *= float is performing truncating conversion
/dlib/math/vector.d(525): Warning: int *= float is performing truncating conversion
/dlib/math/vector.d(525): Warning: uint *= float is performing truncating conversion
/dlib/math/vector.d(525): Warning: ushort *= float is performing truncating conversion
It should be done only in getPixel
, and not in setPixel
.
dlib-master$ dub build
Checking dependencies in '/home/dlib-0.3.0'
Package dlib (configuration "library") defines no import paths, use {"importPaths": [...]} or the default package directory structure to fix this.
Building configuration "library", build type debug
Running dmd...
dlib/xml/lexer.d(187): Error: function dlib.xml.lexer.Lexer.getForward (ulong position, int num) is not callable using argument types (ulong, ulong)
dlib/geometry/obb.d(53): Error: no property 'translation' for type 'Matrix!(float, 4)'
dlib/geometry/obb.d(59): Error: no property 'translation' for type 'Matrix!(float, 4)'
dlib/geometry/intersection.d(128): Error: incompatible types for ((dot) * (dir)): 'float' and 'Vector!(float, 3)'
dlib/geometry/intersection.d(212): Error: no property 'translation' for type 'Matrix!(float, 4)'
dlib/geometry/intersection.d(242): Deprecation: function dlib.math.matrix.Matrix!(float, 4).Matrix.transform is deprecated - Matrix!(T,N).transform is deprecated, use vector to matrix multiplication instead
dlib/image/io/png.d(364): Error: function dlib.math.utils.networkByteOrder (uint value) is not callable using argument types (ulong)
dlib/image/io/png.d(442): Error: cannot implicitly convert expression (tmp.length) of type ulong to uint
dlib/image/io/zstream.d(46): Error: cannot implicitly convert expression (dest.length) of type ulong to uint
dlib/image/io/zstream.d(47): Error: cannot implicitly convert expression (dest.length) of type ulong to uint
dlib/image/io/zstream.d(61): Error: cannot implicitly convert expression (input.length) of type ulong to uint
dlib/image/io/zstream.d(94): Error: cannot implicitly convert expression (this.dest.length / 2LU) of type ulong to uint
dlib/math/fft.d(52): Error: cannot implicitly convert expression (data.length) of type ulong to uint
Error: DMD compile run failed with exit code 1
Image filters should optionally accept preallocated output storage.
AFAIK, Posix requires '/' and Winapi requires ''. Are there standard functions to do the conversion?
Such as identityMatrix
, Vector.transform
, etc.
If it is possible to detect if clamp is presented with something like __traits(compiles, ...), or by checking compiler version you can make public import of clamp from phobos, or present your own function.
Image loaders now use much of GC, which is no good. I'm going to use the following workaround (already implemented in PNG loader):
travis-ci unittest build for my project dlangide fails on dlib:
Building dlib 0.4.1 configuration "library", build type unittest.
Running dmd...
../../../.dub/packages/dlib-0.4.1/dlib/filesystem/local.d(341): Error: function dlib.filesystem.local.findFiles (string baseDir, bool recursive) is not callable using argument types (ReadOnlyFileSystem, string, bool)
../../../.dub/packages/dlib-0.4.1/dlib/filesystem/local.d(361): Error: undefined identifier 'functions'
../../../.dub/packages/dlib-0.4.1/dlib/filesystem/local.d(363): Error: undefined identifier 'functions'
../../../.dub/packages/dlib-0.4.1/dlib/math/vector.d(948): Warning: calling dlib.math.vector.Vector!(float, 3).Vector.length without side effects discards return value of type float, prepend a cast(void) if intentional
../../../.dub/packages/dlib-0.4.1/dlib/math/vector.d(949): Warning: calling dlib.math.vector.Vector!(float, 3).Vector.lengthsqr without side effects discards return value of type float, prepend a cast(void) if intentional
../../../.dub/packages/dlib-0.4.1/dlib/math/vector.d(950): Warning: calling dlib.math.vector.distance!float.distance without side effects discards return value of type float, prepend a cast(void) if intentional
FAIL ../../../.dub/packages/dlib-0.4.1/.dub/build/library-unittest-linux.posix-x86_64-dmd_2066-C3294255E83FD63DEF449B07C61958D9/ dlib staticLibrary
Error executing command test: dmd failed with exit code 1.
The following code will fail to compile:
import dlib.math.vector;
static this() {
const ivec3 v = ivec3(1, 2, 3);
const int x = v.x;
}
This probably applies to other Vector methods, too. I'd gladly provide a patch, but I'm not sure how to solve this without duplicating the whole method.
dlib/math/sse.d(184): Error: bad type/size of operands 'mov'
FAIL .dub/build/library-debug-posix.osx-x86_64-dmd_2066-5F283B0B6A1DC5388B277615AB841C18/ dlib staticLibrary
Error executing command run: dmd failed with exit code 1.
dlib-master\dlib\math\vector.d(533)
: Warning: calling dlib.math.utils.clamp!ushort.clamp without side effects disca
rds return value of type ushort, prepend a cast(void) if intentional
dlib-master\dlib\image\image.d(86):
Deprecation: Read-modify-write operations are not allowed for shared variables.
Use core.atomic.atomicOp!"+="(this.progress, this.pixelCost) instead
According to my tests, inversion via LU decomposition is 4 times faster than current analytic method.
Such as 4:4:4, 4:4:0, 4:2:2, 4:1:1, 4:1:0.
Still can't find the reason.
Using inverseAffine
doesn't always guarantee identity as a result of M * M^-1. Need rewriting.
Here is what I consider suitable. Since what, in principle, OpenFile
does is abstracts a filesystem interface, we can do something like this:
interface Filesystem
{
IOStream open(string fileName, FileMode mode);
// Probably also remove, rename, mkdir etc.
}
class StdFilesystem: Filesystem
{
IOStream open(string fileName, FileMode mode)
{
return new FileStream(new std.stream.File(fileName, mode));
}
// ...
}
StdFilesystem stdfs;
static this()
{
stdfs = new StdFilesystem();
}
IOStream openFile(string fileName, FileMode mode = FileMode.In)
{
return stdfs.open(fileName, mode);
}
The main question is, what methods do we need in an interface like that?
All container implementations from dlib.core (aarray, bst, hash, linkedlist, queue, stack) should be moved to new package dlib.container.
Implement frustum: just Plane[6] planes;
.
Implement frustum construction. From projection/perspective matrix for example.
Implement frustum AABB intersection test.
Plane extraction
Frustum - AABB Intersection implementation
They should use SuperImage.free
to ensure that underlying SuperImage implementation correctly releases its memory.
(following the previous conversation...)
I also believe we should pay extra attention to leave our back door open for a possible SIMD implementation in the future. The way I imagine it, as SIMD isn't practical everywhere, would be through another template parameter. An example probably illustrates it better:
vec4 doWhatever(const ref vec4 data, const ref mat4 matrix) {
// convert to SIMD types
vec4sse data_simd = data; // alias for Vector!(4, float, Vector.SSE)
mat4sse matrix_simd = matrix; // Matrix!(4, float, Vector.SSE)
// now do some really complex and expensive operation
...
// convert back to plain ol' floats and return
return data_simd;
}
dub --build=docs
generates DDoc documentation.
Most modules are not documented right now, but for those few that are it would be nice to be able to publish the documentation online. Can we do this with just github? Just pushing these to the repo will display them as HTML source code.
lve@vlopatin-laptop:~/src/d/dlib$ dub build --build=unittest
Building dlib 0.4.1+commit.34.gebd7d7c configuration "library", build type unittest.
Running dmd...
dlib/core/oop.d(174): Warning: use '{ }' for an empty statement, not a ';'
dlib/core/oop.d(180): Warning: use '{ }' for an empty statement, not a ';'
dlib/core/oop.d(185): Warning: use '{ }' for an empty statement, not a ';'
dlib/container/array.d(70): Error: None of the overloads of 'append' are callable using argument types (int), candidates are:
dlib/container/array.d(89): dlib.container.array.DynamicArray!(HuffmanTableEntry, 32LU).DynamicArray.append(HuffmanTableEntry c)
dlib/container/array.d(118): dlib.container.array.DynamicArray!(HuffmanTableEntry, 32LU).DynamicArray.append(const(HuffmanTableEntry)[] s)
dlib/container/array.d(85): Error: cannot implicitly convert expression (0) of type int to HuffmanTableEntry
dlib/image/io/jpeg.d(153): Error: template instance dlib.container.array.DynamicArray!(HuffmanTableEntry, 32LU) error instantiating
FAIL .dub/build/library-unittest-linux.posix-x86_64-dmd_2066-2961EB2D0079E9BB12186E96CBA5D5F0/ dlib staticLibrary
Error executing command build: dmd failed with exit code 1.
I guess the problem is in the filtering code.
...to gain better compatibility with OpenGL and address multiplication-related issues mentioned in #14.
Would be nice to have an easy way to convert one type to another through constructor.
like ivec3 discretePos = ivec3(vec3var);
or maybe with to!ivec3(vec3Var);
Currently I use
ivec3 toivec3(vec3 vec)
{
return ivec3(cast(int)vec.x, cast(int)vec.y, cast(int)vec.z);
}
We don't seem to have one, or is my eyesight getting bad?
Latest version of dlib don't have 'v' prefix like v0.3.0, so i can't fetch dlib using dub.
Stream-based image I/O would bring compatibility with virtual filesystems and networking.
Currently PNG exportrer writes a single large IDAT chunk with image data. In some cases (when encoding non-compressible images such as pixel art), this gives invalid results at zlib compression stage. RFC 1951 (DEFLATE algorithm spec) states that the block sizes are arbitrary, except that non-compressible blocks are limited to 65,535 bytes
. So the exporter should break the data into 64K chunks.
I added dlib as a dependency to my dub-based project, but when trying to build it, I'm getting these errors:
Package dlib (configuration "library") defines no import paths, use {"importPaths": [...]} or the default package directory structure to fix this.
...
../../../.dub/packages/dlib-0.2.4/dlib/image/package.d(45): Error: module morphology is in file 'dlib/image/filters/morphology.d' which cannot be read
I tried to manually modify dlib's package.json, adding '.' as an importPath, but that gives me errors like:
dlib/image/package.d(45): Error: module dlib.image.morphology from file ... must be imported as module 'dlib.image.morphology'
assert( nextPowerOfTwo!uint(2500) == 4096 ); // returns 4092
dlib.xml
package should be rewritten with manual memory management.
It will be useful to have such syntax:
chunkWorldPos.x %= REGION_SIZE;
chunkWorldPos.y %= REGION_SIZE;
chunkWorldPos.z %= REGION_SIZE;
as
chunkWorldPos %= REGION_SIZE;
These are , openForIO
, openDir
, createDir
.remove
#16 is fixed, but most of the functions in dlib.math.affine are still missing. I rewrote only widely-used ones to make the module pass the unittest. Missing functions are marked as TODO
.
To make porting process easier, old implementations are still there (matrix_old.d, affine_old.d).
Using Ubuntu x64:
Building dlib ~master configuration "library", build type debug.
Running dmd...
../../../.dub/packages/dlib-master/dlib/image/io/zlib.d(81): Error: function dlib.image.io.zlib.ZlibEncoder.reallocateBuffer (uint len) is not callable using argument types (ulong)
../../../.dub/packages/dlib-master/dlib/image/io/zlib.d(91): Error: function dlib.image.io.zlib.ZlibEncoder.reallocateBuffer (uint len) is not callable using argument types (ulong)
../../../.dub/packages/dlib-master/dlib/image/io/zlib.d(157): Error: function dlib.image.io.zlib.ZlibDecoder.reallocateBuffer (uint len) is not callable using argument types (ulong)
../../../.dub/packages/dlib-master/dlib/image/io/zlib.d(167): Error: function dlib.image.io.zlib.ZlibDecoder.reallocateBuffer (uint len) is not callable using argument types (ulong)
FAIL ../../../.dub/packages/dlib-master/.dub/build/library-debug-linux.posix-x86_64-dmd_2067-3DFF75C58537CAA01A8A2A997801CE14/ dlib staticLibrary
Error executing command run: dmd failed with exit code 1.
In commit 915597e, import std.functional;
was changed to import std.algorithm : iota, reduce;
.
However, std.algorithm does not contain an iota
function in DMD v2.067.1.
DMD compiler output:
dlib\math\combinatorics.d(11): Error: module std.algorithm import 'iota' not found
Building dlib 0.5.2 configuration "library", build type unittest.
Running dmd...
../../../.dub/packages/dlib-0.5.2/dlib/filesystem/local.d(342): Error: no property 'filter' for type 'std.range.interfaces.InputRange!(DirEntry)'
FAIL ../../../.dub/packages/dlib-0.5.2/.dub/build/library-unittest-linux.posix-x86_64-dmd_2067-EA65A65E20E3EAC0F371C7F7489485A2/ dlib staticLibrary
Error executing command test:
dmd failed with exit code 1.
A lot of warnings like
dlib-0.5.3\dlib\math\vector.d(525,35): Warning: int *= float is performing truncating conversion
dlib-0.5.3\dlib\math\vector.d(525,35): Warning: uint *= float is performing truncating conversion
Could you please fix?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.