I used BRISQUE in Matlab before and it worked fine so I decided to use it again in C#.
However, BRISQUE in OpenCvSharp (the same goes for Python and C++ as well) requires a SVM model data and range data saves - as seen in the documentation.
public static QualityBRISQUE Create(string modelFilePath, string rangeFilePath)
public static QualityBRISQUE Create(SVM model, Mat range)
According to MATLAB's documentation; < brisque compare A to a default model computed from images of natural scenes with similar distortions >. Do such save files exist in openCV or must I make them manually?
I found them, on the opencv_contrib GitHub page.
You can find both YML files (the model and the range files) here.
Related
I have a background in C++ and recently I started working in C#.
I have written following pieces of code (in Visual Studio):
var list_Loads = database.GetData<Load>().ToList();
var test_list = list_Loads.Where(o => (o.Name.Substring(0, 3) == "123")).ToList();
When I run the program and I move my mouse over both lists, first I get the count, which is very useful, but when I ask for the entries, this is what I get:
0 : namespace.Load
1 : namespace.Load
2 : namespace.Load
...
Not very useful, as you can imagine :-)
So my question: how can I show the Name attributes of those objects?
I thought: no problem. I have a background in native visualisers, so it should be rather easy to turn this into useful information, but then it comes:
In order to alter the way that those objects are represented, there is the first proposal to add a [DebuggerDisplay] "tag" to the definition of that class in source code.
However, as those classes are part of a framework I'm just referring to, I don't have access to the source code and hence I can't modify this.
Then I found another solution, which comes down to: "Write an entire C# project, debug, test and install it and it might work" (see documentation on "Custom visualisers of data" on the Microsoft website).
I almost choked in my coffee: writing an entire project, just for altering the view of an object??? (While, in C++, you just create a simple .natvis file, mention the classname and some configuration, launch .nvload and that's it.
Does anybody know a simple way to alter the appearance of C# object, without needing to pass through the whole burden of creating an entire C# project?
By the way, when I try to load a natvis file in Visual Studio immediate window, this is what I get:
.nvload "C:\Temp_Folder\test.natvis"
error CS1525: Invalid expression term '.'
What am I doing wrong?
Thanks in advance
OP (my emphasis):
In order to alter the way that those objects are represented, there is the first proposal to add a [DebuggerDisplay] "tag" to the definition of that class in source code.
However, as those classes are part of a framework I'm just referring to, I don't have access to the source code and hence I can't modify this.
Does anybody know a simple way to alter the appearance of C# object, without needing to pass through the whole burden of creating an entire C# project?
If you just want to specify [DebuggerDisplay] on a type, you don't have to have access to the source code. You can make use of [assembly:DebuggerDisplay()] and control how a type appears in the debugger. The only downside is that [assembly:DebuggerDisplay()] naturally only affects the current assembly whose code your mouse is hovering over. If you wish to use the customised display in other assemblies that you own, then you must repeat the [assembly:DebuggerDisplay()] definition.
Here's an easy before-and-after example with DateTime. I picked DateTime because we generally don't have access to the source code and it has some interesting properties:
var items = new List<DateTime>
{
DateTime.Now.AddDays(-2),
DateTime.Now.AddDays(-1),
DateTime.Now
};
...which on my machine defaults to:
Maybe I'm fussy and I just want to see:
Day of the week and
Day of the year
...I can do that via:
using System.Diagnostics;
[assembly: DebuggerDisplay("{DayOfWeek} {DayOfYear}", Target = typeof(DateTime))]
...which results in:
Example:
namespace DebuggerDisplayTests
{
public class DebuggerDisplayTests
{
public DebuggerDisplayTests()
{
var items = new List<DateTime>
{
DateTime.Now.AddDays(-2),
DateTime.Now.AddDays(-1),
DateTime.Now
};
}
}
.
.
.
}
Overrides
[assembly:DebuggerDisplay()] can also be used as a means to override pre-existing [DebuggerDisplay] on a 3-rd party type. Don't like what style they have chosen? Is the type showing far too much information? Change it with [assembly:DebuggerDisplay()].
Coming from this question, I've managed to get all CompletionItem instances available for a specific offset using completionService.GetCompletionsAsync(document, offset);.
So, after querying for completions of "MyString".Len, I get a CompletionItem for the Length method and can then, using the CompletionService, call service.GetDescriptionAsync(document, completionItem) to retrieve "int string.Length { get; }".
But, how can I get the comments for Length, e.g. "Gets the number of characters in the current String object."? And, if easily possible, other information regarding potential overloads?
Assuming that you're adding references to the assemblies using
MetadataReference.CreateFromFile method, you should pass an DocumentationProvider instance as an additional parameter, like this:
MetadataReference.CreateFromFile(path, MetadataReferenceProperties.Assembly, new MyDocumentationProvider(path));
DocumentationProvider is an abstract class, we ended up implementing our own by overriding GetDocumentationForSymbol method and locating appropriate XML node inside XML document.
Looking at Roslyn source code, there is XmlDocumentationProvider class which has an abstract method GetSourceStream (where you're supposed to pass a content of .xml file that stores documentation for .NET assemblies).
Please note that for this feature to work there should be an .xml file with descriptions file next to the assembly (which is normally produced from the source code when you have compile an assembly with Documentation File option set).
For .NET assemblies these files are included as part of SDK, and normally can be found at:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\vxxx
We use this approach in our Roslyn-based parsers in our AlterNET Studio product. You may find a bit more information about these parsers here.
GetDescriptionAsync can only return a number of overloads, to get list of overloads available at the same position you might need to use Recommender API like this:
var model = document.GetSemanticModelAsync().Result
var symbols = Microsoft.CodeAnalysis.Recommendations.Recommender.GetRecommendedSymbolsAtPositionAsync(model, pos, workspace).Result;
This API will return a separate symbol for every overload.
We asked a while ago whether it's possible to retrieve additional information (such as underlying symbol) from CompletionItem and the short answer is no. You may refer to the discussion here:
https://github.com/dotnet/roslyn/issues/57677
I'm currently writing an In-App purchase plugin for Unity in Objective-C using pure C as the API between unity and the objective-c code.
Introduction to the problem I am facing
The basic functionality already works. That is, I already have a very basic function call in my plugin to start a product request to the Apple App Store which can be called from Unity. In the unity script you simply call this method like this:
[DllImport ("__Internal")]
private static extern void RequestProducts(string[] productIdentifiers, int arrayCount);
public static void RequestProductData( string[] productIdentifiers )
{
RequestProducts(productIdentifiers, productIdentifiers.Length);
}
This calls the C function which looks like this:
void RequestProducts(char* productIdentifiers[], int arrayCount)
{
// Call the In-App purchase manager to initialize the product request
[[InAppPurchaseManager sharedInAppPurchaseManager] RequestProductData:productIdentifierCollection];
}
Now I've omitted the part of the C function which takes the productIdentifiers array and converts it into an NSArray just to keep it simple and explain the problem I'm trying to solve.
Now the InAppPurchaseManager class is a singleton class. The RequestProductData method initiates the product request to the app store.
The Problem
When the StoreKit gives me a response back with all the products, this is where it starts to get tricky for me. I want to pass all the relevant data for each product retrieved back to the unity C# script so you can handle the data in your game. This means storing:
-The name of each product
-The description of each product
-The price of each product
An obvious solution would be to make a struct or class which contains this information and then make an instance for each product and put them all into an array.
The Question
Now the question is, how would I go about sending this array of complex data structures back to the Unity script? Unity's official documentation mentions that you can send messages back to Unity using this method call:
UnitySendMessage("GameObjectName1", "MethodName1", "Message to send");
I got the call to work, but the obvious problem is that it only allows you to send strings.
So:
how would I go about sending arrays of complex data structures back to the Unity script? Is this even possible?
Follow up on my comment and your comment: if you want a robust solution, I would recommend that you check out this answer. If this is something performance critical, then you will have to get a lot more "manual" with your serialization. So how performance critical is this transfer of data?
Here is my problem. I have a series of photos of different parts of a building and I need to link them together. After that I need to show each photo in sequence to display a path from point A to point B… I.e., from a classroom to a fire escape.
I have done a bit of research and I believe a non-directed unweighted graph should do the trick.
As I have not much experience in this area. I was wondering how I need to store the photos in a data structure and if there are any libraries out there to do the job?
Yes, you need to apply some algorith, that can solve the problem for you.
You can use this great libray:
QuickGraph
to solve this part of the problem.
As to the way of storing your data, you need to define vertices (the photos) and edges between vertices like (photo A-photoB), (photo A-photo C), and so on.
You have to recover that info from the database and load the corresponding structure in quickgraph and let it find the path for you.
Here you have extensive docs and samples:
Quick graph documentation
For something similar to this I used:
MyEdges class, which implements IEdge<T> (T should be you photo ID type, int or whatever is) - represents the edge between to photos (places)
Graph class, which inherits AdjacencyGraph<T,MyRelation>. You load it with the available MyEdges (this is directed graph)
PathFinder algorithm class: I inherited from FloydWarshallAllShortestPathAlgorithm<T, MyRelation>
Then you have to:
Create the edges (i.e. read them from the DB)
Instance a Graph class, and add all edges to it
Use the PathFinder constructor, using the graph as parameter. This finds the paths.
This algorithm lets you specify to which photos you can go from a given photo (edges), supposes that the distance is similar between them, but you have to define all the routes (from A to B, from B to A and so on). That's the "un-weighted" part of the OP. If your case differs you'll have to read the docs.
You can implement an UnDirected graph if you prefer that adding A To B also adds B to A. It can spare some lines of code, but I usually prefer adding all the possibilities myself. Its easier to think "from the Library I can go to aisle A and aisle B. From aisle B to Library and Laboratory", and so on, that trying to think of all edges.
You can create two tables in a database:
Photos (with IDs)
Path (IdFrom and IdTo)
This is easy to maintain and implement.
I've got some material parameters stored in the FBX file (DiffuseFactor, ShininessExponent, SpecularFactor and others), but I can't get to them using Effect.Parameters nor BasicEffect (they've got only the basic stuff - like EmmisiveColor or alpha). I know, that I can try to write a Effect-derived class, but is there any other way? A built-in feature or maybe some half-raw parameters stored somewhere?
If you create a custom model processor (for the content pipeline) and override the ConvertMaterial method you can access this type of data in the input MaterialContent.OpaqueData collection.
I know if you output an EffectMaterialContent from this method like they do in the Skinned Model sample, you can attach this data to the EffectMaterialContent's OpaqueData collection and it will be visible in the shader using the names you supply. This was as of XNA 3.1 anyway, I'm not sure if there's a better/alternate way to do this now.
EDIT: Wow, didn't realize this question was almost a year old.