Initialize multiple cameras Sapera - c++

I am trying to initialize multiple cameras using Sapera C++ but only one camera is being initialized. I am not sure what I am doing wrongly.
#include <vector>
#include <memory>
#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <atomic>
#include "SapClassBasic.h"
int serverCount = SapManager::GetServerCount();
char serverName[CORSERVER_MAX_STRLEN];
for (int serverIndex = 0; serverIndex < serverCount; serverIndex++)
{
if (SapManager::GetResourceCount(serverIndex, SapManager::ResourceAcqDevice) != 0)
{
// Get Server Name Value
SapManager::GetServerName(serverIndex, serverName, sizeof(serverName));
acqDeviceList_.push_back(serverName);
}
}
// add available servers to property and set active device to first server in the list
CreateProperty(g_CameraServer, acqDeviceList_[0].c_str(), MM::String, false, 0, false);
SetAllowedValues(g_CameraServer, acqDeviceList_);
activeDevice_ = acqDeviceList_[0];

Related

Is this code correct to send logs to remote syslog server using log4cplus?

Can someone please tell me if this is correct way of using SysLogAppender of log4cplus ? I did not find a proper example for log4cplus. I need to send numerous logs to remote syslog server.
main.cpp
int main()
{
SysLogHelper syslogHelper;
int errCode = syslogHelper.initialize("172.16.72.239");
errCode = syslogHelper.sendLogstoSyslog("send testing log");
// I need to send numerous logs to syslog
}
syslog.cpp
#include <log4cplus/syslogappender.h>
#include <log4cplus/spi/loggingevent.h>
#include <log4cplus/logger.h>
class SysLogHelper
{
string hostname;
log4cplus::SysLogAppender *syslogAppender;
// is it necessary to create a pointer? I am not able to use log4cplus in a class without creating a pointer? Is there any other way?
log4cplus::spi::InternalLoggingEvent syslogLoggingEvent;
public:
SysLogHelper();
int initialize(string hostname);
int sendLogstoSyslog(string message);
};
SysLogHelper::SysLogHelper()
{
hostname = "";
syslogAppender = NULL;
}
int SysLogHelper::initialize(string hostname)
{
syslogAppender = new log4cplus::SysLogAppender("ident", hostname);
//I am not getting what is "ident" here? what input is expected?
return 0;
}
int SysLogHelper::sendLogstoSyslog(string message)
{
syslogLoggingEvent.setLoggingEvent(
log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("test")).getName(),
log4cplus::FATAL_LOG_LEVEL, LOG4CPLUS_TEXT(message),__FILE__,
__LINE__, "main");
syslogAppender->doAppend(syslogLoggingEvent);
//Is this correct method of sending logs to syslog?
return 0;
}
questions:
I am able to send logs to remote syslog using above code. But is this correct way to use log4cplus APIs? Questions are given in the form of comments in above code example.
Why do we need to use log4cplus::initializer? I am not able to import log4cplus/initializer.h in my code.
In my opinion the phylosophy at the base of Log4cplus library is that you can have in your application one or more logger and for each logger you can have one or more output, called "appender". Inside your application you have to manage with logger and you don't have care which appender are linked to the logger. This is clear, for example, if you use a property file to config and to tune your logger.
By the way here in the following I show what I have done to configure syslog inside my application in both cases:
configuring syslog appender inside the code:
#include <log4cplus/logger.h>
#include <log4cplus/fileappender.h>
#include <log4cplus/syslogappender.h>
#include <log4cplus/layout.h>
#include <log4cplus/ndc.h>
#include <log4cplus/helpers/loglog.h>
#include <log4cplus/helpers/property.h>
#include <log4cplus/loggingmacros.h>
#include <log4cplus/configurator.h>
#include <log4cplus/helpers/stringhelper.h>
#include <log4cplus/helpers/fileinfo.h>
#include <TCHAR.h>
using namespace std;
using namespace log4cplus;
using namespace log4cplus::helpers;
using namespace log4cplus;
int main()
{
log4cplus::initialize ();
Logger root = Logger::getRoot();
// log level INFO: you don't see TRACE and DEBUG on your syslogserver
root.setLogLevel(log4cplus::INFO_LOG_LEVEL);
SharedObjectPtr<Appender> ptrSys(
new SysLogAppender(
_T("mysyslog"),
_T("localhost"),
514,
_T("user"))) ;
root.addAppender(ptrSys);
for(int i=0; i<100; ++i)
{
LOG4CPLUS_TRACE(root, LOG4CPLUS_TEXT("Error log test")); //not visible
LOG4CPLUS_DEBUG(root, LOG4CPLUS_TEXT("Debug log test")); //not visible
LOG4CPLUS_INFO(root, LOG4CPLUS_TEXT("Info log test"));
LOG4CPLUS_WARN(root, LOG4CPLUS_TEXT("Warning log test"));
LOG4CPLUS_ERROR(root, LOG4CPLUS_TEXT("Error log test"));
}
log4cplus::Logger::shutdown();
return 0;
}
As I said the way, that I prefer, is by configuration file, called here configlog.properties
#include <log4cplus/logger.h>
#include <log4cplus/fileappender.h>
#include <log4cplus/syslogappender.h>
#include <log4cplus/layout.h>
#include <log4cplus/ndc.h>
#include <log4cplus/helpers/loglog.h>
#include <log4cplus/helpers/property.h>
#include <log4cplus/loggingmacros.h>
#include <log4cplus/configurator.h>
#include <log4cplus/helpers/stringhelper.h>
#include <log4cplus/helpers/fileinfo.h>
#include <TCHAR.h>
using namespace std;
using namespace log4cplus;
using namespace log4cplus::helpers;
using namespace log4cplus;
log4cplus::tstring getPropertiesFileArgument (std::wstring argv)
{
log4cplus::tstring file = LOG4CPLUS_C_STR_TO_TSTRING (argv);
log4cplus::helpers::FileInfo fi;
if (getFileInfo (&fi, file) == 0)
return file;
return LOG4CPLUS_TEXT ("log4cplus.properties");
}
int main()
{
log4cplus::initialize ();
PropertyConfigurator::doConfigure( getPropertiesFileArgument(_T("c:\\ConfigLog.properties")));
Logger root = Logger::getRoot();
for(int i=0; i<100; ++i) {
LOG4CPLUS_TRACE(root, LOG4CPLUS_TEXT("Error log test"));
LOG4CPLUS_DEBUG(root, LOG4CPLUS_TEXT("Debug log test"));
LOG4CPLUS_INFO(root, LOG4CPLUS_TEXT("Info log test"));
LOG4CPLUS_WARN(root, LOG4CPLUS_TEXT("Warning log test"));
LOG4CPLUS_ERROR(root, LOG4CPLUS_TEXT("Error log test"));
}
log4cplus::Logger::shutdown();
return 0;
}
the configlog.properties file is something like this
log4cplus.rootLogger=INFO, syslog
log4cplus.appender.syslog=log4cplus::SysLogAppender
log4cplus.appender.syslog.ident=syslog
log4cplus.appender.syslog.layout=log4cplus::PatternLayout
log4cplus.appender.syslog.layout.ConversionPattern=[%T] %-5p %b %x - %m%n
log4cplus.appender.syslog.host=localhost
log4cplus.appender.syslog.udp=true
log4cplus.appender.syslog.port=514
log4cplus.appender.syslog.facility=user
I hope to be not too in late and I hope this can be helpful for you

