?
- 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.
- #ifndef Win_can_h
- #define Win_can_h
- ?
- #include <iostream>
- #include "ControlCAN.h"
- ?
- using namespace std;
- ?
- ?
- CAN Correlation
- ?
- Const Static DWORD ndevicetype = Vci_canete; //Device type
- Const Static DWORD ndeviceind = 0; //Device index number
- Const Static DWORD ncanind = 0; //Device port number
- ?
- class Win_can
- {
- Public:
- ??? Win_can () {}
- ??? ~win_can ()
- ??? {
- ?????? Vci_closedevice (Ndevicetype,ndeviceind);
- ???}
- ?
- ???? int Write_to_can (vci_can_obj frames[], int len) //support for sending multiple frames
- ??? {
- ?????? int ret = vci_transmit (Ndevicetype,ndeviceind,ncanind,frames,len);
- ?????? if (Ret < 1)
- ?????? {
- ????????? Std::cout << " send failed " << Std::endl;
- ??????}
- ?????? return ret;
- ???}
- ?
- ??? int read_from_can (vci_can_obj &frame) //frame Read
- ??? {
- ?????? int receiver = vci_receive (ndevicetype,ndeviceind,ncanind,&frame,1); //If only one frame is received at a time, is it better handled?
- ?????? if (Receiver <= 0)
- ?????? {
- ????????? Vci_readerrinfo (Ndevicetype,ndeviceind,ncanind,&errinfo);
- ??????}
- ?????? return true;
- ???}
- ?
- ??? bool init_can (string desip, int desport)
- ??? {
- ?????? /************************************************************************/
- ?????? / * Can card initialization * /
- ?????? /************************************************************************/
- ?????? int nreserved = desport;
- ?????? if (Vci_opendevice (ndevicetype,ndeviceind,nreserved)! = 1)
- ?????? {
- ????????? Std::cout << " failed to turn on the device, please check the device type and device index number is correct " << Std::endl;
- ????????? Vci_closedevice (Ndevicetype,ndeviceind);
- ????????? return false;
- ??????}
- ?
- ?????? Vci_setreference (Ndevicetype,ndeviceind,ncanind,cmd_desip, (PVOID) desip.c_str ());
- ?????? Vci_setreference (Ndevicetype,ndeviceind,ncanind,cmd_desport, (PVOID) &nreserved);
- ?
- ??? Vci_clearbuffer (Ndevicetype,ndeviceind,ncanind); //Clear buffer
- ???????? return true;
- ???}
- ?
- Public:
- ??? Vci_err_info Errinfo;
- ?
- };
- ?
- ?
- ?
- ?
- #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:
- 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.
- 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