I am working on a image processing project. I need to extract a region of interest from one varible (cv_image <bgr_pixel>) to another variable (cv_image <bgr_pixel>) with a dlib::rectangle varible
In OpenCV, its like:
Mat mainImage=cv::imread(location,0);
Mat roi = mainImage(cv::Rect(0,0,100,100))
Is there any similar methods in Dlib??
You can use dlib::extract_image_chips(). It allows you to specify where the chip comes from in a variety of ways, but you can also simply do extract_image_chips(in_img, some_rectangle, out_img). However, out_img can't be a cv_image. It has to be something like dlib::array2d or dlib::matrix. More generally, if you really just want to copy between OpenCV objects then you don't need dlib.
Related
When using the Windows-Machine-Learning library, the input and output to the onnx models is often either TensorFloat or ImageFeatureValue format.
My question: What is the difference between these? It seems like I am able to change the form of the input in the automatically created model.cs file after onnx import (for body pose detection) from TensorFloat to ImageFeatureValue and the code still runs. This makes it e.g. easier to work with videoframes, since I can then create my input via ImageFeatureValue.CreateFromVideoFrame(frame).
Is there a reason why this might lead to problems and what are the differences between these when using videoframes as input, I don't see it from the documentation? Or why does the model.cs script create a TensorFloat instead of an ImageFeatureValue in the first place anyway if the input is a videoframe?
Found the answer here.
If Windows ML does not support your model's color format or pixel range, then you can implement conversions and tensorization. You'll create an NCHW four-dimensional tensor for 32-bit floats for your input value. See the Custom Tensorization Sample for an example of how to do this.
I trained my model in Nvidia Digits 5 and I would now like to extract the accuracy and loss plots that were generated during training for a report. Is this data saved somewhere so that it would possible to extract the data for these plots so that I could plot it in Python and perhaps ultimately modify the plots to compare different models etc?
The best solution I have found is to either look at the HTML file or to scan the text file caffe_output.log that is produced by Caffe. The text file is usually stored in /var/digits/jobs/insert_your_job_id/ but you can also just run on linux systems:
locate caffe_output.log
Go to your DIGITS job folder and locate your job's subfolder. Inside you'll find a file status.pickle, which is a pickled object containing all your job's information.
You can load it in python like so:
import digits
import pickle
data = pickle.load(open('status.pickle','rb'))
This object is somewhat generic and may contain multiple tasks. For a typical classification task it will likely be just one, but you will still need to access it via data.tasks[0]. From there you can grab the plots:
data.tasks[0].combined_graph_data()
which returns a somewhat convoluted dict (unfortunately - since your network can produce many accuracy/loss outputs, as well as even custom ones). It contains everything you need though - I managed to plot accuracy with:
plt.plot( data.tasks[0].combined_graph_data()['columns'][2][1:] )
but it's likely that you'll have to write a bit of custom code. As always, dir() is your friend.
I'm trying to use the img.alpha(SOMETHING) command in the ruby magick library (in a custom manipulate routine used by carrierwave).
alpha() expects an argument of Magick::AlphaChannelType but I cannot find any doucmentaiton on how to specify such an argument, or what options are available.
The docs say the argument shoudl be:
One of the following values of the AlphaChannelType enumeration:
ActivateAlphaChannel Enable the images use of transparency. If
transparency data did not exist, allocate the data and set to opaque.
If the image previously had transparency data, the data is again
enable as it was when turned off. The transparency data is not changed
or modified in any way.
...
But do not give any examples of how to actually specify one of the 10 possible argument values.
The AlphaChannelTypes that alpha wants are constants within Magick so you want to use Magick::ActivateAlphaChannel, Magick::BackgroundAlphaChannel, ...:
img.alpha(Magick::ActivateAlphaChannel)
I don't my way around CarrierWave but I'd guess it just wants to see one of the Magick:: constants somewhere.
I had spent so many hours failing to find a line graph generator for my benchmark results that I just wanted to plug in. I tried quite a few like Google's chart API but it still seemed confusing or not graceful looking, I am clueless.
Examples of benchmark images I wished to make something like are this:
What specific applications /web services do you recommend for generating something even close to this? I want something "neat".
You can use python mathplotlib, which generates beautiful graphs like:
(Source code)
I use gnuplot. It is not a lib, but a separate executable file. You can output plotting data to one file, and plotting commands in another - script file, which refer to data file. Then call gnuplot with this script file.
Another way is to use qwt. It is a real library, but it depends on Qt. If you already use Qt in your project, it is very straigth way to plot graphs. If not, then just use gnuplot
I am porting an iphone game to windows phone 7. iphone works fairly similarly to Winmo7 in that you add all the files you want to be able to read to the project. we didn't want this extra step in our asset creation pipeline, so we just made it so all files were put into our own basic file archive, then just added that one archive file to the project. we then have an asset build process that exports all our assets, then creates this archive from them.
in winmo7 it caught me by surprise that you couldn't just do the same thing. as far as I know, the only way you can load data is though the content pipeline. we solved this fairly easily though by simply making a contentImporter that would just convert all the files to byte[] and export them as byte arrays, then you can simply load them an just directly access all the bytes that are in the file. unfortunately, unlike c++ where you would just cast memory to structures (because the file would already be stored in the structure's format) c# seems to require a more manual approach, where you use things such as BitConverter to load all the data into structures and classes from the byte array.
the thing is, we want to use our already existing asset export processes for things like textures and meshes, were we already have stuff setup for figuring out the exact pixel format that should be used for each texture ect. so in those cases we don't want to use the default Texture and Mesh content Importers. we tried making our on Texture ContentImporter, by simply making it return a Texture2D, but in order to create a Texture2D, you need a graphics device.
the second problem was the process of having to add every asset to the project. we decided that we didn't want to just load our dataArchive like we do for the iphone, because we DO want to use the default ContentImporters for Some of the data (like sound). but we solved this problem by making it so you just add one text file, with the root data dir in it, to the project, then made a ContentImporter that iterates through that directory structure and calls 'context.BuildAsset' on all the files there.
so summing up, we have one asset and ContentImporter that automatically handles the importing of all the assets in the data directory, thus solving the problem of having to add them manually to the project. some of these assets will be directed through the default ContentImporters (like sound and music, and xmls) while others will just be imported as byte[] and loaded manually, because we already have the asset in the format we want. in the case of those assets, it would be good if we could do the 'byte[] -> loaded manually' inside custom ContentImporters - offline- but for the first one we tried - Textures - it required a Graphics device to create the native Textue2D structure, and we couldn't find one in the ContentImporter framework.
so any thoughts? pointers? or is this the bestest way to do everything? I suppose another option would be to just convert all assets to a format the default Texture and Mesh processors can take in, and parameters to go with each of them (so we have a hand crafted 565 texture, convert it back to an 888 tga, then send it through the default texture pipeline with a parameter saying "convert this to 565")
TitleContainer
its this new class they added in 4.0, and is a little less explicit than the File stuff
just go TitleContainer.OpenStream(path)
It's straight forward to open a text file and read the contents in a WP7 project. Here is one way.
Uri linesUri = new Uri("lines.txt", UriKind.Relative);
StreamResourceInfo stream = App.GetResourceStream(linesUri);
StreamReader streamReader = new StreamReader(stream.Stream);
var contents = streamReader.ReadToEnd();
streamReader.Close();
I initially dragged the lines.txt file into my project from explorer - no other handling was necessary for this code to work.
Include the references you need...
using System.IO;
using System.Windows.Resources;
Rephrase the question and I would be more than happy to help you. Specifically, give examples of the issues you are trying to solve. I have done a lot work with the content pipeline in XNA and could share with you some tips.
I will update my answer once you give more details.