How to open and close DVD-RW with C++?

I want to apologize for bad English.
In my system, the CD drive is occupied by another device and the program code does not work correctly, what should I use to open and close the DVD-RW drive?
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <shellapi.h>
#include <mmsystem.h>
using namespace std;
int main()
{
MCI_OPEN_PARMS OpenParm;
MCI_SET_PARMS SetParm;
MCIDEVICEID dID;
OpenParm.lpstrDeviceType=L"CDAudio";
mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE, (DWORD_PTR)&OpenParm);
dID = OpenParm.wDeviceID;
mciSendCommand(dID, MCI_SET, MCI_SET_DOOR_OPEN, (DWORD_PTR)&SetParm);
Sleep(3000);
mciSendCommand(dID, MCI_SET, MCI_SET_DOOR_CLOSED, (DWORD_PTR)&SetParm);
mciSendCommand(dID, MCI_CLOSE, MCI_NOTIFY, (DWORD_PTR)&SetParm);
return 0;
}
My System
What use instead CDAudio?

gcc compiler doesn't recognize my code for using Serial Port in Raspberry Pi 3

I'm compiling and running a C++/OpenCV program directly on the Raspberry Pi 3's Terminal with the line:
g++ pkg-config --cflags --libs opencv name.cpp -o name
I have been working like this without issues, but now I want to send some results like coordinates and numbers via serial port to Arduino, I tried to use this code:
#include <sstream>
#include <string>
#include <iostream>
#include <fstream>
#include <sys/time.h>
#include <termios.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
//######################################################################
int fd = open("/dev/ttyAMS0", O_RDWR);
if (fd == -1) {
perror("/dev/ttyAMS0");
return 1;
}
struct termios tios;
tcgetattr(fd, &tios);
// disable flow control and all that, and ignore break and parity errors
tios.c_iflag = IGNBRK | IGNPAR;
tios.c_oflag = 0;
tios.c_lflag = 0;
cfsetspeed(&tios, B9600);
tcsetattr(fd, TCSAFLUSH, &tios);
// the serial port has a brief glitch once we turn it on which generates a
// start bit; sleep for 1ms to let it settle
usleep(1000);
// output to serial port
char msg[] = "hi there";
write(fd, msg, strlen(msg));
But now each time I try to compile I get the errors shown in the image Here:
So I guess I'm missing something, I have added all the libraries for the Serial Port as well but I don't know if I should add something on the line for compile as I did with the opencv libraries. Thanks in advance for your answers :)
I can't add comment so I will answer what I think about your problem.
Looks like your code written in global scope outer any function body.
You can't use if statement out of any function body.
Try to enclose your if statement in function body.
Something like this:
void chec(int fd) {
if (fd == -1) {
perror("/dev/ttyAMS0");
exit(1);
}
}
int fd = open("/dev/ttyAMS0", O_RDWR);
check(fd);

