/////////////////////////////////////////////////////////////// Method: OnDraw Class: CCamView Purose: CCamView drawing Input: nothing Output: nothing ///////////////////////////////////////////////////////////////
| 139 | // Output: nothing |
| 140 | //////////////////////////////////////////////////////////////////// |
| 141 | void CCamView::DrawCam( IplImage* pImg ) |
| 142 | { |
| 143 | // return; |
| 144 | if( m_bDrawing ) return; |
| 145 | m_bDrawing = true; |
| 146 | // if there was an image then we need to update view |
| 147 | if( pImg ) |
| 148 | { |
| 149 | // copy the image (will be deleted after display) |
| 150 | IplImage *pDstImg = pImg;//cvCloneImage(pImg); |
| 151 | |
| 152 | int nCamWidth = pImg->width;//m_pCamera->m_nWidth; |
| 153 | int nCamHeight = pImg->height;//m_pCamera->m_nHeight; |
| 154 | |
| 155 | |
| 156 | // draw a vertical line through the center of the image |
| 157 | cvLine(pDstImg, cvPoint(nCamWidth/2, 0), cvPoint(nCamWidth/2, nCamHeight), CV_RGB( 0,255,0 )); |
| 158 | |
| 159 | // draw a horizontal line at pixel 25 |
| 160 | cvLine(pDstImg, cvPoint(0, 25), cvPoint(nCamWidth, 25), CV_RGB( 0,255,0 )); |
| 161 | |
| 162 | // draw a horizontal line through the center of the image |
| 163 | //cvLine(pDstImg, cvPoint(0, nCamHeight/2), cvPoint(nCamWidth, nCamHeight/2), CV_RGB( 0,255,0 )); |
| 164 | |
| 165 | // process image from opencv to wxwidgets |
| 166 | unsigned char *rawData; |
| 167 | // draw my stuff to output canvas |
| 168 | CvSize roiSize; |
| 169 | int step = 0; |
| 170 | |
| 171 | // get raw data from ipl image |
| 172 | cvGetRawData( pDstImg, &rawData, &step, &roiSize ); |
| 173 | |
| 174 | // convert data from raw image to wxImg |
| 175 | |
| 176 | |
| 177 | wxImage *pWxImg = new wxImage( nCamWidth, nCamHeight, rawData, TRUE ); |
| 178 | |
| 179 | // convert to bitmap to be used by the window to draw |
| 180 | |
| 181 | if (m_pBitmap) |
| 182 | { |
| 183 | delete m_pBitmap; |
| 184 | } |
| 185 | |
| 186 | m_pBitmap = new wxBitmap( pWxImg->Scale(m_nWidth, m_nHeight) ); |
| 187 | |
| 188 | m_bNewImage = true; |
| 189 | m_bDrawing = false; |
| 190 | |
| 191 | Refresh( FALSE ); |
| 192 | |
| 193 | //Update( ); |
| 194 | delete pWxImg; |
| 195 | |
| 196 | //cvReleaseImage( &pDstImg ); |
| 197 | |
| 198 |