Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DlibDotNet.Extensionsの依存パッケージについて #263

Closed
TwilightWings opened this issue Sep 17, 2021 · 6 comments · Fixed by #264
Closed

DlibDotNet.Extensionsの依存パッケージについて #263

TwilightWings opened this issue Sep 17, 2021 · 6 comments · Fixed by #264
Assignees
Labels

Comments

@TwilightWings
Copy link

Windowsです。
DlibDotNet.Extensionsの依存パッケージがSystem.Drawing.Common.dllになっていますが、実際はSystem.Drawing.dllで動いているようです。

System.Drawing.Common.dllを入れたのですが、実際のアセンブリの要求がSystem.Drawing.dllになっており、そちらを入れなおして動きました。

Bitmap.ToMatrixなどの変換で使用しました。
ところが、DlibDotNetの方の要求するアセンブリはきちんとSystem.Drawing.Common.dllになっており、System.Drawing.Common.dllを要求するようになったバージョンのパッケージからこの二つのDlibDotNetとDlibDotNet.Extensionsのパッケージは競合状態にあるようです。

現在DlibDotNet(19.21.0.20210230)+DlibDotNet.Extensions(最新)+普通のSystem.Drawingで動くようです。
正直Windowsは普通のSystem.Drawing.dllで動けばいいと思います。

当方がUnityで動作させているため、想定の環境と異なっているだけが原因でしたら申し訳ありません。

@takuya-takeuchi
Copy link
Owner

@LightWings-GameProject
報告ありがとうございます。
正直に申し上げますと、Extensionは利用頻度が少ないため、検証が漏れていました。
*.csprojを確認したところ、System.Drawing「も」リンクされていたのが原因だと思われます。

こちらはSystem.Drawingを外しておきます。
また、Matrix.ToBitmapはSystem.Drawing.CommonをDlibDotNet自体がリンクしていますので、Extensionなしに使えるようになっていますので、そちらの使用を検討してください。

@takuya-takeuchi takuya-takeuchi linked a pull request Sep 18, 2021 that will close this issue
takuya-takeuchi added a commit that referenced this issue Sep 18, 2021
* Remove System.Drawing from DlibDotNet.Extensions
@TwilightWings
Copy link
Author

TwilightWings commented Sep 19, 2021

ご確認と修正ありがとうございます!

また、Matrix.ToBitmapはSystem.Drawing.CommonをDlibDotNet自体がリンクしていますので、Extensionなしに使えるようになっていますので、そちらの使用を検討してください。

これは「Bitmap.ToMatrix(Bitmap → Matrix)」も同様でしょうか?
当方のUnity環境もSystem.Drawing.Commonでリンクは可能なのですが、不便な点が一つありましてブラシによる矩形塗りつぶしがRectangle構造体が内包されていないのかエラーになってしまいます(Rectangleがアセンブルに含まれていないエラー、引数にRectangleをとる。)。

Matrix<RgbPixel>などに対して画像を任意の矩形、色で塗りつぶすような機能はございますでしょうか?

@takuya-takeuchi
Copy link
Owner

takuya-takeuchi commented Sep 19, 2021

https:/takuya-takeuchi/DlibDotNet/blob/master/src/DlibDotNet/Extensions/BitmapExtensions.cs に ToMatrix がありますので、そちらを使ってください。

不便な点が一つありましてブラシによる矩形塗りつぶしがRectangle構造体が内包されていないのかエラーになってしまいます

これはどう言う意味ですか?
System.Drawing.Rectangle が System.Drawing.Common.dll に存在しないということですか?
DlibDotNet.Rectangle と名前が同じで名前解決できないとかではないですか?

Matrixなどに対して画像を任意の矩形、色で塗りつぶすような機能はございますでしょうか?

public static void DrawRectangle(Matrix<RgbPixel> image, Rectangle rect, RgbPixel color, uint thickness = 1)

Dlib.DrawRectangle を使ってください。

@takuya-takeuchi
Copy link
Owner

@LightWings-GameProject

失礼、上の関数は塗りつぶしではないですね。
FillRect を使ってください

@TwilightWings
Copy link
Author

TwilightWings commented Sep 19, 2021

ご返信ありがとうございます!

DlibDotNet.Rectangle と名前が同じで名前解決できないとかではないですか?

当方もRectangleに対して勘違いがあるかもしれませんので、最新版の適用をしてもう一度確認します。
その際また問題がありましたら別のissueとして挙げさせていただきます。
ありがとうございました。こちらはクローズいたします。

@TwilightWings
Copy link
Author

TwilightWings commented Sep 30, 2021

既にクローズしていますが、件のRectangleの識別がうまくいかなかった原因が分かりました。
結論から言いますと私がUnityでDlibDotNetを使っているのが原因でした。

Rectangleが識別できなかった直接の原因はUnityのターゲットを.NET Standard 2.0にする必要があったにもかかわらず4.0に設定してしまっていたことでした。
https://forum.unity.com/threads/system-drawing-common-dll-is-not-allowed-or-missing.1059125/

ひとまずこれでビルドは通ったのですが、そもそもUnityはmonoで動かしていましたのでSystem.Drawing.Commonを動かすのは困難でした。
https://answers.unity.com/questions/1678854/systemdrawing-or-equivalentgetting-systemdrawing-t.html

なので結果的にSystem.Drawing.Commonに依存していないDLibDotNet+DLibDotNetExtensionのSystem.Drawingに依存した修正前の旧バージョンを使って動作させることにしました。

ゆくゆくはUnityでの実装を辞めて、通常のWindowsアプリとして実装しなおしたいと思います。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants