I have got the following exception in my OpenCV program. I had the following image in my computer and I moved it to my mobile phone and read it by Mat imageRead = Highgui.imread("/mnt/sdcard/Pictures/2im00.png");
Then I tried to convert its color space to HSV using the following statement, and got the exception on this statement.
Imgproc.cvtColor(imageRead, hsvImage, Imgproc.COLOR_RGB2HSV);
But the exception does not seem to tell me anything more than that it is in the function cvtColor, or I can't read the encoded information there.
So the question is that how do I find out why I am getting this exception?
Is there any coded information there, like some codes (like scn==3 or scn==4 or error:-215 or depth etc etc), which I can browse somewhere to find out why I am getting the exception?
Most probably, Assertion failure occurs because you are passing an empty image to the cvtColor function.
Or
The Mat image you are passing is not an CV_8U or CV_32F format.
I agree with Miki's comment for more details follow this link How to interpret c++ opencv Assertion error messages due to an error in cvtColor function?
Related
I'm trying to convert a base64 string in a BitMap, in order to show a photo in an ImageView. I'm failing because I'm receiving a bad string (how to fix this problem is not the scope of this topic), so I tried to handle this situation with a try-catch block.
Well, this block doesn't work because there's no exception throwed. As you can see from the Logcat in the lower part of the below image,the Base64 object (or the BitmapFactory one) just write a log about the failure (D/skia: failed to create image decoder with message 'unimplemented'), but don't launch any exception. There's no trace of my PHOTO-tagged log instead.
How could I do to manage this situation manually?
(I'm sorry if you'll find my english strange or difficult to read. I'm not mothertongue, but any help or criticism about it is well accepted)
Is it a compressed image encoded to Base64? (like .jpg or .png)
If so, the format of the image is not supported by the image decoder.
Otherwise, if it's raw data encoded in Base64, you should use Bitmap.createBitmap() to create a Bitmap.
I have used the official sample for using the Camera2 API to capture a RAW sensor frame. The code is in java but I transformed it to Kotlin with the help of Android Studio. I tested it, and I'm capable of taking and saving a dng picture to my phone. Not a problem so far.
But what I really want is to be able to retrieve some information about the picture, I don't care about saving it. I want to do the processing directly with my smartphone.
What I tried so far, is to get the byte array of the image.
In the function dequeueAndSaveImage, I retrieve the image from a ImageReader : image = reader.get()!!.acquireNextImage().
I suppose that is here that I have to process the image. I tried to log the image.width, image.height and the image.planes.count and there was no problem.
By the way, since the format is RAW_SENSOR, the image.planes.count is 1, corresponding to a single plane of raw sensor image data, with 16 bits per color sample.
But when I'm trying to log the image.planes[0].buffer.array().size for example, I'm getting a FATAL EXCEPTION: CameraBackground with java.lang.UnsupportedOperationException.
And if I'm trying to log the same thing, but in the function that saves the image to a dng file, I'm getting another type of error : FATAL EXCEPTION: AsyncTask #1 with java.lang.UnsupportedOperationException
Am I even going the right way in order to retrieve information about the image? For example the the intensity of the pixels, the average, the standard deviation for each channel of color, etc...
EDIT : I think that I found the problem, although not the solution.
When I log image.planes[0].buffer.hasArray(), it returns false, that's why calling array() throws an exception.
But then, how do I get the data from the image?
Did anyone has experience with MVEL2 on android?
i've tried out the same code with a simple java program and later on android:
The following exception is thrown when executed on android:
E/AndroidRuntime(30793): java.lang.ExceptionInInitializerError
I tried the example from the mvel website:
String template = "Hello, my name is #{name.toUpperCase()}";
Map vars = new HashMap();
vars.put("name", "Michael");
System.out.println(TemplateRuntime.eval(template, vars));
If theres no solution could anyone suggest a template engine which works with android
and supports iteration?
MVEL2 tries to substring the first 3 characters of the system java.version property when initializing the parser, and under Android the version is 0. That causes a bunch of exceptions which eventually cause the ExceptionInInitializerError.
If you want to force the java.version property, you can simply set it yourself:
System.setProperty("java.version", "1.6");
I have no idea what kind of odd side effects this may cause for Android, but at least it gets the MVEL parser up and running without throwing exceptions!
System.setProperty with "java.version" key seems to be read only propery in android, so it won't work.
i've tried to integrate MVEL 2 into android with no success, try using EVAL lib
I cant even get the example working for this, it throws the following error
02-04 19:22:05.617: E/AndroidRuntime(2548): java.lang.IllegalArgumentException: Supplied pTextureAtlasSource must not exceed bounds of Texture.
Does anyone know how to fix this or what it mean? This is just the example program that I installed
Ok, anyone that has this issue...
First of all that error was not correct, I seemed to have an older version of the AndEngine that was throwing that error. Also the example that is provided is flawed
Although it spcifies the base folder is "gfx" this doesnt apply for TexturePacket Textures therefore the path for the object should be "gfx/spritesheet/". I discovered this after it started to throw a null pointer exception after updating the engine
I am using a system() call in a program , that is in c library. For 1st 9 calls it returns '0'(zero) after 10th call it returns 256. I do not know what does it mean. Please anybody help me. Following is the line of code
int returnValue= system("/system/bin/cat /dev/graphics/fb0 > /tmpdata/Screenshot/screenshot.bin");
According to this man page dealing with the general unix cat command, an error code >0 simply means an error occurred.
The following exit values shall be returned:
0
All input files were output successfully.
>0
An error occurred.
Your system() call is attempting to concatentate two files, so perhaps there is a space issue or maybe the source file does not exist.
You may also wish to take a look at some recent source code for Android cat (cat.c) which gives some indicatations of the kind of things that trigger errors within cat.