本文整理汇总了C#中Emgu.CV.Capture.GetCaptureProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Capture.GetCaptureProperty方法的具体用法?C# Capture.GetCaptureProperty怎么用?C# Capture.GetCaptureProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emgu.CV.Capture
的用法示例。
在下文中一共展示了Capture.GetCaptureProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: write
public void write() {
int codec = Emgu.CV.CvInvoke.CV_FOURCC('P', 'I', 'M', '1');
int fps = 25;
if (list_timestamps.Count > 0)
{
String tempvideopath = Program.getConfiguration().Mediafolderpath + @"\" + list_timestamps[0].ToString() + ".mpg";
Capture tempcapture = new Capture(tempvideopath);
fps = (int)tempcapture.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FPS);
tempcapture.Dispose();
}
VideoWriter videowriter = new VideoWriter(videopath, codec, fps, 640, 480, true);
for (int i = 0; i < list_timestamps.Count; i++)
{
videopath = Program.getConfiguration().Mediafolderpath + @"\" + list_timestamps[i].ToString() + ".mpg";
try
{
Capture joincapture = new Capture(videopath);
Image<Bgr, byte> frame = joincapture.QueryFrame();
for (int n = 1; n < 15; n++)
joincapture.QueryFrame();
while (frame != null)
{
videowriter.WriteFrame(frame);
frame = joincapture.QueryFrame();
}
joincapture.Dispose();
// Notify main frame to update its progressbar
ExportVideoProgressEventArgs e = new ExportVideoProgressEventArgs(i);
DoneAppendingRallyVideoEvent(this, e);
}
catch (NullReferenceException) { Console.WriteLine("unreadable video file"); }
}
videowriter.Dispose();
}
示例2: Initialise
public void Initialise(string filename)
{
Close();
try
{
_Capture = new Capture(filename); //create a video player
FCaptureFPS = _Capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS);
Length = _Capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_COUNT) / FCaptureFPS;
FCapturePeriod = (int)(1000.0d / FCaptureFPS);
}
catch
{
_Status = "Player open failed";
return;
}
_Status = "Player open success";
HasCapture = true;
Image.FrameAttributesChanged = true;
Filename = filename;
CaptureThreadRun = true;
CaptureThread = new Thread(fnCapture);
CaptureThread.Start();
}
示例3: Main
static void Main(string[] args)
{
navigationMatrix = new Matrix3D();
navigationMatrix.Translate(new Vector3D(0, 100, 110));
navigationMatrix.Scale(new Vector3D((double)1 / 5, (double)1 / 5, (double)1 / 5));
displayProfile = new Bin[Bin.RANGEL, Bin.RANGEA, Bin.RANGEB];
for (int l = 0; l < Bin.RANGEL; l++)
for (int a = 0; a < Bin.RANGEA; a++)
for (int b = 0; b < Bin.RANGEB; b++)
displayProfile[l, a, b] = new Bin(l, a, b);
PopulateProfile(displayProfile, navigationMatrix);
String path = Environment.CurrentDirectory + PATH_TO_VIDEO;
if (!System.IO.File.Exists(path))
return;
//Opens the movie file
capture = new Capture(path);
double fps = capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS);
//Reads frame by frame
Timer timer = new Timer(1000 / fps);
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Start();
Console.Read();
}
示例4: frameProcessing
private void frameProcessing()
{
_capture = new Capture(_file);
totalFrameCount = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
progressBar1.Maximum = (int)totalFrameCount;
timer.Start();
_capture.ImageGrabbed += ProcessFrame;
if (timer.ElapsedMilliseconds == 1000) _capture.Stop();
}
示例5: Main
static void Main(string[] args)
{
/* One File
string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string workingDir = @"E:\REDID\vids";//Path.Combine(desktop, "test", "Dancing_Resized");
string videoName = "pos_030.avi";
*/
string workingDir = @"C:\Users\Paolo\Desktop\crowd_results\New folder";
string outDir = @"C:\Users\Paolo\Desktop\crowd_results";
int maxFrames = 1000;
string[] files = Directory.GetFiles(workingDir, "*.avi");
foreach (string f in files)
{
string filename = Path.GetFileName(f);
string outDirFile = Path.Combine(outDir, filename.Remove(filename.Length - 4));
if (!Directory.Exists(outDirFile))
Directory.CreateDirectory(outDirFile);
else
{
Console.WriteLine("Directory already exists! OVERWRITE?");
if ( Console.ReadKey().Key == ConsoleKey.Y)
{
Directory.Delete(outDirFile, true);
CvInvoke.cvWaitKey(100);
}
else
Environment.Exit(1);
}
Capture cap = new Capture(f);
string rootFile = Path.GetFileName(f);
rootFile = rootFile.Remove(rootFile.Length - 4);
int totFrames = (int)cap.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_COUNT);
if (totFrames > maxFrames && maxFrames != 0)
totFrames = maxFrames;
Console.WriteLine("FILE {0}: {1} frames", rootFile, totFrames);
StreamWriter sw1 = new StreamWriter(Path.Combine(outDirFile, "imageList.txt"));
for (int frameNumber = 1; frameNumber < totFrames; frameNumber++)
{
IMG currentFrame = cap.QueryFrame();
if (currentFrame == null)
continue;
string fileOut = string.Format("{0}_{1}.jpg", rootFile, frameNumber.ToString("D8"));
currentFrame.Save(Path.Combine(outDirFile, fileOut));
sw1.Write(fileOut + '\n');
if (frameNumber % 100 == 0)
Console.WriteLine("Frame {0} written...", frameNumber);
}
sw1.Dispose();
}
}
示例6: CameraBL
public CameraBL()
{
try
{
// check if all libraries were loaded
if (DependencyCheck.Execute())
{
// init grabber
this.grabber = new Capture();
// get current height and width
this.FrameWidth = grabber.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH);
this.FrameHeight = grabber.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT);
}
}
catch (NullReferenceException)
{
this.IsCameraAvailable = false;
}
}
示例7: CatchImages
//filename: Catch image from video file
//ms: Capture every ms. ms = 0 means capture all frames. (24 frames per second)
public List<string> CatchImages(string fileName, int ms, string outputPath)
{
_log.Debug("Start to capture");
if (string.IsNullOrWhiteSpace(fileName) || string.IsNullOrWhiteSpace(outputPath))
{
_log.Error("Cannot catch images from path: " + fileName + " and output to: " + outputPath);
}
//List<Image<Bgr, Byte>> imageList = new List<Image<Bgr, Byte>>();
List<string> imagePath = new List<string>();
Capture capture = new Capture(fileName);
double frameCount = capture.GetCaptureProperty(CapProp.FrameCount);
capture.Dispose();
int index = 0;
int fc = (int)frameCount;
Mat mat = null;
try
{
//TODO: Modified this to change period of capture image.
while (index < 30/*fc*/)
{
index++;
using (capture = new Capture(fileName))
{
capture.SetCaptureProperty(CapProp.PosFrames, (double)index);
using (mat = capture.QueryFrame())
{
string indexStr = index < 10 ? "0" + index : index.ToString();
string imgPath = outputPath + "\\" + indexStr;
if (!Directory.Exists(outputPath))
{
Directory.CreateDirectory(outputPath);
}
//long quality = 60;
//saveJpeg(imgPath, mat.Bitmap, quality);
string grayImgName = saveGrayAndThreshold(imgPath, mat.Bitmap);
if (!string.IsNullOrEmpty(grayImgName))
{
imagePath.Add(grayImgName);
}
}
}
}
}
catch (System.Exception ex)
{
_log.Error("Exception:", ex);
}
return imagePath;
}
示例8: SalmonCounter
public SalmonCounter()
{
InitializeComponent();
_capture = new Capture(videoOne);
counter = new Counter(_capture.Width);
bImage = new BlobImage();
fgDetector = new ForegroundDetector(bImage);
sTracker = new SalmonTracker(bImage, counter);
watch = new Stopwatch();
time = new TimeSpan();
FPS = (int)_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
frameCount = (int)_capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
pictureBox1.Width = _capture.Width;
pictureBox1.Height = _capture.Height;
show.Width = _capture.Width;
show.Height = _capture.Height;
//msec between frames
msec = (int)(1000 / FPS);
//set the event handler
_capture.ImageGrabbed += grabImage;
_capture.Start();
watch.Start();
_frame = new Mat();
//Start foregroundSegmenter tread and salmon tracker thread
backgroundSubtractorThread = new Thread(fgDetector.detect);
backgroundSubtractorThread.Start();
sTrackerThread = new Thread(sTracker.updateSalmons);
sTrackerThread.Start();
}
示例9: faceTrack
public faceTrack()
{
InitializeComponent();
CvInvoke.UseOpenCL = false;
_cascadeClassifierFace = new CascadeClassifier(Application.StartupPath + "/haarcascade_frontalface_default.xml");
_cascadeClassifierEye = new CascadeClassifier(Application.StartupPath + "/haarcascade_eye.xml");
try
{
capturecam = new Capture(0);
capturecam.SetCaptureProperty(CapProp.Fps, 30);
capturecam.SetCaptureProperty(CapProp.FrameHeight, 240);
capturecam.SetCaptureProperty(CapProp.FrameWidth, 320);
capturecam.SetCaptureProperty(CapProp.AutoExposure, 1);
trackBarUpdate(trackBarContrast, (int)capturecam.GetCaptureProperty(CapProp.Contrast));
trackBarUpdate(trackBarBrightness, (int)capturecam.GetCaptureProperty(CapProp.Brightness));
//trackBarUpdate(trackBarGain, (int)capturecam.GetCaptureProperty(CapProp.Gain));
trackBarUpdate(trackBarZoom, (int)capturecam.GetCaptureProperty(CapProp.Zoom));
textBoxTime.Text = "Time: ";
textBoxCodec.Text = "Codec: ";
textBoxFrameRate.Text = "Frame: ";
capturecam.ImageGrabbed += ProcessFrame;
//Application.Idle += ProcessFrame;
//original.Image = capturecam.QueryFrame();
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
示例10: ClickCameraButton
private void ClickCameraButton(object sender, EventArgs e)
{
ClearTimer();
try
{
_capture = new Capture(0);
double fps = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS);
_cameraTimer.Interval = Convert.ToInt16(1);
_cameraTimer.Tick += TickCameraTimer;
_cameraTimer.Start();
}
catch (Exception)
{
MessageBox.Show("無法找到攝影機,請確定是否有連接");
}
}
示例11: Form1
public Form1()
{
InitializeComponent();
markedPoints = new Dictionary<string, Point[]>();
try
{
capture = new Capture("kinect_local_rgb_raw_synced.avi");
capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.PosFrames, currentFrame);
pictureBox.Image = capture.QueryFrame().Bitmap;
frameCount = (int) capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
} catch ( Exception e)
{
Console.WriteLine(e);
}
}
示例12: InitVideoCapture
public void InitVideoCapture(string path)
{
try
{
m_FrameMat = new Mat();
m_VideoCaptureFilename = path;
m_VideoCaptureInterface = null;
m_VideoCaptureInterface = new Capture(m_VideoCaptureFilename);
m_VideoCaptureInterface.SetCaptureProperty(CapProp.FrameHeight, 640);
m_VideoCaptureInterface.SetCaptureProperty(CapProp.FrameWidth, 360);
m_VideoCaptureInterface.SetCaptureProperty(CapProp.Fps, 5);
m_VideoCaptureInterface.ImageGrabbed += VideoCaptureInterface_ImageGrabbed;
m_VideoCaptureFrameCount = (int)m_VideoCaptureInterface.GetCaptureProperty(CapProp.FrameCount);
m_VideoCaptureInterface.Start();
}
catch (Exception e)
{
}
}
示例13: frameProcessing
private void frameProcessing()
{
_capture = new Capture(_file);
totalFrameCount = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
_capture.ImageGrabbed += ProcessFrame;
}
示例14: SetFile
public void SetFile(string filePath)
{
if (capture != null)
capture.Dispose();
capture = new Capture(filePath);
nextFrame = capture.QueryFrame();
if (nextFrame != null)
isDirty = true;
this.VideoSize = new Size2((int)capture.GetCaptureProperty( Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH),
(int)capture.GetCaptureProperty( Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT));
#if false
Image<Bgr, byte> img = capture.QueryFrame();
img = capture.QueryFrame();
ImageViewer viewer = new ImageViewer();
viewer.Image = img;
viewer.ShowDialog();
#endif
}
示例15: SetupCapture
private void SetupCapture(int Camera_Identifier)
{
//update the selected device
CameraDevice = Camera_Identifier;
//Dispose of Capture if it was created before
if (_capture != null) _capture.Dispose();
try
{
//Set up capture device
_capture = new Capture(CameraDevice);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS, Int16.Parse(fpstext.Text));
if (resolution.SelectedIndex == 0)
{
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 480);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 640);
}
if (resolution.SelectedIndex == 1)
{
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 1000);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 2000);
}
selectedWidth= _capture.Width;
selectedHeight = _capture.Height;
selectedfps = Convert.ToInt16(_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS));
// _capture.ImageGrabbed += ProcessFrame;
}
catch (NullReferenceException excpt)
{MessageBox.Show(excpt.Message);}
}