Not sure why this is happening. The method :
IplImage.createFrom(image);
Is hanging without returning any value. I've tried multiple images, and confirmed their existence. I'm writing an application that harnesses template matching, however this initial step is giving me a headache. Does anyone know why this method would suspend the thread and not return any value? I've done some research, and confirmed my OpenCV path is set up, and that all my libraries are properly setup.
Before converting a BufferedImage to iplimage we need to create an iplimage which has same height and width as the BufferedImage. Try this code:
IplImage ipl_image = IplImage.create(buffered_image.getWidth(),buffered_.getHeight(),IPL_DEPTH_8U,1);
ipl_image = IplImage.createFrom(buffered_image);
Related
I'm new to C++ and opencv and having difficulty running the background subtractor model. I'm using Visual Studio 2017 (VC++) and opencv 3.2.
I need to use BackgroundSubtractorMOG2 and it creates the model fine but throws exception when I pass it a new frame that is converted from an encoded image (because I'm using a USB3 camera that doesn't allow direct reading of frame by opencv) to cv::Mat. The code snippet is below
if (EncodeRawImage(pRawImage, &frameDesc, imageFormat, &pEncodedImage, &encodedImageSize) == SUCCESS) {
// Convert current raw image to openCV Mat format for analysis
auto store = gcnew cli::array<Byte>(encodedImageSize);
System::Runtime::InteropServices::Marshal::Copy(IntPtr(pEncodedImage), store, 0, encodedImageSize);
auto stream = gcnew System::IO::MemoryStream(store);
System::Drawing::Bitmap^ bitmapFrame = safe_cast<System::Drawing::Bitmap ^> (Image::FromStream(stream));
Mat imgBuf = Mat(bitmapFrame->Width, bitmapFrame->Height, CV_8U, pEncodedImage);
Mat imgMat = imdecode(imgBuf, CV_LOAD_IMAGE_COLOR);
bgm->apply(imgMat , fgMaskMOG);
returnCode = 1;
}
The exception is
owner 0x0000023afa2a2ec0 Information not available, no symbols loaded for opencv_world320d.dll> cv::detail::PtrOwner *
stored 0x0000023afa29baa0 Information not available, no symbols loaded for opencv_world320d.dll> cv::BackgroundSubtractorMOG2 *
Even though the opencv320d.lib are linked properly and a few other basic opencv samples run for me in the same program (e.g., cv::subtract, cv::calcHist etc). I wonder if it because the image size is too large (4608x3288) and bitmpaFrame that I'm creating may have an issue?
Or if I'm trying to access image data in the stream/memory in a way that is not allowed?
Even though the Information not found string is still there when I do the breakpoint, I just found that the model was throwing exception because of large image size as I mentioned in my original question (4608x3288). I resizes the image (resize(newImageMat, newImageMat, cv::Size(1000, 1000 * newImageMat.rows / newImageMat.cols), INTER_LINEAR);) and the error is gone and the model learns and shows the result. The text maybe a Visual Studio bug since I was reading about a similar issue here https://stackoverflow.com/a/7736034/3377101?
Trying to use JavaCV for image processing to rotate image according to it's Exif data.
Reading and writing from file to either Mat or IplImage works, but since the file is being upload or downloaded, I also want to be able to do the same thing processing byte[] instead of having to write to file.
However, I cannot find how to create a Mat instance from byte[].
The method 'aMat.put(0, 0, byteArray)' which is mentions in some answers is not available on a Mat instance in javacp version 1.0 using javacpp-presets:opencv:3.0.0.
Trying to put the bytes in the Mat data via : 'aMat.data().put(imageBytes, 0, 0)' throws a NPE because data() returns null. I cannot find how to set the data since it is a JNI call.
Any idea's on how to create a opencv_core.Mat from byte[]?
Did you try using:
yourMat.data().put(yourByteArray);
Just make sure yourMat is of the right size.
I am new to the Google App Engine and I am trying to use the Blobstore to store images that I want to display later on.
The image storage works fine. Now I want to dynamically change some images in my html code. Therefore I need a method of getting the images out of the blobstore and passing them. I am using Python. I found the get_serving_url-command, which seemed to be the perfect fit. Sadly, this causes an Error and I seem to be unable to fix it.
My basic code looks like this:
blob_key = "yu343mQ7kT4344N434ewQ=="
if blob_key:
blob_info = blobstore.get(blob_key)
if blob_info:
img = images.Image(blob_key=blob_key)
url = images.get_serving_url(blob_key)
...
Everytime the function gets called, I get the following Error in my Log Console.
File "C:\Program Files
(x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py",
line 234, in _MakeRealSyncCall
raise pickle.loads(response_pb.exception())
AttributeError: 'ImagesNotImplementedServiceStub' object has no
attribute 'THREADSAFE'
I have no idea how to fix it or if I am doing something terribly wrong.
I am very grateful for your support! Thank you in advance!
Have a nice day
You probably need an instance of BlobKey so if you are getting blob_info successfully try:
img = images.Image(blob_key=blob_info.key())
url = images.get_serving_url(blob_info.key())
I am running an MVC3 app on Mono/linux and everything is working fine with the exception of an image upload utility. Whenever an image upload is attempted i get the Invalid Parameter error from within the method below:
System.Drawing.GDIPlus.CheckStatus(status As Status) (unknown file): N 00339
System.Drawing.Bitmap.SetResolution(xDpi As Single, yDpi As Single)
I've googled this error extensively and have found that the Invalid parameter error can often be misleading, and could fire if for example there was an error with the upload itself, or if the image was not fully read. This runs fine on IIS/Windows, but I've not been able to get it to work in Mono.
Apache2
Mono 2.10.8.1
Am i missing something simple or do i need to find a different way to handle image manipulation for mono?
After doing quite a bit of testing, I was able to determine the root of my error. I was attempting to use the Image.HorizontalResolution and Image.VerticalResolution properties for Bitmap.Resolution . While these properties were set on the initial upload (where the file is read into a stream from the tmp directory), when i posted back with the base64 encoded string of the image itself, it appears these values were lost somehow. Because of this the SetResolution method failed.
For whatever reason i do not have this issue on IIS/Windows, the properties exist in both circumstances.
I encountered a similar issue. A Bitmap loaded from disk, reported bmp.HorizontalResolution==0 and bmp.VerticalResolution==0 when they were both==300. This behaviour does not occur on Windows.
A bit more digging, I found that the following test fails:
[Test]
public void GDI_SetResoltion()
{
var b1 = new Bitmap (100, 100);
Assert.That (b1.HorizontalResolution, Is.Not.EqualTo (0));
Assert.That (b1.VerticalResolution, Is.Not.EqualTo (0));
}
I believe Windows will default resolution to 96 dpi.
I'm making a small file-browser for my own use, in Ruby, and using Qt for the view. The idea is that it'll end up on my TV, where I can use the remote to move up and down and launch files.
Everything works fine, until I'm going to move the selection using the remote. I managed to set up a D-Bus service, so I'll just call the methods using LIRC.
The code I'm using for setting up the view looks like this:
#dm = Qt::DirModel.new
#sm = Qt::ItemSelectionModel.new(#dm)
#lv = Qt::ListView.new
#lv.model = #dm
#lv.selectionModel = #sm
cwd = #dm.index(#dir)
#lv.rootIndex = cwd
And then I'm unsure how to change the selection. Think I must have tried about every setIndex, setSelection and every method sounding similar, on the DirModel, ItemSelectionModel and ListView, without any luck. I've been googling and reading through the API without finding anything.
Ideally, I would have something like "moveSelectionDown" and "moveSelectionUp" that takes care of it, and making sure it wraps around correctly. But I can't seem to find anything.
Managed to fix it through the ItemSelectionModel every view apparently has.
moving up:
curIndex = #lv.currentIndex
#lv.selectionModel.setCurrentIndex(curIndex.sibling(curIndex.row-1, 0), Qt::ItemSelectionModel::ClearAndSelect)
or adding one to move down
I think you're forgetting that you have to create the ModelIndex through your model:
#dm.index(3, 0, None)
I'd try this method (Though I'm not really sure, this deselects the other cells.)
#lv.setCurrentIndex(#dm.index(3, 0, None))
I haven't used Ruby for ages, so I'm not exactly sure there's None.