Summary series _ 2 (VC, opencv, QT and other error debugging, continue ...)

Source: Internet
Author: User
Tags float number

This article will summarize some errors encountered during the use of opencv +.

1. After the program is compiled, the following error occurs during running:

  

Solution:

A. An error may occur when reading a file, for example, the name or path of a file such as an image or video is incorrect.

 

2. When the program passes the compilation, the following error occurs:

  

Solution:

A. The data type may be incorrect. For example, in this statement, gray_diff.at <unsigned char> (I, j) = 255;

Originally, the Data Type in gray_diff is unsigned char. If you write it as gray_diff.at <int> (I, j) = 255; or if you write it as another one, a similar error will be reported.

 

3. After the program is compiled, the following prompt appears:

  

Solution:

A. It may be that the read address is invalid. For example, if you read an image but the file is not in the image directory, a similar error will occur.

 

4. if you write a separate header file, for example, GMM. HPP, the header file also contains the system header file used by opencv, but in GMM. when opencv built-in variable types are applied in HPP, an error is reported. For example, the content of GMM. HPP is included in Main. cpp.

Shows the GMM. HPP content:

  

The following error is reported during compilation:

  

The reason is that the opencv namespace is not used. Just add using namespace CV. Note that after using the opencv header file, you must use its namespace at the same time. Otherwise, an error will be reported.

 

5. If the following error message is displayed during project generation:

  

It indicates that you have defined variables in the header file, and this header file is contained by two or more source files. Therefore, we can draw a conclusion that we should not define variables in the header file. If we want to define variables, we need to add a static keyword in front.

 

6. When you use single-step debugging and the variable monitor to monitor mat variables, you can view the data in mat (especially when the data type is floating point). The following information may appear:

  

This does not indicate that the mat data is incorrect, but the variable monitoring cannot be displayed. There may be two reasons: first, the variable can only display unsigned char data, other non-similar data may be displayed incorrectly. Second, internal data of the mat type may have different data points, so data may not be displayed.

 

7. XP + opencv2.3.1 + vs2010 used before reinstalling the system, opencv opened the camera normally, XP + opencv2.4.2 + vs2010 used after reinstalling the system, the program did not change, opencv failed to open the camera when running these programs, however, the camera EXE in the opencv1.0sample is running normally. In addition, the camera driver is normal, such as QQ video, and the camera software of the XP system can run normally. Why?

Later on the Internet, they all said that opencv2.0 previously only supported the VWF driver, which is an old driver of Microsoft. After opencv2.0, The vediocapture class is used, and the DirectShow class is supported. Is my camera driver too low? I interviewed a lot of camera drivers after the interview. From 01 to 11 years, none of them will work. Finally, we tested the videocapture class's function of reading video AVI files, and found that it was not smooth. Later, I re-built a project and ran smoothly using the same code. (Because opencv2.4.2 was just installed, I took the code that was not previously written in opencv2.3.1. to block it, I added the camera test code ), it seems that something in 2.3.1 has an impact. In short, it is good to work!

 

8. When debugging, the variable is displayed as-1. # in00 0. There are several possibilities. First, this variable (usually float type) is not initialized in debug mode. Second, it is possible that the calculated value is out of bounds, for example, an infinite number or an infinitely small float number, except for the number with the denominator 0.

 

9. Why is the window name of the new video displayed in opencv2.4.2 garbled? Sometimes even the name is not displayed. In addition, the slide entries that should have been present cannot be displayed or are in disorder.

This is because in the debug environment, the corresponding dll library should be followed by D, for example, opencv_core242d.dll. If opencv_core242.dll is used, the window name may be garbled, even slide bars cannot be displayed. Similarly, if you use a DLL with the end of D in release, the memory will report an error directly. Therefore, you can only use a DLL without D.

In a word, use the corresponding DLL in debug and the corresponding DLL in release to debug.

10. in QT, if the slot function is defined in the header file, the slot function must be implemented in the CPP source file. Otherwise, the slot function similar to undefined reference to mainwindow: on_pushbutton_clicked () will appear () the error is caused by the deletion of unnecessary buttons in the UI.

11. If you use the QT console to create a program, the following error message appears when you run the program:

  

This is because the console program cannot use the QT interface (qmessagebox is used in this program). Therefore, you need to remove QT-Gui from the code of the Project PRO. Otherwise, a similar error will be reported.

12. If the following error occurs in opencv:

  

It indicates that the imshow function is interrupted by other functions before the display is completed. This may occur in the callback function.

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.