Kvazaar encoder - Reading ROI file failed - encoder

While trying this command:
kvazaar -i video.yuv --input-res 1280x720 -o video_tiled.hevc --roi roi.txt --slices tiles
I get this error:
Reading ROI file failed.
invalid argument: roi=roi.txt
Any ideas?
Thanks!

Your roi.txt file must be incomplete and inadequate to the specified size.
About the roi.txt file:
(...) the first two values are the width and height, followed by
width*height delta QP values in raster order.
Here is a link to the source code giving the error: [ https://github.com/ultravideo/kvazaar/blob/f8c5bb18a4604175f20dea673d14ca66257ac0c0/src/cfg.c#L1103 ]

Related

Kaggle - Cats vs dogs (UserWarning: Found 20000 invalid image filename(s) in x_col="filename". These filename(s) will be ignored.)

When I am generating the test generator, I get below error
UserWarning: Found 20000 invalid image filename(s) in x_col="filename". These filename(s) will be ignored.
Here is the code:
test_datagen = ImageDataGenerator(rotation_range=15,
rescale=1./255,
shear_range=0.1,
zoom_range=0.2,
horizontal_flip=True,
width_shift_range=0.1,
height_shift_range=0.1)
test_generator = train_datagen.flow_from_dataframe(train_df,
"./test/",x_col='filename',y_col='category',
target_size=Image_Size,
class_mode='categorical',
batch_size=batch_size)
The test folder is immediate before the file. I have searched a lot to fix this issue. If any thing wrong in the code please specify that or give me other suggestions.
All jpeg / png names must be in numerical order, according to the flow_from_dataframe in ImageDataGenerator, alphanumeric labels are not permitted. The image would be ignored, and a warning for that file will be issued.
Every image in your scenario has alphanumeric label (name in csv).

Change video stream resolution in YoloV4 demo

Here's what shows when loading the live stream demo for Yolov4:
Webcam index: 2
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Video stream: 2304 x 1536
Objects:
Then it starts finding objects with 2 fps.
How do I change the video stream resolution to 1080p or 720p? The frame rate is very slow and this appears to be the fix.
Can't find it within the makefile or cfg folder. Any thoughts? Is this an opencv problem?
Thanks!
cfg settings:
[net]
batch=64
subdivisions=8
# Training
#width=512
#height=512
width=320
height=320
channels=3
momentum=0.949
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
learning_rate=0.0013
burn_in=1000
max_batches = 500500
policy=steps
steps=400000,450000
scales=.1,.1
I tried with the built-in camera and connected my phone(IP) and got 1080 on both with smooth results. I didn't find anywhere to change the webcam settings which are stuck on 2304x1536. Where would camera settings be located?
After searching around for a solution to this issue myself I finally found it!
In the darknet/src/ folder is a file named "image_opencv.cpp". At lines 597 and 598 you will find the following 2 commented commands:
//cap->set(CV_CAP_PROP_FRAME_WIDTH, 1280);
&
//cap->set(CV_CAP_PROP_FRAME_HEIGHT, 960);
After trying out these commands a lot more errors showed up, this is due to yolov4 (and my install) using OpenCV 4.1.1. Which has a different syntax. Your resolution should change to 1920x1080 if you replace the two aforementioned commands with these:
cap->set(cv::CAP_PROP_FRAME_WIDTH, 1920);
cap->set(cv::CAP_PROP_FRAME_HEIGHT, 1080);
Notice that the comment slashes have been removed as to activate the commands.

Why do OpenCV VideoWriter only support 8-bit depth images?

I use VideoWriter::write to wrote a Mat with the pixel format of CV_32FC3,but it would always cause an error when VideoWriter::write was called.
Then i found that any pixel format of CV_8UC* would always succeed.
But Why?
Error Msg Was:
OpenCV(4.2.0) Error: Assertion failed (!fixedType() || ((Mat*)obj)->type() == mtype) in cv::debug_build_guard::_OutputArray::create, file C:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\matrix_wrap.cpp, line 1195
Any answer will be helpful
video is simply not stored at such high colour depths
Quoted From #MarkSetchell

opencv_createsamples "Assertion Failed" Error

I am trying to create a vec file from my positive image samples. I'm using the latest version of Opencv. The command I am using is this:
opencv_createsamples -info Positive.info -num 3750 -w 24 -h 24 -vec Positive.vec
All my images are bigger than 24x24, so I don't believe that that is the issue. I've tried searching online, but I don't find anyone with this error while doing the createsamples command. The output that I get when I run that is this:
Info file name: Positive.info
Img file name: (NULL)
Vec file name: Positive.vec
BG file name: (NULL)
Num: 3750
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 24
Height: 24
Max Scale: -1
RNG Seed: 12345
Create training samples from images collection...
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.0.0-alpha) Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in cv::Mat::Mat, file c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\matrix.cpp, line 465
This is my first time using opencv, so I'm very unclear as to what this error is. Anyone have any experience with this or can point me in the right direction to correcting the error?
This is Priyanka.
I was also getting the same error and I was trying to get resolution to it somehow.
But I could not find anything on internet.
But I am able to solve the problem successfully.
2-3 things that were missing as below:
I used opencv_annotation.exe to generate the -info (text file). This utility embeds complete image path into the file, where as the opencv_createsamples.exe expects that the images are present in the same folder as of the -info file. So what used to happen was the path of the image was getting concatenated with the path of the -info file.
i.e Suppose -info file is available at D:\MyPath\DataSet\annotations.txt and the images are at D:\MyPath\DataSet\Vehicles\*.png. In this case, while executing the opencv_createsamples.exe, the complete image path becomes D:\MyPath\DataSet\D:\MyPath\DataSet\Vehicles\image000.png, which the utility is not able to find.
So cater to the correct path kindly take care of below things
put the -info file in the same path as of images.
ensure that the -info file does not have the path for any image. It should contain only the
<image name without complete path> <object instances> <x y, width height>
With this change the image path was taken correctly and my issue got resolved.
Try doing this. It may help you.
This is Tushar Pathade, this error comes when your info.txt(file which contains information of objects to be detected) file contains some wrong information like image_name 1 0 0 0 0 or image_name 2 10 20 30 40. In first examples coordinates are (0,0,0,0) which is impossible while in second example no. of objects are 2 but coordinates of only one objects are mentioned.
So this lines produced this error. So first remove it and then run. You will not get any error then.
As priyanka mentioned above, this also need to take care of first but this will produced another error. It is nothing but image not found error. So to avoid it put info.txt file in a folder where negative images are. Basically u will see path in error so accordingly handle it.
Thank you.
I got the same error.
The error is about the bounding boxes, sometimes while creating bounding boxes you create a box outside the image pixel so that region is not get accepted and then you get this error.
Solution :
I used divide and conquer tech for this solution. What I did is I've created a new text file and in that text file I pasted some files from the original info or text file I ran the code if its creating samples then good if not then delete any one image from that text file run again*(run the create_samples again)*. do this until you get the clean file. I know this is too tedious task but this works.!
Thanks
I face the same issue now, if the num argument is less than 950 it works for me.

