Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TestCamera.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <crtdbg.h>
- #include <iostream>
- #include <stdint.h>
- #include <stdlib.h>
- #include "opencv2/highgui/highgui.hpp"
- #include "opencv2/imgproc/imgproc.hpp"
- #include "opencv2/opencv.hpp"
- #pragma comment(lib,"comctl32.lib")
- #pragma comment(lib,"gdi32.lib")
- #pragma comment(lib,"vfw32.lib")
- typedef unsigned long DWORD;
- extern "C" {
- bool _cdecl img_capture ( int which_camera );
- int _cdecl img_init();
- bool _cdecl img_led ( int which_camera, int16_t mode );
- int _cdecl img_read ( int which_camera, unsigned char* pFrameBuffer, DWORD BytesToRead, DWORD dwMilliseconds );
- int _cdecl img_readAsy ( int which_camera, unsigned char* pFrameBuffer, DWORD BytesToRead, DWORD dwMilliseconds );
- int _cdecl img_reset ( int which_camera );
- bool _cdecl img_set_exp ( int which_camera, int16_t exposure );
- bool _cdecl img_set_gain ( int which_camera, int16_t gain );
- bool _cdecl img_set_lt ( int which_camera, int16_t a2, int16_t a3 );
- bool _cdecl img_set_wh ( int which_camera, int16_t w, int16_t h );
- }
- using namespace cv;
- using namespace std;
- unsigned char buffer[ 1024 * 1024 ];
- int main()
- {
- uint32_t timeout = 1000;
- int g_width = 1024, g_height = 1024;
- DWORD bytesToRead = g_width * g_height;
- memset ( &buffer[0], 0xaa, sizeof ( buffer ) );
- int ret = img_init();
- printf ( "%d = img_init\n", ret );
- ret = img_set_wh ( 1, g_width, g_height );
- printf ( "%d = img_set_wh(1,w,h)\n", ret );
- ret = img_set_wh ( 5, g_width, g_height );
- printf ( "%d = img_set_wh(5,w,h)\n", ret );
- // img_set_exp ( 1, 25 );
- // img_set_exp ( 5, 100 );
- //img_set_gain ( 1, 8 );
- // img_set_lt ( 1, 128, 0 );
- // camera indices are to be 1 and 5(looking up)
- ret = img_readAsy ( 5, &buffer[0], bytesToRead, timeout );
- printf ( "%d = img_readAsy, %d\n", ret, bytesToRead );
- Mat cameraFrame ( Size ( g_width, g_height ), CV_8UC1, buffer, g_width );
- imshow ( "camera", cameraFrame );
- bool quit = false;
- while ( quit == false ) {
- switch ( cv::waitKey ( 0 ) ) {
- case 'd':
- ret = img_readAsy ( 1, &buffer[0], bytesToRead, timeout );
- printf ( "%d = img_readAsy, %d\n", ret, bytesToRead );
- imshow ( "camera", cameraFrame );
- break;
- case 'u':
- ret = img_readAsy ( 5, &buffer[0], bytesToRead, timeout );
- printf ( "%d = img_readAsy, %d\n", ret, bytesToRead );
- imshow ( "camera", cameraFrame );
- break;
- case '0':
- img_led ( 1, 0 );
- break;
- case '1':
- img_led ( 1, 1 );
- break;
- case '2':
- img_led ( 5, 0 );
- break;
- case '3':
- img_led ( 5, 1 );
- break;
- case 'q':
- quit = true;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement