Zdravim,
pisem taku mini-aplikaciu na demonstraciu prace s IDS kamerou pod .NET.
Mam multi project solution kde jeden projekt je v C# a druhy v C++/CLR.
Potrebujem po stisknuti tlacitka v UI ktore je v C# inicializovat kameru priamo cez funkciu z kniznice od vyrobcu.
v UI volam
Kód:
private void initButton_Click(object sender, System.EventArgs e)
{
int osid = cameraSample.InitCamera(pictureBox.Handle.ToInt32());
this.initButton.Text = osid.ToString();
}
co je c++ metoda v druhom projekte (prepojene je to v poriadku, parametre preda bez problemov, aj vrati hodnotu)
Kód:
int CameraSample::InitCamera(int handleWindow)
{
HIDS cameraHandle = (HIDS) 0;
HWND displayWindowHandle = (HWND) handleWindow;
[color=red]int camera = is_InitCamera(&cameraHandle,displayWindowHandle);[/color]
return camera;
}
,kde HWND je nejaky struct definovany vo WinDef.h a HIDS su definovane v header file, ktory bol ku kamere (s tym tiez nieje problem)
Samotnu funkciu is_InitCamera() popisuje v maunlae vyrobca takto
Kód:
[b]Syntax[/b]
INT is_InitCamera (HIDS* phf, HWND hWnd)
[b]Description[/b]
is_InitCamera() starts the driver and establishes the connection to the camera. After
successful initialization, this function assigns the camera handle. All subsequent functions require
this handle as the first parameter.
When using Direct3D for image display, you can pass a handle to the output window (see also
How To Proceed: Image Display).
Neustale vsak dostavam na ten cerveno vyznaceny riadok tento error
Kód:
Error 1 error C2664: 'is_InitCamera' : cannot convert parameter 1 from 'cli::interior_ptr<Type>' to 'HIDS *' c:\Users\*****\Documents\Visual Studio 2008\Projects\CameraSample\CameraSampleApp\CameraSampleApp.cpp 18 CameraSampleApp
Co som googlil radili pouzit pre deklaraciu toho HIDS triedu pin_ptr<TYPE>, ale neslo mi to ani s tym. Vraj je to nejaky problem s GC, alebo co. Paradoxne na tom je, ze uz raz som to mal v stave ked to islo a dokonca ta funkcia vratila IS_SUCCES, lenze som bol nespokojny s tym, ako to je napisane, tak som tu upravil, bohuzial uz niet cesty spat
Prosim o radu ako tam tie parametre spravne napasovat. Skusal som rozne variacie.
Napriklad ked tam hodim
Kód:
int camera = is_InitCamera(0,displayWindowHandle);
,tak nedostanem error ale vrati IS_NO_SUCCES, takze tie parametre tam zrejme neboli take ake by mali.
EDIT:
V manuale je
Kód:
Code Sample
//Open camera with ID 1
HIDS hCam = 1;
INT nRet = is_InitCamera (&hCam, NULL);
Vopred dakujem za akukovek radu a prajem pekne velkonocne sviatky