CLEYE Reading Image Pixels Value
Posted: 19 November 2011 05:05 PM   [ Ignore ]
New Member
Rank
Total Posts:  1
Joined  2011-11-08

I am trying to do some Image Pixel Reading, I pulled some of the code off an OpenCV site, however, when I tried to compile it, alone, I get a flash of the console window and then nothing. However, if I tried to integrate it with some code that I pulled from the laboratories, however, I get the following errors:

error C3861: ‘PS3EyeMulticamStart’: identifier not found
error C3861: ‘PS3EyeMulticamGetFrame’: identifier not found
error C3861: ‘PS3EyeMulticamStop’: identifier not found
error C3861: ‘PS3EyeMulticamGetCameraCount’: identifier not found
error C2664: ‘MessageBoxW’ : cannot convert parameter 2 from ‘const char [26]’ to ‘LPCWSTR’
1>      Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2065: ‘VGA’ : undeclared identifier
error C3861: ‘PS3EyeMulticamOpen’: identifier not found
error C2664: ‘MessageBoxW’ : cannot convert parameter 2 from ‘const char [32]’ to ‘LPCWSTR’
1>      Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C3861: ‘PS3EyeMulticamLoadSettings’: identifier not found
error C3861: ‘PS3EyeMulticamGetFrameDimensions’: identifier not found
error C2664: ‘MessageBoxW’ : cannot convert parameter 2 from ‘const char [32]’ to ‘LPCWSTR’
1>      Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C3861: ‘PS3EyeMulticamClose’: identifier not found
error C3861: ‘PS3EyeMulticamShowSettings’: identifier not found
error C3861: ‘PS3EyeMulticamSaveSettings’: identifier not found
error C3861: ‘PS3EyeMulticamClose’: identifier not found
1>


Here is the code:

[/code]
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include "CLEyeMulticam.h"
 
#define WINDOW_NAME     "Capture Window"
bool bRunning = false;
int w, h;
 
// Capture thread
DWORD WINAPI Capture(LPVOID)
{
    IplImage 
*grayImage = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 1);
    
PS3EyeMulticamStart();
    while(
bRunning)
    
{
        PBYTE pBuffer 
= NULL;
        
cvGetImageRawData(grayImage, &pBuffer;);
        
PS3EyeMulticamGetFrame(pBuffer);
        
cvShowImage(WINDOW_NAME, grayImage);
    
}
    PS3EyeMulticamStop
();
    
cvReleaseImage(&grayImage;);
    return 
0;
}
 
void Program
()
{
    
// Query driver for number of connected PS3Eye cameras
    
int camCnt = PS3EyeMulticamGetCameraCount();
    
printf("Found %d PS3Eye cameras\n", camCnt);
    if(
camCnt == 0)
    
{
        MessageBox
(NULL,"No PS3Eye camera(s) found","PS3EyeMulticamTest", MB_ICONEXCLAMATION);
        return;
    
}
    
// Open cameras
    
if(!PS3EyeMulticamOpen(camCnt, VGA, 30))
    
{
        MessageBox
(NULL,"Could not open PS3Eye camera(s)","PS3EyeMulticamTest", MB_ICONEXCLAMATION);
        return;
    
}
    
// Load the default camera settings 'settings.xml' file
    // If the file is not found it will be created
    
PS3EyeMulticamLoadSettings("settings.xml");
 
    
// Get output image dimensions
    
PS3EyeMulticamGetFrameDimensions(w, h);
    
printf("Image dimensions (%d, %d)\n", w, h);
 
    
// Create OpenCV main window
    
cvNamedWindow(WINDOW_NAME, CV_WINDOW_AUTOSIZE);
    
cvMoveWindow(WINDOW_NAME, 0, 0);
    
cvResizeWindow(WINDOW_NAME, w, h);
 
    
// Start PS3Eye image capture thread
    
HANDLE hThread = CreateThread(NULL, 0, Capture, NULL, 0, 0);
    if(
hThread == NULL)
    
{
        MessageBox
(NULL,"Could not create capture thread","PS3EyeMulticamTest", MB_ICONEXCLAMATION);
        
PS3EyeMulticamClose();
        return;
    
}
    bRunning 
= true;
    
// The 's' key will open camera settings dialog
    
while(bRunning)
    
{
        int key 
= cvWaitKey(0);
        switch(
key)
        
{
            
case 's':
            case 
'S':
                
// Display settings
                
PS3EyeMulticamShowSettings();
            break;
            case 
0x1b:
                
printf("Exiting...\n");
                
// Stop the capture thread
                
bRunning = false;
                
// Wait for thread to exit
                
WaitForSingleObject(hThread, 3000);
                
printf("Thread exited\n");
            break;
        
}
    }
    
// Save camera settings
    
printf("Saving settings\n");
    
PS3EyeMulticamSaveSettings();
    
printf("Closing OpenCV window\n");
    
cvDestroyWindow(WINDOW_NAME);
    
PS3EyeMulticamClose();
}
 

void
mouseHandler
(int event, int x, int y, int flags, void* param)
{
    IplImage
* img0, * img1;
    
CvFont    font;
    
uchar*    ptr;
    
char      label[20];
 
    
img0 = (IplImage*) param;
    
img1 = cvCloneImage(img0);
 
    
cvInitFont(&font;, CV_FONT_HERSHEY_PLAIN, .8, .8, 0, 1, 8);
 
    if (
event == CV_EVENT_LBUTTONDOWN)
    
{
        
/* read pixel */
        
ptr = cvPtr2D(img1, y, x, NULL);
 
        
/*
         * display the BGR value
         */
        
sprintf(label, "(%d, %d, %d)", ptr[0], ptr[1], ptr[2]);
 
        
cvRectangle(
            
img1,
            
cvPoint(x, y - 12),
            
cvPoint(x + 100, y + 4),
            
CV_RGB(255, 0, 0),
            
CV_FILLED,
            
8, 0
        
);
 
        
cvPutText(
            
img1,
            
label,
            
cvPoint(x, y),
            &
font;,
            
CV_RGB(255, 255, 0)
        );
 
        
cvShowImage("img", img1);
    
}
}


// This is the program entry if you link with /SUBSYSTEM:CONSOLE option
int main(int argc, char *argv[])
{
Program
();
IplImage* img;
 
    
/* usage: <prog_name> <image> */
    
if (argc != 2) {
        printf
("Usage: %s <image>\n", argv[0]);
        return 
1;
    
}
 
    
/* load image */
    
img = cvLoadImage(argv[1], 1);
 
    
/* always check */
    
assert(img);
 
    
/* create a window and install mouse handler */
    
cvNamedWindow("img", 1);
    
cvSetMouseCallback("img", mouseHandler, (void*)img);
 
    
cvShowImage("img", img);
 
    
cvWaitKey(0);
 
    
/* be tidy */
    
cvDestroyAllWindows();
    
cvReleaseImage(&img;);
 
    return 
0;
}

[code] 

how do I fix this?

Profile
 
 
 
 


RSS 2.0     Atom Feed