Error while trying to build stasm minimal

I do not have experience on C++. And I have to use stasm for face detection. I'm traying to build the minimal example. On page 4 of this tutorial is possible to know what is necessary to make it work. But I'm these two errors:
g++ -Wno-deprecated -o teste minimal.cpp `pkg-config opencv --cflags --libs` -I/home/caaarlos/workspace/StasmDesbravando/stasm
In file included from minimal.cpp:46:0:
/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/pinstart.cpp: In function ‘void stasm::CopyPoint(stasm::Shape&, const Shape&, int, int)’:
/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/pinstart.cpp:138:13: error: redefinition of ‘void stasm::CopyPoint(stasm::Shape&, const Shape&, int, int)’
static void CopyPoint( // copy a point from oldshape to shape
^
In file included from minimal.cpp:37:0:
/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/convshape.cpp:9:13: error: ‘void stasm::CopyPoint(stasm::Shape&, const Shape&, int, int)’ previously defined here
static void CopyPoint( // copy a point from oldshape to shape
This is my code:
// minimal.cpp: Display the landmarks of a face in an image.
// This demonstrates stasm_search_single.
#include <stdio.h>
#include <stdlib.h>
#include "opencv/highgui.h"
#include <opencv/cv.h>
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_lib.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/asm.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/atface.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/basedesc.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/classicdesc.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/convshape.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/err.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/eyedet.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/eyedist.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/faceroi.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/hat.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/hatdesc.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/landmarks.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/landtab_muct77.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/misc.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/pinstart.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/print.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shape17.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shapehacks.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shapemod.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/startshape.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_landmarks.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_lib.h"
//#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_lib_ext.h"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/asm.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/classicdesc.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/convshape.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/err.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/eyedet.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/eyedist.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/faceroi.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/hat.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/hatdesc.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/landmarks.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/misc.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/pinstart.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/print.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shape17.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shapehacks.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/shapemod.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/startshape.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/stasm_lib.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/MOD_1/facedet.h"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/MOD_1/initasm.h"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/MOD_1/initasm.cpp"
#include "/home/caaarlos/Documentos/TCC/stasm4.1.0/stasm/MOD_1/facedet.cpp"
using namespace cv;
using namespace std;
int main()
{
static const char* const path = "../data/testface.jpg";
cv::Mat_<unsigned char> img(cv::imread(path, CV_LOAD_IMAGE_GRAYSCALE));
if (!img.data)
{
printf("Cannot load %s\n", path);
exit(1);
}
int foundface;
float landmarks[2 * stasm_NLANDMARKS]; // x,y coords (note the 2)
if (!stasm_search_single(&foundface, landmarks,
(const char*)img.data, img.cols, img.rows, path, "../data"))
{
printf("Error in stasm_search_single: %s\n", stasm_lasterr());
exit(1);
}
if (!foundface)
printf("No face found in %s\n", path);
else
{
// draw the landmarks on the image as white dots (image is monochrome)
stasm_force_points_into_image(landmarks, img.cols, img.rows);
for (int i = 0; i < stasm_NLANDMARKS; i++)
img(cvRound(landmarks[i*2+1]), cvRound(landmarks[i*2])) = 255;
}
cv::imwrite("minimal.bmp", img);
cv::imshow("stasm minimal", img);
cv::waitKey();
return 0;
}
I'm compiling my code in thi way:
g++ -Wno-deprecated -o teste minimal.cpp `pkg-config opencv --cflags --libs` -I/home/caaarlos/workspace/StasmDesbravando/stasm
What am I doing wrong? Can someone help me?
Thanks.
I've found a solution for this problem. If somebody has a problem like mine, you should enter on this site and use the CMakeList.txt and CMake to build Stasm. If you get any error you can try the intructions provides o the readme.

trouble with Open Cv and GPIO on mini6410

I am doing a simple project on arm based mini6410. I have debian package installed on mini. My project is to interface one IR motion sensor and I USB webcam with the mini6410. the working will be simple, whenever there will be any motion detected by IR sensor, the webcam will be on for 30 seconds save the images (over write the previous) and then off.
I have already cross comiled the Open CV code using arm-linux-gcc
For IR I am using GPE register.
Here I am stuck with a issue which I am unable to resolve. and even dont know how to resolve. OpenCv code is a cpp file camera.cpp and the file which deals with I/O ports is a C file named sensor.c. Now in that c file I am polling or whatever mechanism to check if the GPE register is 1 or not. If it is one, I should start the Open CV code which will start to capture images. further more this sensor.c file is not to be compiled rather made a module and then insmod on my mini6410.
However I dont know how to write c++ code in a c file. you can say i dont know how to call the OpenCV thing from the C file. as it is a module and within this i cant write the cpp code as then using namespace std and using namespace cv doesnot work.
i am new to embedded stuff and linux it self. so I wanted to know are there some possible solutions.
i am attaching my codes of both files.
This is sensor.c
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/serio.h>
#include <linux/delay.h>
#include <linux/clk.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/cdev.h>
#include <linux/miscdevice.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>
#include <mach/map.h>
#include <mach/regs-clock.h>
#include <mach/regs-gpio.h>
#include <plat/gpio-cfg.h>
#include <mach/gpio-bank-q.h>
#include <mach/gpio-bank-e.h>
#include <mach/map.h>
#include <plat/regs-timer.h>
#include <mach/hardware.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/moduleparam.h>
#include <linux/ioctl.h>
#include <linux/cdev.h>
#include <linux/string.h>
#include <linux/list.h>
#include <linux/pci.h>
#include <asm/uaccess.h>
#include <asm/atomic.h>
#include <asm/unistd.h>
#include <mach/gpio-bank-k.h>
#define RLV 0x0FFF
unsigned Gpe;
unsigned sensor_value;
typedef struct
{
int delay;
} TIM_DEV;
static TIM_DEV TimDev;
static irqreturn_t INTHandler(int irq,void *TimDev)
{
Gpe = readl(S3C64XX_GPEDAT);
Gpe &= ~(0xF<<1);
readl(sensor_value, S3C64XX_GPEDAT);
while (sensor_value == 1)
{//1 means that IR sensor has detected a motion and given a value of +5 V
for (i = 0; i < 30; i++){
//CV_function();
// delay here such that delay(1 s) * 30 = 30 seconds
}
}
return IRQ_HANDLED;
}
static struct file_operations dev_fops = {
.owner = THIS_MODULE,
.write = MyWrite,
};
static struct miscdevice misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = DEVICE_NAME,
.fops = &dev_fops,
};
static int __init dev_init(void)
{
int ret;
unsigned TimerControl;
unsigned TimerINTControl;
unsigned TimerCNTB;
unsigned TimerCMPB;
unsigned TimerCFG1;
unsigned Ge;
TimerControl = readl(S3C_TCON);
TimerINTControl = readl(S3C_TINT_CSTAT);
TimerCNTB = readl(S3C_TCNTB(0));
TimerCMPB = readl(S3C_TCMPB(0));
TimerCFG1 = readl(S3C_TCFG1);
TimerCFG1 &= ~(S3C_TCFG1_MUX0_MASK);
TimerCNTB = RLV;
TimerCMPB = 0;
writel(TimerCNTB, S3C_TCNTB(0));
writel(TimerCMPB, S3C_TCMPB(0));
writel(TimerCFG1, S3C_TCFG1);
TimerControl |= S3C_TCON_T0MANUALUPD;
TimerINTControl |= S3C_TINT_CSTAT_T0INTEN;
writel(TimerControl, S3C_TCON);
writel(TimerINTControl, S3C_TINT_CSTAT);
TimerControl = readl(S3C_TCON);
TimerControl |= S3C_TCON_T0RELOAD;
TimerControl &= ~S3C_TCON_T0MANUALUPD;
TimerControl |= S3C_TCON_T0START;
writel(TimerControl, S3C_TCON);
//////////////Here I am configuring my GPE as input/////////////
Ge = readl(S3C64XX_GPECON);
Ge &= ~(0xFFFF<<4);
Ge |= (0x0000<<4);
writel(Ge, S3C64XX_GPECON);
/////////////
misc_register(&misc);
ret = request_irq(IRQ_TIMER0, INTHandler, IRQF_SHARED, DEVICE_NAME, &TimDev);
if (ret)
{
return ret;
}
return ret;
}
static void __exit dev_exit(void)
{
free_irq(IRQ_TIMER0, &TimDev);
misc_deregister(&misc);
}
module_init(dev_init);
module_exit(dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("XYZ");
this is camera.cpp
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
int main( int argc, const char** argv )
{CvCapture* capture = 0;
Mat frame, frameCopy, image;
capture = cvCaptureFromCAM( 2 );
if( !capture )
{
cout << "No camera detected" << endl;
}
if( capture )
{
cout << "In capture ..." << endl;
IplImage* iplImg = cvQueryFrame( capture );
frame = iplImg;
if( frame.empty() )
break;
if( iplImg->origin == IPL_ORIGIN_TL )
frame.copyTo( frameCopy );
else
flip( frame, frameCopy, 0 );
cvSaveImage("image.jpg" ,iplImg);
}
cvReleaseCapture( &capture );
return 0;
}
the for loop in the sensor.c file should have my this above code by some means
I hope you get the idea,
Thanks
The missing link in the code shown is a mechanism by which the user-space code shown above can get notification of a change in the GPIO pin detected by the device driver.
There are two obvious ways to achieve this:
Integrate the GPIO pin into the platform's GPIO resources and then use the generic sysfs mechanism from user-space. The Linux kernel GPIO documentation describes both kernel and user-space side of this.
Have your driver expose a sysfs node for the GPIO line. sysfs is fundamental to the Linux Driver Model. I suggest a thorough read of Linux Device Drivers 3rd Edition.
The user-space side of either method is similar: You open the sysfs resource exported by your module and then use either poll() or select() to block until an event occurs.