내 인턴십을 위해서는 prosillica 카메라로 사진을 만들어야하는데 카메라로 작업 할 수있는 다른 API를보고있었습니다. 이제는 작동하는 코드를 찾았고 이전 인턴이 작성한 코드를 작성합니다 ("추측하기"라고 말합니다). 나는 이미지를 얻지 만 모두 실제로 확대됩니다. 공식 Firegrab 프로그램에서 사진은 잘 보이고 전혀 확대되지 않습니다. 이미지 here을 볼 수 있습니다. 내가 카메라에 연결하면, 나는 또한 즉시 녹화를 시작하도록 지시AVT Firewrap.net 카메라가 코딩되지 않았더라도 확대합니다.
Ctrl = FireWrap_CtrlCenter.GetInstance();
Ctrl.OnFrameReady += OnFrameReady;
Result = Ctrl.FGInitModule();
if (Result == enFireWrapResult.E_NOERROR)
{
Result = InfoContainer.FGGetNodeList();
var NodeCnt = InfoContainer.Size();
InfoContainer.GetAt(NodeInfo, 0);
Result = Cam.Connect(NodeInfo.Guid);
cCamera.Items.Add(Cam.DeviceAll);
if (Result == enFireWrapResult.E_NOERROR)
{
Cam.m_Guid = NodeInfo.Guid;
}
if (Result == enFireWrapResult.E_NOERROR)
{
Result = Cam.SetParameter(enFGParameter.E_IMAGEFORMAT,
(((uint)enFGResolution.E_RES_SCALABLE << 16) |
((uint)enColorMode.E_CCOLORMODE_Y8 << 8) |
0));
}
if (Result == enFireWrapResult.E_NOERROR)
Result = Cam.OpenCapture();
// Print device settings
Result = Cam.GetParameter(enFGParameter.E_XSIZE, ref XSize);
Result = Cam.GetParameter(enFGParameter.E_YSIZE, ref YSize);
width = XSize;
height = YSize;
// Start camera
if (Result == enFireWrapResult.E_NOERROR)
{
Result = Cam.StartDevice();
}
}
: 내가 카메라에 연결하기 위해 쓴 코드는 다음과 같이이었다. 프레임이 나 카메라 I가 다음 코드를 사용하는 OnFrameReady 처리된다 켜지 얻을 : 그래서 프레임을 얻고 바이트 []에 넣어이 함수
Debug.WriteLine("OnFrameReady is called");
FGEventArgs args = (FGEventArgs)__p2;
FGFrame Frame;
Guid.High = args.High;
Guid.Low = args.Low;
if (Guid.Low == Cam.m_Guid.Low)
{
Result = Cam.GetFrame(Frame, 0);
// Process frame, skip FrameStart notification
if (Result == enFireWrapResult.E_NOERROR & Frame.Length > 0)
{
byte[] data = new byte[Frame.Length];
// Access to frame data
if (Frame.CloneData(data))
{
//DisplayImage(data.Clone());
SaveImageFromByteArray(data);
// Here you can start your image processsing logic on data
string debug = String.Format("[{6}] Frame #{0} length:{1}byte [ {2} {3} {4} {5} ... ]",
Frame.Id, Frame.Length, data[0], data[1], data[2], data[3], Cam.m_Guid.Low);
Debug.WriteLine(debug);
}
// Return frame to module as fast as posible after this the Frame is not valid
Result = Cam.PutFrame(Frame);
}
}
를하고 난 전화 함수 SaveImageFromByteArray(); 여기서 나는 byte []를리스트에 넣는다. 그래서 나는 나중에 그들을 저장하기 위해 모든 나의 그림에 접근 할 수있다. 메신저 후
public void SaveImageFromByteArray(byte[] byteArray)
{
try
{
//bytearray size determined
byte[] data = new byte[width * height * 4];
int o = 0;
//bytearray size filled
for (int io = 0; io < width * height; io++)
{
byte value = byteArray[io];
data[o++] = value;
data[o++] = value;
data[o++] = value;
data[o++] = 0;
}
bytearrayList.Add(data);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
, 내가 저장을 클릭 내 모든 프레임을 레코딩 할 카메라를 중지하고 난 비트 맵 파일에 저장하려면 다음 함수를 호출 : 다음 SaveImageFromByteArray의 코드는 다음과 같이 다음에
public void SaveData()
{
try
{
foreach (byte[] data1 in bytearrayList)
{
byte[] data = Save(data1);
lock (this)
{
unsafe
{
fixed (byte* ptr = data)
{
try
{
using (image = new Bitmap((int) width, (int) height, (int) width * 4,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb, new IntPtr(ptr)))
{
image.Save(path + nextpicture + ".bmp", ImageFormat.Bmp);
Debug.WriteLine("Image saved at " + path + nextpicture + ".bmp");
nextpicture++;
}
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
}
}
}
}
}
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
}
}
위 다음과 같이 작성되는 함수에서 호출 된 함수 저장 :
private byte[] Save(byte[] data1)
{
//bytearray size determined
byte[] data = new byte[width * height * 4];
int o = 0;
//bytearray size filled
for (int io = 0; io < width * height; io++)
{
byte value = data1[io];
data[o++] = value;
data[o++] = value;
data[o++] = value;
data[o++] = 0;
}
return data;
}
나는 우리가 카메라에 연결하고 우리가이 L을 실행할 때 줌의 문제가 생기는 일이라고 생각을 ine 코드 :
if (Result == enFireWrapResult.E_NOERROR)
{
Result = Cam.SetParameter(enFGParameter.E_IMAGEFORMAT,
(((uint)enFGResolution.E_RES_SCALABLE << 16) |
((uint)enColorMode.E_CCOLORMODE_Y8 << 8)|
0));
}
그러나 문제는 Firewrap.net 또는 해당 API에 대한 문서가 없다는 것입니다. 15를 좋아하는 16을 편집하려고 할 때도 카메라가 시작되지 않습니다.