When I run opencv to show an image, I got an error like the image.
String index out of range: -8
The code is from Opencv website:
http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html
Like it is mentioned in the tutorial, you need to call your program by command line with an argument which is the path to your image :
./DisplayImage HappyFish.jpg //From the tutorial
The arguments you pass to an application are stored in argv and counted by argc. The first parameter is always the path of your own application.
If this don't helps you, you'll need to show us some codes and logs (what is the exact error message, etc.)
Related
I am trying to get the demo code for Detectron2 working locally on my laptop. Everything appears to run correctly, but no object instances are detected, even when I use the image from the Colab demo.
I am running on a non-GPU Mac. I followed the installation instructions to install Detectron. I have the following module versions on my machine:
detectron2#git+https://github.com/facebookresearch/detectron2.git#ea3b3f22bf1de58008599794f149149ff65d3780
opencv-python==4.5.3.56
torch==1.9.0
torchvision==0.10.0
I copied demo.py, predictor.py, mask_rcnn_R_101_FPN_3x.yaml, and Base-RCNN-FPN.yaml from Detectron's github. I then ran inference demo with pretrained model command. The specific command was this:
python demo.py --input 000000439715.jpeg --output output --config-file mask_rcnn_R_101_FPN_3x.yaml --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl MODEL.DEVICE cpu
000000439715.jpeg is the sample image of the man on horseback from the Colab notebook demo. The last line of the output is
000000439715.jpeg: detected 0 instances in 6.77s
The image in the output directory has no annotation on it.
The logging output looks okay to me. The only thing that may be an indication of a problem is a warning at the top
[08/28 12:35:18 detectron2]: Arguments: Namespace(confidence_threshold=0.5, config_file='mask_rcnn_R_101_FPN_3x.yaml', input=['000000439715.jpeg'], opts=['MODEL.WEIGHTS', 'detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl', 'MODEL.DEVICE', 'cpu'], output='output', video_input=None, webcam=False)
[08/28 12:35:18 fvcore.common.checkpoint]: [Checkpointer] Loading from detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl ...
[08/28 12:35:18 fvcore.common.checkpoint]: Reading a file from 'Detectron2 Model Zoo'
WARNING [08/28 12:35:19 fvcore.common.checkpoint]: Some model parameters or buffers are not found in the checkpoint:
I'm not sure what to do about it though.
I tried not specifying the model weights. I also tried setting the confidence threshold to zero. I got the same results.
Am I doing something wrong? What are the next debugging steps?
I met the same question with you, just like:
WARNING [xxxxxxxxx fvcore.common.checkpoint]: Some model parameters or buffers are not found in the checkpoint:
and this warning made my result very bad. Finally I found that I use a wrong weight file.
Hope this can help you.
I downloaded the official example which is CGAL-5.2\examples\Triangulation_2 from the website CGAL.org.
I successfully cmake the examples.
Then I opened Triangulation_2_Examples.sln from G:\MyCGAL_code\code_1\Triangulation_2\build by VS2017.
I also successfully built all projects (without errors).
I then click the debugger in VS: the draw triangulation.exe running fine, but the Triangulation_2 Basic_viewer is empty.
I knew someone's successful results has colored triangles in the window called Triangulation_2 Basic_viewer.
Did anyone try this official example before?
The program draw_triangulation_2 takes a filename as input (the file must contains a set of 2D points).
Without parameter, it takes data/triangulation_prog1.cin by default.
Thus the working directory must contains a directory data and this directory must contains a file triangulation_prog1.cin. Otherwise, the triangulation is empty.
To solve your problem, you need either to create the data directory and copy triangulation_prog1.cin in this directory; or give a valid filename as parameter.
I'm trying to read an image using OpenCV, where I did the following:
input_image = imread(argv[1], IMREAD_UNCHANGED);
if(input_image.empty())
{
cout<<"Image cannot be read";
return -1;
}
I'm using Xcode 6.4, and would like to pass two arguments, one for the input image and another for the output image.
So, I did the following in order to pass the argument:
Product --> Scheme --> Edit Scheme...
And, under Arguments, added two arguments: image1.png and image2.png.
I had only image1.png, which I added to the directory containing main.cpp. But, when I try to run the program, the input image seems not to be read, since the above if-statement evaluates to true, and I get the error message.
Why is that? What could I be doing wrong?
Thanks.
I am trying to run the letter_recog.cpp example with the 64-bit OpenCV 3. But during the process, it report the debug: Expression: vector subscript out of range.
When I step into the OpenCV source code to find out what is wrong, and it stops at the line of the memcpy(&subsets[split.subsetOfs], &w->wsubsets[wsplit.subsetOfs], ssize*sizeof(int));.
It is one line of the function int DTreesImpl::addTree(const vector& sidx ).
In the letter_recog.cpp example, I choose the build_rtrees_classifier. The train data after the prepare_train_data(data, responses, ntrain_samples) is
And the debug error happens in the function of model = StatModel::train(tdata, RTrees::Params(10,10,0,false,15,Mat(),true,4,TC(100,0.01f)));
Can anyone tell me what is wrong? Or how can I run the `letter_recog.cpp example successfully? Because I do not have enough reputation points, I can not post image.
Thanks a lot!`
sorry for my english..
i'm new to opencv, and i want to try samples square.cpp,i used codeblocks on ubuntu.
but i got error when i compiled and run it, it said that (on Xterm):
opencv error : bad argument (bad image header) in cvCloneImage file build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp, line 3122
so, my question is, how to fix it?
thanks.
It may contain some code which is using some input images. The important thing is that those input images might not be null.
This error comes in cxarray.cpp where we have the code like if (!CV_IS_IMAGE_HDR(src)). Now if you check for the definition of this
#define CV_IS_IMAGE_HDR
You will get it as:
((img) != NULL && ((const IplImage*)(img))->nSize == sizeof(IplImage))
The first thing it checks is for null image. So in your case you might not have the input image with you.
Select a input image you have and then try again. It will work, as it have worked for me.