Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

BBatts

@BBatts
About
Posts
14
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • DShow.Net Problem With Opening Camera
    B BBatts

    I know it's unnecessary -- it's just an old habit. Certainly not what's causing my problem though.

    C# help csharp data-structures

  • DShow.Net Problem With Opening Camera
    B BBatts

    OK. It tells me parameter is incorrect. That's the exception thrown. Which leads to believe the one of my two IBaseFilters isn't being released. But I don't see where or how.

    C# help csharp data-structures

  • DShow.Net Problem With Opening Camera
    B BBatts

    Thanks for replying. capGraph.RenderStreamdoesn't throw an exception, but it returns -2147024809

    C# help csharp data-structures

  • DShow.Net Problem With Opening Camera
    B BBatts

    Hello. I'm streaming a webcam using DirectShow. I can open the camera fine on a windows form once. But, If I close the camera and then try to reopen it my code fails on the RenderStream line. Once I restart my application everything is fine again. I'm quite certain I'm freeing everything up, but i'm stumped. Any help would be GREATLY appreciated.

    Guid cat = PinCategory.Capture;
    Guid med = MediaType.Video;

        private IBaseFilter sourceBase;
        private IGraphBuilder graph;
        private ICaptureGraphBuilder2 capGraph;
        private ISampleGrabber sg;
        private IMediaControl mc;
        private IBaseFilter grabberBase;
        private VideoInfoHeader videoInfoHeader;
    
        private const int WM\_GRAPHNOTIFY = 0x00008001;
        private const int WS\_CHILD = 0x40000000;
        private const int WS\_CLIPCHILDREN = 0x02000000;
        private const int WS\_CLIPSIBLINGS = 0x04000000;
    
        private int frameWidth = 320;
        private int frameHeight = 240;
    
    public bool Start(string SystemID)
        {          
            using (DsDevice camDevice = GetDeviceFromMon(SystemID))
            {
                if (camDevice != null)
                {
                    object comObj = null;
                    Guid gbf = typeof(IBaseFilter).GUID;
                    Guid clsid = Clsid.CaptureGraphBuilder2;
                    Guid riid = typeof(ICaptureGraphBuilder2).GUID;
    
                    AMMediaType media = new AMMediaType();
                    media.majorType = MediaType.Video;
                    media.subType = MediaSubType.RGB24;
                    media.formatType = FormatType.VideoInfo;
                  
                    //Create Source
                    camDevice.Mon.BindToObject(null, null, ref gbf, out comObj);
                    sourceBase = (IBaseFilter)comObj; comObj = null;
    
                    //Create Graph
                    comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.FilterGraph));
                    graph = (IGraphBuilder)comObj; comObj = null;
    
                    //Create Capture Graph
                    comObj = DsBugWO.CreateDsInstance(ref clsid, ref riid);
                    capGraph = (ICaptureGraphBuilder2)comObj; comObj = null;
    
                    //Create Grabber
                    comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.SampleGrabber));
                    sg = (ISampleGrabber)comObj; comObj = null;
    
    C# help csharp data-structures

  • Execution of query??
    B BBatts

    You can't have the "'" in Guardian's Name. What database are you using?

    C# database help question

  • Working with Bitmaps
    B BBatts

    Hello, I'm collecting bitmaps from a camera like below:

    private void LPRCamera2_OnNewFrame(object sender, ref Bitmap NewFrame)
    {
    while (LPR2List.Count >= LowCamSettings.LPR2FrameCount)
    {
    LPR2List[0].Dispose();
    LPR2List.RemoveAt(0);
    }

            if (lpr2FrameIndex >= LowCamSettings.LPR2SkipCount)
            {
                LPR2List.Add(new Bitmap(NewFrame));   //List object
                lpr2FrameIndex = 0;
            }
            else if (LowCamSettings.LPR2SkipCount > 0)
                lpr2FrameIndex++;
        }
    

    I then take the list (LPR2List) and pass it to a new object that copies the list to a local variable. Like so:

                for (int i = 0; i < LPR2List.Count; i++)
                {
                    if (LPR2List\[i\] != null)
                        this.Plate2List.Add((Bitmap)LPR2List\[i\].Clone());  //Error Line
                }
    

    Every now and then i'm getting an error when copying telling me that the object is in use. I haven't the slightest clue what I could be doing wrong. Any help would be greatly appreciated.

    C# help graphics

  • How do i take the text from Form2.textbox and paste it into Form1.textbox?
    B BBatts

    That's it, but it's not very elegant. You can use properties to return the value of visual objects. Like so. There is no reason to create that form and leave it in memory. It better to use it and then destroy it as soon as you're done.

    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

            private void button1\_Click(object sender, EventArgs e)
            {
                using (Form2 f2 = new Form2())
                {
                    f2.ShowDialog();
                    //f2.Show(); //this doesn't work because ShowDialog is required to stop the process and wait for input, show to show the form and moves on
                    label1.Text = f2.TextValue;
                }
            }
        }
        
        public partial class Form2 : Form
        {
            public string TextValue
            {
                get { return textBox1.Text; }
                set { textBox1.Text = value; }
            }
    
            public string LabelValue
            {
                get { return label1.Text; }
                set { label1.Text = value; }
            }
    
            public Form2() 
            { 
                InitializeComponent(); 
            }
        }
    
    C# question tutorial

  • Parameterized Queries
    B BBatts

    Got one you would recommended?

    C# csharp database visual-studio tutorial question

  • Parameterized Queries
    B BBatts

    Is there any benefit to adding BEGIN TRANSACTION; and COMMIT; to the beginning and end of a parameterized query in C#. Also, is there any real advantage to stored procedures vs parameterized queries? For Example:

    using (SqlConnection dbConnection = new SqlConnection(GSettings.SQLConnectionString))
    {
    dbConnection.Open();

                for (int i = 0; i < DBUpdateList.Count; i++)
                {
                    string selectSQL = "BEGIN TRANSACTION; UPDATE TABLE SET Dog = [@Dog](/Members/dog); COMMIT;";
    
                    using (SqlCommand dbCommand = new SqlCommand(selectSQL, dbConnection))
                    {
                        dbCommand.Parameters.AddWithValue("[@Dog](/Members/dog)", "Poodle");
                        dbCommand.ExecuteNonQuery();
                    }
                }
            }
    
    C# csharp database visual-studio tutorial question

  • Managing List<Bitmap>
    B BBatts

    Hello All, I have an application that frequently uses the general List object with an bitmap type". I have two questions concerning these. 1: What is the best way to copy the bitmaps from one list to another while ensuring the Bitmaps in the original list are unchanged if changes are made to the new list. Currently i'm doing it in a forloop such as:

    List aviList1 = new List(); aviList1.Clear();

    for (int i=0; I originalList.Count; i++)
    aviList1.Add(new Bitmap(originalList[i]));

    2: Is calling originalList.Clear sufficient to free up the memory or would it be necessary to loop through the list and dispose of the Bitmaps individually? Thanks in advance for the always great support here at CodeProject. Bryan

    C# question graphics performance lounge

  • Windows Service: Timer vs Thread
    B BBatts

    Thanks Nicholas, I've never seen it done that way!

    C# discussion visual-studio performance question

  • Windows Service: Timer vs Thread
    B BBatts

    Yes. It performs varies disk related services. Clean Up, Archive, Backup, etc etc. There can be up to 6 process running at the same time. I currently create and fire 6 System.Threads on the Start() event. Each thread has a loop that keeps it running with a Thread.Delay, so they look something like this:

    private void WorkerThread_DoWork()
    {
    while (contiueWorking)
    {
    //Perform Some Task

    System.Threading.Thread.Sleep(10000);
    

    }
    }

    The task may or may not take longer than 10 seconds to complete, depending on the amount of data that is being managed. So, my question is (and admittedly I'm stumbling trying to ask it) would it be better to have 6 timers in this situation or should I stick with the threads? Or am I simply overthinking it.

    C# discussion visual-studio performance question

  • Windows Service: Timer vs Thread
    B BBatts

    "When the timer fires it uses a thread." Yes. To be more specific a timer is an object the fires a thread periodically. "Huh? If the thread is running and not blocked then it is fact running" If the thread your timer has fired takes longer to execute than the interval level of a timer it will fire again. Unless, of course, you disable it. Where as if one is using a System.Thread there is more direct control over when and how the thread is fired. I can't think of any reason to use a Timer as opposed to System.Thread...in a windows service. I guess that was the point of my post.

    C# discussion visual-studio performance question

  • Windows Service: Timer vs Thread
    B BBatts

    Hello All, I was wanting to start a discussion about best practice when creating threads in a Windows Service. I have a service that has multiple process running at the same time (6-10). Is it better to use timers or threads? I personally prefer threads because I can end them all with a single line of code where as if have to end each timer individually. Plus with threads, you don't have to worry about it calling it self until you want it to. Does anybody have any other thoughts on this? What's a better way to go and why? Which is lighter on PC usage and memory? etc etc Thanks in advance, Bryan

    C# discussion visual-studio performance question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups