Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ibaiGorordo
Copy link
Contributor

Comparing the nfa function with the function in the binomial_nfa repository, the first log_gamma call is missing.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

alalek and others added 30 commits October 15, 2022 16:44
DNN: Make Unsqueeze layer support negative axes
Parsing quantized nodes does not rely on names
DNN: supports Scatter and ScatterND from ONNX
Setting CAP_PROP_AUTO_EXPOSURE on VideoCapture with backend DSHOW does not change anything. Now with this implementation the property can be used with value 1 for availability.
…daptiveThreshold

QR code, reduce extra adaptiveThreshold()
* docs: remove duplicated step in Build .js doc

* docs: add missing emcmake prefix to command
* Fixes for Halide
* Enable some Halide tests
DNN-TF: let StridedSlice layer support const input
Do not fail tests in Yolo v7 model was not found
@ibaiGorordo
Copy link
Contributor Author

ibaiGorordo commented Jan 15, 2023

Hi,

I saw that the test failed always when testing with the rotatedRect:

TEST_F(Imgproc_LSD_ADV, rotatedRect)
.

I did some testing to try to understand why it was failing, but then I tested the same test with the original LSD method it was also failing the test. The reason why the incorrect method is working is that doing the refinement with LSD_REFINE_ADV returns almost the same result as using LSD_REFINE_STD because rect_improve is basically almost doing nothing.

The issue is that since the log_gamma is missing the value of log1term becomes a large negative value and therefore term becomes 0.0 in many cases if not always.

double term = exp(log1term);

Here is the calculations with the current code for one of the lines of the rotated rect test:
n+1: 815.000000, log_gamma(n+1): 4645.665759, log1term: -3832.690976, term: 0.000000

And this are the same calculations with the corrected code:
n+1: 815.000000, log_gamma(n+1): 4645.665759, log1term: -2.025217, term: 0.131965

As a result, with the current code, it in many cases (if not always), the if statement below becomes true, and therefore the value of nfa in the current code is either -log1term / M_LN10 - LOG_NT or -LOG_NT depending on k > n * p.

if(double_equal(term, 0))
{
if(k > n * p) return -log1term / M_LN10 - LOG_NT;
else return -LOG_NT;
}

In summary, the ADV version of the rotatedRect test is not correct since the original LSD method does not detect the lines of the rotatedRect in all the epochs when doing the rect_improve function

Edit:
Actually, there might be other issues because I am testing the LSD implementation in this other repository, and it passes the test even when using rect_improve. Below is an image for one of the tests (left is the results from the pylsd-nova repository, and the right one is the official OpenCV implementation with LSD_REFINE_ADV.

image

fengyuentau and others added 10 commits January 16, 2023 12:44
* fix openmp include and link issue on macos

* turn off have_openmp if OpenMP_CXX_INCLUDE_DIRS is empty

* test commit

* use condition HAVE_OPENMP and OpenMP_CXX_LIBRARIES for linking

* remove trailing whitespace

* remove notes

* update conditions

* use OpenMP_CXX_LIBRARIES for linking
Add `estimateSE2(...)`, `estimateSE3(...)`, `estimateSIM2(...)`, `estimateSIM3(...)` for estimating an geometric transformation with rotation and translation (with scaling for SIM) using USAC: as alternative for `estimateAffinePartial2D` and `estimateAffine3D`.

Modified test module.

Remove unused variables.

Remove initializer of unused variable.

Add interfaces to accept UsacParams() and corresponding test codes.

Revise test code.

PartialNd removed

Umeyama rewritten for code quality & speed

comments & minors

rise number of points

fix, and +30% faster!

only one number should be that big

remove USAC code, leave fix only

big number
…ense

USAC fix: GraphCut fails to allocate big dense matrices
Adding HEVC/H265 FourCC support to MSMF video writer

* Adding HEVC/H265 fourcc to MSMF video writer

Adding HEVC/H265 fourcc to MSMF video writer. I have verified it with my own video input stream, and it works well on my workstation.

* Update video io testing

* Adding macro fence to get rid of compiler error

H265/HEVC encoder is only available in Windows or later. https://learn.microsoft.com/en-us/windows/win32/medfound/h-265---hevc-video-encoder

* Update test_video_io.cpp
@asmorkalov asmorkalov requested a review from vpisarev January 25, 2023 08:25
alalek and others added 11 commits January 25, 2023 16:52
Added regression parameterized test for Structure Append mode

final_qr_code clear outside generateQR() method
dnn: add layer normalization for vision transformers

* add layer norm onnx parser, impl and tests

* add onnx graph simplifier for layer norm expanded

* handle the case when constants are of type Initializer

* add test case for layer norm expanded with initializers

* use CV_Assert & CV_CheckType in place of CV_Assert_N; use forward_fallback for OCL_FP16

* use const ref / ref in parameters of invoker::run; extract inner const if from nested loop; use size_t in place of ull

* template hasBias

* remove trailing whitespace

* use pointer parameter with null check; move normSize division & mean_square division outside of loop; use std::max to ensure positive value before std::sqrt

* refactor implementation, optimize parallel_for

* disable layer norm expanded

* remove the removal of layer norm optional outputs
…_23105_encodeStructuredAppend_problem

Fix encodeStructuredAppend() resulting in only one QR code problem, and false output data fix.
@ibaiGorordo
Copy link
Contributor Author

I have found the other issue (there might be more). The rect_nfa function was not checking the pixels inside the rectangle correctly. With the last changes to the rect_nfa function, now it checks the same pixels as the original paper. In the image below I fill a rotated rectangle using the original paper method (blue), the old OpenCV method (green), and the fixed code (red). As you can see, the old calculation had some logic issues.
rect_fill_comparison

I have tested the fix with the rotatedRect test example, and now it detects all the lines properly (compared to before when sometimes some of the lines were missing).

This reverts commit 823f891, reversing
changes made to ffc9d68.
@ibaiGorordo ibaiGorordo closed this Feb 1, 2023
@ibaiGorordo
Copy link
Contributor Author

Closing PR and opening a new one due to a mistake merging opencv:4.x

@ibaiGorordo ibaiGorordo mentioned this pull request Feb 1, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.