OpenCV read image from csv file

I have image in csv file and i want to load it in my program. I found that I can load image from cvs like this:
CvMLData mlData;
mlData.read_csv(argv[1]);
const CvMat* tmp = mlData.get_values();
cv::Mat img(tmp, true),img1;
img.convertTo(img, CV_8UC3);
cv::namedWindow("img");
cv::imshow("img", img);
I have RGB picture in that file but I got grey picture... Can somebody explain me how to load color image or how can I modify this code to get color image?
Thanks!
Updated
Ok, I don't know how to read your file into OpenCV for the moment, but I can offer you a work-around to get you started. The following will create a header for a PNM format file to match your CSV file and then append your data onto the end and you should end up with a file that you can load.
printf "P3\n284 177\n255\n" > a.pnm # Create PNM header
tr -d ',][' < izlaz.csv >> a.pnm # Append CSV data, after removing commas and []
If I do the above, I can see your bench, tree and river.
If you cannot read that PNM file directly into OpenCV, you can make it into a JPEG with ImageMagick like this:
convert a.pnm a.jpg
I also had a look at the University of Wisconsin ML data archive, that is read with those OpenCV functions that you are using, and the format of their data is different from yours... theirs is like this:
1000025,5,1,1,1,2,1,3,1,1,2
1002945,5,4,4,5,7,10,3,2,1,2
1015425,3,1,1,1,2,2,3,1,1,2
1016277,6,8,8,1,3,4,3,7,1,2
yours looks like this:
[201, 191, 157, 201 ... ]
So maybe this tr command is enough to convert your data:
tr -d '][' < izlaz.csv > TryMe.csv
Original Answer
If you run the following on your CSV file, it translates commas into newlines and then counts the lines:
tr "," "\n" < izlaz.csv | wc -l
And that gives 150,804 lines, which means 150,804 commas in your file and therefore 150,804 integers in your file (+/- 1 or 2). If your greyscale image is 177 rows by 852 columns, you are going to need 150,804 RGB triplets (i.e. 450,000 +/- integers) to represent a colour image, as it is you only have a single greyscale value for each pixel.
The fault is in the way you write the file, not the way you read it.
To see color image I must set number of channels. So this code works for me:
CvMLData mlData;
mlData.read_csv(argv[1]);
const CvMat* tmp = mlData.get_values();
cv::Mat img(tmp, true),img1;
img.convertTo(img, CV_8UC3);
img= img.reshape(3); //set number of channels

Resources