How to process pixels in CLEyeMulticamWPFTest?
Posted: 30 October 2010 08:30 PM   [ Ignore ]
New Member
Rank
Total Posts:  6
Joined  2010-01-27

Does any one know how to process pixels in CLEyeMulticamWPFTest?
It’s not work below.

void CaptureThread()
        
{
            int w 
00;
            
System.IntPtr Scan0 _map;

            
int nVal;

            
CLEyeCameraGetFrameDimensions(_cameraref wref h);

            
CLEyeCameraStart(_camera);
            
int i 0;
            var 
color=0;

            
unsafe
            {
                char
thisPtr;
                
chartmpPtr;

                while (
_running)
                
{
                    
if (CLEyeCameraGetFrame(_camera_map500))
                    
{
                        
if (!_running)  break;
                        
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, (SendOrPostCallback)delegate
                        {

                             thisPtr 
= (char*)Scan0;
                             for (
int y 0h; ++y)
                             
{
                                 
for (int x 0w; ++x)
                                 
{

                                     
if (ColorMode == CLEyeCameraColorMode.CLEYE_COLOR_PROCESSED || ColorMode == CLEyeCameraColorMode.CLEYE_COLOR_RAW)
                                     
{
                                         tmpPtr 
= (thisPtr + (4) + (4));
                                         
nVal = (int)*(tmpPtr);                                    
                                         if (
nVal 0nVal 0;
                                         if (
nVal 255nVal 255;
                                         *((
thisPtr + (4) + (4))) = (char)nVal;

                                     
}
                                     
else
                                     
{
                                        tmpPtr 
thisPtr + () + x;
                                         
nVal = (int)*(thisPtr+y*w+x);
                                         if (
nVal 0nVal 0;
                                         if (
nVal 255nVal 255;
                                         *(
thisPtr + () + x)=(char)nVal;
                                         
                                     
}

                                 }
                             }
                             BitmapSource
.Invalidate();
                        
}null);
                        
i++;
                    
}
               }
            } 
Profile
 
 
Posted: 30 October 2010 11:37 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  585
Joined  2009-09-17

What doesn’t work? I wouldn’t call BeginInvoke inside the capture loop. Also from the code you posted it seems that you are not modifying any pixels but just copying them back in place.

Profile
 
 
Posted: 31 October 2010 06:01 PM   [ Ignore ]   [ # 2 ]
New Member
Rank
Total Posts:  6
Joined  2010-01-27

Indeed , i just try to manipulate the pixels fetched from the function of CLEyeCameraGetFrame(_camera, _map, 500))
In this procedure, i just put it back the original values.

I don’t know how to do it.  do you have any sample about it ?
I don’t know how to deal with interopbitmap , intptr etc.

tks.

Profile
 
 
Posted: 01 November 2010 11:46 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  585
Joined  2009-09-17

In your code the _map points to image pixels (unmanaged memory).
I’m not sure what kind of processing you are trying to do (depending on complexity, it might not be ideal to do this in C#) but you can always use the marshaling to go from IntPtr to byte[] or just use the code you have shown.
Your code should work fine the way you have it.

Profile
 
 
Posted: 03 August 2011 09:57 AM   [ Ignore ]   [ # 4 ]
New Member
Rank
Total Posts:  5
Joined  2010-11-19

Using Marshall.PtrToStructure
What datatype should it convert the _map intptr to?

I don’t really understand how it can be byte[]?

Thanks in advance?

Profile
 
 
 
 


RSS 2.0     Atom Feed