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
H

Herboren

@Herboren
About
Posts
110
Topics
44
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Having an issue accessing a bitmap region from two different threads.
    H Herboren

    Turns out it was as simple as creating a public void PreviewImageUpdate() outside of the bg worker

    private void t_processFrame_Tick(object sender, EventArgs e) {
    // UpdateMotionDetectionPreviiw();
    if (!_bw_frameProcessor.IsBusy) {
    _bw_frameProcessor.RunWorkerAsync();
    }
    }

    private void _bw_frameProcessor_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    _bw_frameProcessor.Dispose();
    }

    private void _bw_frameProcessor_DoWork(object sender, DoWorkEventArgs e) {
    UpdateMotionDetectionPreview();
    }

    public void UpdateMotionDetectionPreview() {
    try {
    GetImage = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
    g = Graphics.FromImage(GetImage);
    g.CopyFromScreen(screen.Bounds.X, 0, 0, 0, GetImage.Size);

    if (motionDetector.ProcessFrame(GetImage) > 1.02 f)
      pbDesktopFeed.Image = GetImage;
    else
      pbDesktopFeed.Image = GetImage;
    

    } catch (Exception ex) {}
    }

    However, I do plan to take consideration in using a ScreenCaptureScreen() to relay this image to AForge video player to improve the over performance of the framerate since the PB update is too slow.

    C# graphics help tutorial

  • Having an issue accessing a bitmap region from two different threads.
    H Herboren

    I can't for the life of me figure out how to access the region from a tick thread which is calling a bgworker(). Here is the original code

    private void t_processFrame_Tick(object sender, EventArgs e)
    {
    if (!_bw_frameProcessor.IsBusy)
    {
    _bw_frameProcessor.RunWorkerAsync();
    }
    }

    private void _bw_frameProcessor_DoWork(object sender, DoWorkEventArgs e)
    {
    try
    {
    GetImage = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
    g = Graphics.FromImage(GetImage);
    g.CopyFromScreen(screen.Bounds.X, 0, 0, 0, GetImage.Size);

        pbDesktopFeed.Image = (Bitmap)GetImage;                           
        motionDetector.ProcessFrame((Bitmap)pbDesktopFeed.Image);
    }
    catch (Exception ex) { }
    

    }

    Its kind of frustrating because I have been sitting here for 3 days (I have a high tolerance of trying different variations before I burn myself out) trying to figure out why it works fine in Timer_Tick but not when Timer) Tick is running the Backgroundworker. My guess is that it is because of the Threads between the both. I have tried cloning the bitmap inside the background worker

    GetImage = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
    Bitmap clone = (Bitmap) GetImage.Clone()
    g = Graphics.FromImage(clone);
    g.CopyFromScreen(screen.Bounds.X, 0, 0, 0, clone.Size);
    pbDesktopFeed.Image = (Bitmap)GetImage;
    motionDetector.ProcessFrame((Bitmap)pbDesktopFeed.Image);

    I have tried cloning the image using AForge:

    GetImage = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
    g = Graphics.FromImage(GetImage );
    g.CopyFromScreen(screen.Bounds.X, 0, 0, 0, GetImage .Size);
    pbDesktopFeed.Image = (Bitmap)GetImage;
    motionDetector.ProcessFrame(AForge.Imaging.Image.Clone((Bitmap)pbDesktopFeed.Image));

    This however, works fine when I drop it all into the Timer_Tick event.

    private void t_processFrame_Tick(object sender, EventArgs e)
    {
    try
    {
    GetImage = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
    g = Graphics.FromImage(GetImage);
    g.CopyFromScreen(screen.Bounds.X, 0, 0, 0, GetImage.Size);

        pbDesktopFeed.Image = (Bitmap)GetImage;
        motionDetector.ProcessFrame((Bitmap)pbDesktopFeed.Image);
    }
    catch (Exception ex) { }
    

    }

    C# graphics help tutorial

  • AForge Motion Detection from PictureBox?
    H Herboren

    I've found a potential solution in replicating what I am looking for by using Accord VideoFileWrite to write the sequence of frames that bitmap creates, using the PictureBox as a "previewer" to show the height/width of what is being recorded. Is it possible to write VideoFileWrite into a memorystream and use AForges motion detection to read the memorystream or a buffer within the specific moment , rather than the read a file thats been written to the computer. Example Illustration

    C# question

  • AForge Motion Detection from PictureBox?
    H Herboren

    "Okaaay" like you understand my request? Or "Okaaay" like you're being a pompous-dick right now? I mean, I'll understand if you don't know the answer to the question, it's OK to not know everything. But, if you don't know, save me the ridicule and move on, your forum-troll level of insecurity is not required in this thread. Not everyone who comes in here is on your level, in fact majority of the people that come in here are have some level of knowledge in IT that doesn't equate to your standard of knowledge. That is why I am here, either help or don't help. Had you in fact read the thread, you would know that nothing of a 'still image' was mentioned, after all Videos are just layered images. Since my picturebox is technically showing a video of my desktop, rather than using Video File Writer is it possible to put these layers into a MemoryStream read it from there?

    C# question

  • AForge Motion Detection from PictureBox?
    H Herboren

    Correct, so in theory it could work since the picturebox is being replaced with a new layer/frame ever second that timer draws a new bitmap image? I have a picture box that draws the recording of my desktop

    private void tmrImageUpdate_Tick(object sender, EventArgs e)
    {

            var img = new Bitmap(this.Height, this.Width);
            var grph = Graphics.FromImage(img);
            grph.CopyFromScreen((Cursor.Position.X-(pbImageRelay.Height/2)),(Cursor.Position.Y-(pbImageRelay.Width / 2)), 0, 0, img.Size);
            pbImageRelay.Image = img;
        }
    
        private void Form1\_Load(object sender, EventArgs e)
        {
            Rectangle resolution = Screen.PrimaryScreen.Bounds;
    
            tmrImageUpdate.Tick += tmrImageUpdate\_Tick;
            tmrImageUpdate.Enabled = true;
            tmrImageUpdate.Start();
        }
    

    I am trying to detect the motion in say a video player from the desktop, but within the picture box that is viewing on my desktop. Like a picture in a picture on a TV screen, except on PC.

    C# question

  • AForge Motion Detection from PictureBox?
    H Herboren

    Is it possible to detect motion from a picture box? I was looking at AForge for the motion detection class, but because the picture box is not exactly a video source, and currently what I have draws an image when a timer ticks every say 100ms to the box. Could it be possible to detect motion from the picture box? Or convert the realtime images drawn in a picture box to a video source for Realtime processing of motion?

    C# question

  • ComboBoxItem in another Form
    H Herboren

    The Form is a container for controls, so you cannot access it directly from another form/class especially when controls have private modifiers. Using access modifiers may still cause some issues. Its better to access the control using Controls class.

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

        private void btnStart\_Click(object sender, EventArgs e)
        {
            comboBox1.Items.Add("Combo Item");
        }
    }
    
    public class GetComboItem
    {
        public GetComboItem()
        {
            ComboBox cmbItm = Application.OpenForms\["Form1"\].**Controls**.Find("comboBox1", true)\[0\] as ComboBox;            
            MessageBox.Show(cmbItm.Text);
        }
    }
    
    C# help

  • How would I go about adding a shortcut to the notification menu
    H Herboren

    No it's cool, I think you read my message too fast before I could edit it, I would have loved to target the 444 but it only works on the 412

    Android android visual-studio

  • How would I go about adding a shortcut to the notification menu
    H Herboren

    Really no target, but if any case, I will be using 4.1.2. But the app targets most mobile droids. But that screen is accessed from a mobile from swiping from the top edge down.

    Android android visual-studio

  • How would I go about adding a shortcut to the notification menu
    H Herboren

    For example, the red bpi shortcut and the utorrent shortcut, I'm trying to replication that function but can't seem to find any content how to add those to the notification menu.

    Android android visual-studio

  • How would I go about adding a shortcut to the notification menu
    H Herboren

    Like this image here: http://bit.ly/1AQOJB8[^] I can't seem to find any material online related to the topic. I am using Android studio as my ide.

    Android android visual-studio

  • Slow Ping and not guaranteed success
    H Herboren

    Knowing I dont have the admin access what would be the viable method without seeming I am a threat to any system. If ICMP isnt going to work then how else would I go about converting the hostname into an IP using the best methods?

    Visual Basic csharp com sysadmin hosting

  • Slow Ping and not guaranteed success
    H Herboren

    I managed to figure out why, my next question is, why is my code not returning the IP and saying the site site is in active, and also when it returns an IP I type that IP in the browser and it doesn't take me to the domain that its assigned to. why? I guess I could see this as a security prevention but how do I get the right IP from it?

    Visual Basic csharp com sysadmin hosting

  • Slow Ping and not guaranteed success
    H Herboren

    I work for an ISP strictly for small business and minimal residential. We provide different services as well as web hosting. We have to convert web domains to an IP once a month from a list. I am trying to recreate an app in VB.net and it takes forever for ping result to come back as true or flase and when I transl;ate the host into an IP it doesnt get an IP for the host even though it exists. Here is a sample picture of my compiled app running: http://postimg.com/87000/what-86552.jpg[^] my code in vb.net:

    Imports System
    Imports System.Net
    Imports System.IO

    Public Class Form1
    Dim reachable As Boolean = False
    Dim IPEntry As IPHostEntry
    Dim ReadAllLinesArray() As String

    Public Function IsDestinationRechable(ByVal hostOrAddress As String)
        Try
            reachable = My.Computer.Network.Ping(hostOrAddress)
        Catch pingException As System.Net.NetworkInformation.PingException
        Catch genericNetworkException As System.Net.NetworkInformation.NetworkInformationException
            'Fail silently and return false
        End Try
        Return reachable
    End Function
    
    Public Sub GetPingAndIPv4()
        Try
    
            For Each s As String In ReadAllLinesArray
                Try
                    IPEntry = Dns.GetHostByName(s)
                    If IsDestinationRechable(IPEntry.AddressList(0).ToString) = True Then
                        Dim lsv As ListViewItem = lsvHostItemList.Items.Add(s)
                        lsv.SubItems.Add(IPEntry.AddressList(0).ToString)
                        lsv.SubItems.Add(IsDestinationRechable(reachable))
                       
                        tssProgressBar.PerformStep()
                    Else
                        Dim lsv As ListViewItem = lsvHostItemList.Items.Add(s)
                        lsv.SubItems.Add("n/a")
                        lsv.SubItems.Add(IsDestinationRechable(reachable))
                        tssProgressBar.PerformStep()
                    End If
                Catch ex As Exception
                End Try
            Next
    
        Catch ex As Exception
    
        End Try
    End Sub
    
    Private Sub OpenToolStripMenuItem\_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click
        If OpenOldHostsFile.ShowDialog = Windows.Forms.DialogResult.OK Then
    
    Visual Basic csharp com sysadmin hosting

  • Working from scratch based on created application
    H Herboren

    I have a teacher who gave us a compiled application. He did not provide us the code. We have to generate the code in our head and write it out. It must act like his application in every possible way. I have it written out but for some reason when I type in the value of two(2) pieces the two(2) isn't calculated yet every other number I type calculates just fine. Why? two(2) falls within range of 1-199 so its price would be calculated as rangeA * two(2) pieces = price for two, but no result is returned, my text does not display in the textbox either.

    Dim priceArrayElements(20) As Decimal ' Store Prices calculated, 21 count
    Dim pieceArrayElements(20) As Integer ' Store Pieces counted, 21 count

    Dim addedPieces ' Total of all Piece elements added together
    Dim totalAveragePieces ' Average of Piece elements added together / element count
    
    Dim addedPrices As Decimal ' Total of all price elements added together
    Dim totalAveragePrices As Decimal ' Average of Price elements added together / element count
    
    Dim elementCounter As Decimal ' Global Counter for both arrays
    
    Dim rangeA As Decimal = 0.5  ' Price applies to range   1 - 199
    Dim rangeB As Decimal = 0.55 ' Price applies to range 200 - 399
    Dim rangeC As Decimal = 0.6  ' Price applies to range 400 - 599
    Dim rangeD As Decimal = 0.65 ' Price applies to range 600 - >
    
    Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Select Case False
            Case IsNumeric(txtPieces.Text)
                MessageBox.Show("Pieces completed must be numeric.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtPieces.Text = ""
    
            Case Not IsNumeric(txtName.Text)
                MessageBox.Show("Name is required.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtName.Text = ""
    
            Case Else
    
                Select Case txtPieces.Text
                    Case 1 To 199
                        Try
                            For i As Integer = 0 To priceArrayElements.Length
                                priceArrayElements(i) = (Decimal.Parse(txtPieces.Text) \* rangeA)
                                txtEarned.Text = FormatCurrency(priceArrayElements(i).ToString())
                            Next
                        Catch ex As Exception
                            'Supress Message
                        End Try
    
    Visual Basic help question

  • Settings not saving correctly.
    H Herboren

    I have a a multi-purpose application that I am working with. 3 Different forms, one form has log in validation and the another has DateTimePickers. I threw a button on the parent form just to compare saved settings, when I set a Time in DTP say for 11:30 PM and the close that form and go back to the parent form, the DTP Value that I saved doesn't actually get saved till I close my application and re-open it, so I can't compare my alarm times unless I close the application and re-open it. How can I get the form to refresh to the most updated variable that is being stored in my settings?

    C# question

  • Addrange Listview
    H Herboren

    I am trying to add a range of arrays to al istview from 3 files. My arrays are decalred as:

    string[] sn = File.ReadAllLines("serverList.txt");
    string[] sl = File.ReadAllLines("serverLocation.txt");
    string[] st = File.ReadAllLines("serverType.txt");

    But when I use:

    ListViewItem lvi = new ListViewItem();
    lvi = lv.Items.AddRange(sn);
    lvi.SubItems.AddRange(sl);
    lvi.SubItems.AddRange(st);

    Its tells me the addrange taked invalid arguments, why?

    C# question

  • Array List to Application Settings.
    H Herboren

    I have created an array list to save my listview settings but cannot seem to figure out how to save it to an a preset setting in my properties. This is what I have so far.

    List list;
    private void Form1_FormClosed(object sender, FormClosedEventArgs e)
    {
    list = new List();
    foreach (ListViewItem lvi in lv.Items)
    {
    string[] values = new string[] { lvi.Text, lvi.SubItems[1].Text, lvi.SubItems[2].Text, lvi.SubItems[3].Text };
    list.Add(values);

            }
        }
    
    C# data-structures tutorial

  • Reading from a ListBox
    H Herboren

    lv.SelectedItems[0].ToString() Dont forget to specify the position of the columns using [0] even if you only have one columns the [0] is still used. Then so on if you have more than one columns [1],[2] etc

    modified on Tuesday, August 23, 2011 12:35 PM

    C#

  • IE Trickery [modified]
    H Herboren

    I think I may have sort of found a solution or work around. I could use a webBrowser control in a form that redirects only to that site and then when it checks the 'FEATURE_NATIVE_DOCUMENT_MODE' then it would load the IE7 standards mode by checking the value of ' MyApplication.exe"=dword:11170" ' This is the only thing I could think of after reading the http://blogs.msdn.com/b/ie/archive/2008/03/18/webbrowser-control-rendering-modes-in-ie8.aspx[^]

    C# question announcement
  • Login

  • Don't have an account? Register

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