Hy Everyone!IP 카메라에서 높은 Fps로 JPEG 형식의 이미지를 가져 오는 방법
JPEG 형식의 파나소닉 IP 카메라에서 이미지를 가져 오는 데 문제가 있습니다. fps가 항상 1 또는 2로 유지되지만 infact 카메라는 최대 30 개까지 캠 모델을 지원하기 때문에 문제는 fps와 같습니다. 파나소닉 WV-SP302E 난 여전히 2 FPS를 이미지를 잡고 심지어 다른 스레드에서 이미지를 잡기 위해 backgrounworker 구성 요소를 사용하고
public partial class Form1 : Form
{
// indicates wether to prevent caching in case of a proxy server or not
private bool preventCaching = false;
public Form1()
{
InitializeComponent();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
while (true)
{
this.pictureBox1.Image = this.GetSingleFrame(@"http://ipaddress/SnapshotJPEG?Resolution=320x240&Quality=Standard");
}
}
/// <summary>
/// Get a single JPEG frame from the camera
/// </summary>
/// <param name="source">JPEG Stream source</param>
/// <exception cref="WebException">If the IP camera is not receable or an error is occured</exception>
/// <exception cref="Exception">If an unknown error occured</exception>
public Bitmap GetSingleFrame(string source)
{
byte[] buffer = new byte[512 * 1024]; // buffer to read stream
HttpWebRequest req = null;
WebResponse resp = null;
Stream stream = null;
Random rnd = new Random((int)DateTime.Now.Ticks);
try
{
int read, total = 0;
// create request
if (!preventCaching)
{
req = (HttpWebRequest)WebRequest.Create(source);
}
else
{
req = (HttpWebRequest)WebRequest.Create(source + ((source.IndexOf('?') == -1) ? '?' : '&') + "fake=" + rnd.Next().ToString());
}
// set login and password
req.Credentials = new NetworkCredential("root", "a");
req.Timeout = -1;
resp = req.GetResponse();
// get response stream
stream = resp.GetResponseStream();
// loop
do
{
read = stream.Read(buffer, total, 1024);
total += read;
}
while (read != 0);
Bitmap bmp = (Bitmap)Bitmap.FromStream(new MemoryStream(buffer, 0, total));
return bmp;
}
catch (WebException ex)
{
string s = ex.ToString();
return null;
}
catch (Exception ex)
{
string s = ex.ToString();
return null;
}
finally
{
// abort request
if (req != null)
{
req.Abort();
req = null;
}
// close response stream
if (stream != null)
{
stream.Close();
stream = null;
}
// close response
if (resp != null)
{
resp.Close();
resp = null;
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.backgroundWorker1.RunWorkerAsync();
}
}
내 윈폼 응용 프로그램에 표시하지만, 다음 C# 코드를 사용하고 있습니다. 어떤 생각을 fps를 늘리는 방법
의견을 보내 주셔서 감사합니다. 이미지 잡는 날짜와 시간을 나타내는 목록에 항목을 추가하여 나이를 들여서 진행합니다. 그 목록은 또한 매초마다 두 개의 항목을 표시하므로 문제는 다른 곳에 있다고 생각합니다. –