Memory leak problem +canapi+ Lane line width + image external parameter calibration

Source: Internet
Author: User

?

    1. Memory leaks

      In the process of testing the decision-making procedure, we found a strange problem, each time the program is opened, the connection cable to the dsbase to send data, there will be a 4k of memory leakage every time, 1s increased once. I don't know what the hell.

      Found a lot of information, still did not solve the problem. But, strangely, with the Win7 64-bit machine and the company's computer to do the test, there is no memory leak, no similar error occurred. Strange.

Later, to do experimental tests, and finally found the problem lies. The original is the front Denso radar in the can card to send data, and my program does not receive this data, resulting in memory leaks. Even the same can card,

If it is not dealt with in the procedure, it is not possible. It has been thought that the can API will only work on a can port, and now it does not, so, for the same can device, it is best to manage all the ports in one process,

It's OK to receive and send data. Otherwise it will cause a memory leak. Remember. Remember.

Resources:

http://bbs.csdn.net/topics/390292180 send data memory leak, 4k increments per cycle

http://bbs.csdn.net/topics/360163468 Multi-threaded run-time memory leak

?

Memory leak Detection tool in http://www.cnblogs.com/yixiaoyang/archive/2010/12/10/1902255.html vs environment

?

?

?

http://blog.csdn.net/wxqian25/article/details/17258407boundschecker use

?

?

http://download.csdn.net/user/yth796/uploads/2boundschecker Download

?

Official website: http://supportline.microfocus.com/

?

Possible causes: synchronizing that piece of matter, createthread the problem. Tried, the problem is not here.

Use this function to try and call the thread

?

2 , about CANET API the Use

in order for the program to run as stably as possible, use a minimal library, instead of the Ucos provided CAN Library for programming.

In the process of using the following procedure, a start or Die configuration is not successful, always in Vci_opendevice (); later, the configuration has been tried again or unsuccessfully.

Finally, I wrote a test program, incredibly run through. The final reason is that there should be a problem with the configuration of the project. Later, with the new project configuration project, the perfect solution.

In other words, the next time you troubleshoot a problem, we need an item to test, not a whole test.

  1. #ifndef Win_can_h
  2. #define Win_can_h
  3. ?
  4. #include <iostream>
  5. #include "ControlCAN.h"
  6. ?
  7. using namespace std;
  8. ?
  9. ?
  10. CAN Correlation
  11. ?
  12. Const Static DWORD ndevicetype = Vci_canete; //Device type
  13. Const Static DWORD ndeviceind = 0; //Device index number
  14. Const Static DWORD ncanind = 0; //Device port number
  15. ?
  16. class Win_can
  17. {
  18. Public:
  19. ??? Win_can () {}
  20. ??? ~win_can ()
  21. ??? {
  22. ?????? Vci_closedevice (Ndevicetype,ndeviceind);
  23. ???}
  24. ?
  25. ???? int Write_to_can (vci_can_obj frames[], int len) //support for sending multiple frames
  26. ??? {
  27. ?????? int ret = vci_transmit (Ndevicetype,ndeviceind,ncanind,frames,len);
  28. ?????? if (Ret < 1)
  29. ?????? {
  30. ????????? Std::cout << " send failed " << Std::endl;
  31. ??????}
  32. ?????? return ret;
  33. ???}
  34. ?
  35. ??? int read_from_can (vci_can_obj &frame) //frame Read
  36. ??? {
  37. ?????? int receiver = vci_receive (ndevicetype,ndeviceind,ncanind,&frame,1); //If only one frame is received at a time, is it better handled?
  38. ?????? if (Receiver <= 0)
  39. ?????? {
  40. ????????? Vci_readerrinfo (Ndevicetype,ndeviceind,ncanind,&errinfo);
  41. ??????}
  42. ?????? return true;
  43. ???}
  44. ?
  45. ??? bool init_can (string desip, int desport)
  46. ??? {
  47. ?????? /************************************************************************/
  48. ?????? / * Can card initialization * /
  49. ?????? /************************************************************************/
  50. ?????? int nreserved = desport;
  51. ?????? if (Vci_opendevice (ndevicetype,ndeviceind,nreserved)! = 1)
  52. ?????? {
  53. ????????? Std::cout << " failed to turn on the device, please check the device type and device index number is correct " << Std::endl;
  54. ????????? Vci_closedevice (Ndevicetype,ndeviceind);
  55. ????????? return false;
  56. ??????}
  57. ?
  58. ?????? Vci_setreference (Ndevicetype,ndeviceind,ncanind,cmd_desip, (PVOID) desip.c_str ());
  59. ?????? Vci_setreference (Ndevicetype,ndeviceind,ncanind,cmd_desport, (PVOID) &nreserved);
  60. ?
  61. ??? Vci_clearbuffer (Ndevicetype,ndeviceind,ncanind); //Clear buffer
  62. ???????? return true;
  63. ???}
  64. ?
  65. Public:
  66. ??? Vci_err_info Errinfo;
  67. ?
  68. };
  69. ?
  70. ?
  71. ?
  72. ?
  73. #endif

?

3 , calibration image external parameters

The following parameters are mainly available for image external parameter:

Wheel_offset???? longitudinal distance from the camera to the front axle

Head_offset 168???? The longitudinal distance from the camera to the front bumper

width_offset_l???? The transverse distance of the camera from the revolver

Width_offset_r???? Transverse distance of camera from right wheel

Camera_tanr0 20.00 Camera's pitch angle

Camera_height 138 camera height from the ground

?

?

In adjusting the pitch angle, we have several ways:

    1. When the intersection of two lines is not available, we can calibrate by artificially adjusting the camera_tanr0, then viewing the effect of the inverse perspective, in principle, the lane after the inverse perspective should be parallel, when the lane line is not parallel, indicating the problem of calibration, we need to adjust the angle.
    2. There is also a way, camera_tanr0 unchanged, to adjust the camera, and we can see that the lane line is changing in recognition.

The following are the calibrated lane lines:

?

?

4 , modify Lane width

before the image program has a Bugs, when no two lanes were found, the man made up half the lane width 1.8m, when we detect a lane, because we are laying the lane line is not standard, resulting in karting, the route back and forth Jitter.

Later, add one to get the previous car width to solve the problem.

the added code is as follows: Lane_width into a variable.

is the case where an edge and two edges are detected. Figure 1 is the detection of an edge, the right lane line is a virtual center line, self-complementary.

Figure 2 is to detect 2 edge of the case, the middle of a virtual center line, through the left and right lane line calculation.

Memory leak problem +canapi+ Lane line width + image external parameter calibration

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.