How do I get LLDB to output images? - c++

I have a single 8-bit channel buffer whose contents I would like to see in the middle of a debugging session. Using whatever might be available under Xcode/LLDB, can this be done? A solution that uses a separate window (or even dumping to an external file) is fine.
What changes about the answer if the image is 8-bit planar RGBA?

I think you are asking about:
https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/CustomClassDisplay_in_QuickLook/Introduction/Introduction.html
This was answered here in:
How can I Quick Look custom objects with Xcode 5 visual debugger?
You have to be able to convert your image to a UIImage or some other type that the QuickLook system natively understands.

Related

Is there a way to check the data in a matrix in opencv c++

I'm programming on Visual Studio c++ using OpenCV library for a project in Windows 7. I'm dealing with a lot of matrices of different types: uchar, float, double, Vec3d, Vec3b etc.
When I want to print out a value of an image, I stop the run, write the following line, cout << (int)mat.at<Veb3b>(i,j)[k];, and run from the beginning which is quite time consuming. In debug mode, I don't see the values of matrices, maybe the first index depending on the type. In Matlab, you can see the values, play with them on run time. (I'm fine with just seeing the values inside a matrix)
I'm wondering if there is a way to see the values on runtime using some external tool maybe. Many genius people have been working on OpenCV, some of them should have thought of it.
So, does anybody know about such a tool? I couldn't find anything related.
I'd recommend the Image Watch extension from Microsoft (link).
It has built-in support for OpenCV datatypes. Better for image data, though using it for regular matrices works well too. Can break at any point and view data in global or local variables and can even do some simple filtering on the data displayed. You can zoom in to view individual elements. Also supports exporting directly from the debugger.

How to debug image processing projects on eclipse?

Here at work we have plenty of experience developing image processing applications for the TI DSP platform using an old version of code composer (CC 3.3). We are transitioning to the ARM platform using Eclipse (flavored and distributed by Xilinx).
In the old code composer, a feature we used a lot was to look was an IDE widget that could display a certain area of memory as a bitmap image. It had a properties grid where you would define things like size, pixel format and stride orientation to properly interpret the blob of memory as a picture. The tool also had some nice features like zooming, a grayscale counter, line profile, histogram and etc.
Is there something similar for eclipse? If not, how difficult would it be to create one? I mean, how difficult it is to create a barebones plugin for eclipse that draws information from a location of memory in a jtag interface?
Gdb can call python script. If gdb is used for debugging then please use this. You can use OpenCV or PIL or any image library to show the image.
Updated on 2 Apr 2014:
Let 'data' be the pointer to the image.
Inside gdb run "python data = gdb.parse_and_eval("data")". This will give access to inferior's memory pointed by data.
e.g., "python print(data[35])" will show the 35th element of 'data'.
As the image data can be read in python, it can be displayed or analysed.
Following links will help in getting things done:
http://www.cinsk.org/wiki/Debugging_with_GDB:_How_to_create_GDB_Commands_in_Python
https://sourceware.org/gdb/onlinedocs/gdb/Python.html#Python
Note: Please ignore the comment I added. Hit enter key before writing the actual info.
Hope this helps.
Eclipse has no such feature; personally, I work in a similar environment (image processing on a DaVinci architecture + Eclipse IDE). Writing a Eclipse plugin is not a overly complicated task - there a loads of tutorials(like this one). But maintaining it may become one. We have referece Code in QT so we don't need such features. but if you really want something similar I guess you can always do a memdump in a binary file and interpret hat as an image. As long as the format isn't anything spacial (e.g. you are dumping jpeg format) it should be fine.
That is a great idea for static objects but what if your memory is created temporarily on the heap or on the stack? Is isn’t it easier in dynamic environments (using openCV) just to put a three lines of code whenever you need to see some buf content as an image and use Qt to do image scaling and histogramming?
Mat I(h, w, CV_8U, buf);
imshow(“winname”, buf);
waitKey(-1);
I heard that the latest version of openCV highgui module has the options you talked about but I personally see only very limited use of it in a dynamic programming environment. And yet I visualize data all the time. Moreover, I like to interact with my images, for example, rotate them in 3D, click and get values, or to mark a certain segment. I guess it will be hard to do this with a specific plug-ins.
I just found this; haven't tried it yet:
https://github.com/cuekoo/GDB-ImageWatch
If eclipse is calling gdb, maybe there is a way...

Quick way to output a picture in C++

I'm coding a physical simulation on 2d array and I'm now thinking that I could benefit from having a graphical output. My system is an array of cells (up to 2048*2048 of them) taking binary values, until now I used a prompt or text file output of '+' and '-' but it's not efficient for 2048*2048 lattice and maybe outputting in an image would be quicker and neater. Still, I've never done that. Ideally a library allowing me to write blue and red pixels/cell while parsing my lattice would get the job done. Are there some pre-existing not too long tools for doing it in c++?
Edit: I think that I just found what I was looking for: png++
After no more than 10 lines of coding I got the following output:
All I was asking for! Thank you for the suggestions ;)
You can easily get away without using an external imaging library by outputting a very simple format such as PGM or PBM. Refer to the wikipedia page on Netbpm for more details, but you're essentially outputting all the values as either ASCII or binary numbers, then any image viewer or editor that supports PGM (many of which do) can open and display them. Even if you don't have an editor, something like ImageMagick can easily convert it to a PNG or any other more accessible format.
I've used this technique in the past to quickly visualize 2D data, as you're intending to.
C++ does not have native support for graphics. You need an additional C++ library.
Personally, I suggest you to use Qt, which is free, powerful and cross-platform.

Convert Movie to OpenNI *.oni video

The Kinect OpenNI library uses a custom video file format to store videos that contain rgb+d information. These videos have the extension *.oni. I am unable to find any information or documentation whatsoever on the ONI video format.
I'm looking for a way to convert a conventional rgb video to a *.oni video. The depth channel can be left blank (ie zeroed out). For example purposes, I have a MPEG-4 encoded .mov file with audio and video channels.
There are no restrictions on how this conversion must be made, I just need to convert it somehow! Ie, imagemagick, ffmpeg, mencoder are all ok, as is custom conversion code in C/C++ etc.
So far, all I can find is one C++ conversion utility in the OpenNI sources. From the looks of it, I this converts from one *.oni file to another though. I've also managed to find a C++ script by a phd student that converts images from a academic database into a *.oni file. Unfortunately the code is in spanish, not one of my native languages.
Any help or pointers much appreciated!
EDIT: As my usecase is a little odd, some explanation may be in order. The OpenNI Drivers (in my case I'm using the excellent Kinect for Matlab library) allow you to specify a *.oni file when creating the Kinect context. This allows you to emulate having a real Kinect attached that is receiving video data - useful when you're testing / developing code (you don't need to have the Kinect attached to do this). In my particular case, we will be using a Kinect in the production environment (process control in a factory environment), but during development all I have is a video file :) Hence wanting to convert to a *.oni file. We aren't using the Depth channel at the moment, hence not caring about it.
I don't have a complete answer for you, but take a look at the NiRecordRaw and NiRecordSynthetic examples in OpenNI/Samples. They demonstrate how to create an ONI with arbitrary or modified data. See how MockDepthGenerator is used in NiRecordSynthetic -- in your case you will need MockImageGenerator.
For more details you may want to ask in the openni-dev google group.
Did you look into this command and its associated documentation
NiConvertXToONI --
NiConvertXToONI opens any recording, takes every node within it, and records it to a new ONI recording. It receives both the input file and the output file from the command line.

Converting a pdf to jpg images using in Qt

the heading says it all actually:
i want to convert a pdf file into several jpg images. This is to be a part of a software coded in c++ (I'm using Qt for my interface if that matters... :)
Preferably i want the images output to be 72 dpi.
Is there a easy way to do this?
Please comment if you need any more information form me, I'm grateful for any help, tips or answer!
Take pdf2image utility, and run it from you program, collecting its output files.
If you really need single executable (why?) — take a look at its source, and rip everything from it.
You should try to use poppler (or xpdf). You'll have full control of the rendering resolution and can take advantage of image output devices (ImageOutputDev) which will render pages to a framebuffer.Saving this framebuffer to jpeg with libjpeg is ,then , pretty straightforward.