AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Aforge player missing it's aspect ratio when rotate 90 degre

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

Aforge player missing it's aspect ratio when rotate 90 degre

Postby DSZ » Wed May 15, 2019 10:39 am

I want to play aforge player by rotating the frame 90 degree. When trying like below, the aspect ratio of frame is seems missing.

Code: Select all
 

            this.videoSourcePlayer3.BackColor = System.Drawing.SystemColors.ControlDark;
            this.videoSourcePlayer3.ForeColor = System.Drawing.Color.White;
            this.videoSourcePlayer3.Location = new System.Drawing.Point(8, 51);
            this.videoSourcePlayer3.Margin = new System.Windows.Forms.Padding(0);
            this.videoSourcePlayer3.Name = "videoSourcePlayer3";
            this.videoSourcePlayer3.Size = new System.Drawing.Size(400, 225);
            this.videoSourcePlayer3.TabIndex = 0;
            this.videoSourcePlayer3.VideoSource = null;

        private void videoSourcePlayer3_NewFrame(object sender, ref Bitmap image)
        {
       
                //image.RotateFlip(RotateFlipType.RotateNoneFlipY);//working fine
               //  image.RotateFlip(RotateFlipType.Rotate180FlipX);//working fine
                 image.RotateFlip(RotateFlipType.Rotate90FlipY);

        }


RotateFlip other than 90 and 270 degrees are working fine. How can I resolve this?
Attachments
a_flip90left.PNG
Lose aspect ratio when flip with 90 degree.
a_flip90left.PNG (217.59 KiB) Viewed 85 times
a_NoflipNoRotate.PNG
Normal frame
a_NoflipNoRotate.PNG (222.5 KiB) Viewed 86 times
Last edited by DSZ on Thu May 16, 2019 3:22 am, edited 2 times in total.
DSZ
 
Posts: 13
Joined: Mon Feb 25, 2019 7:06 am

Re: Aforge player missing it's aspect ratio when rotate 90 d

Postby andrew.kirillov » Wed May 15, 2019 1:19 pm

DSZ wrote:When trying like below, the aspect ratio of frame is seems missing.

So what does happen then?

Doing RotateFlip( RotateFlipType.Rotate90FlipY ) swaps Width/Height of an image as it is rotated 90 degrees. So the rest of the code should work same as if the image came like that from video source.

Here is where aspect ratio logic is callculated.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3395
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Aforge player missing it's aspect ratio when rotate 90 d

Postby DSZ » Thu May 16, 2019 3:23 am

Please see my attachments.. Seems frame is stretched when rotate with 90 degree. Can I make it aspect fit?
DSZ
 
Posts: 13
Joined: Mon Feb 25, 2019 7:06 am

Re: Aforge player missing it's aspect ratio when rotate 90 d

Postby andrew.kirillov » Thu May 16, 2019 7:45 am

Just did a test on my side - works fine without issues. Make sure AutoSizeControl property is set to false and KeepAspectRatio to true.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3395
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Aforge player missing it's aspect ratio when rotate 90 d

Postby DSZ » Thu May 16, 2019 8:11 am

AutoSizeControl property is already set as false . But where to set KeepAspectRatio to true?.
DSZ
 
Posts: 13
Joined: Mon Feb 25, 2019 7:06 am

Re: Aforge player missing it's aspect ratio when rotate 90 d

Postby andrew.kirillov » Thu May 16, 2019 9:58 am

DSZ wrote:But where to set KeepAspectRatio to true?

I did it using Property Browser, when designing Main windows. But equally can be done manually in constructor of the form.

vsp.png
vsp.png (2.36 KiB) Viewed 65 times
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3395
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Aforge player missing it's aspect ratio when rotate 90 d

Postby DSZ » Thu May 16, 2019 10:33 am

In my visual studio I can only see AutosizeControl and bordercolor only. there is no keepaspectratio property on videoplayer.
How can I set it in constructor?
DSZ
 
Posts: 13
Joined: Mon Feb 25, 2019 7:06 am

Re: Aforge player missing it's aspect ratio when rotate 90 d

Postby andrew.kirillov » Thu May 16, 2019 12:03 pm

Code: Select all
this.videoSourcePlayer3.KeepAspectRatio = true;


Or maybe you simply have older version of the control.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3395
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Aforge player missing it's aspect ratio when rotate 90 d

Postby DSZ » Fri May 17, 2019 4:26 am

it shows
VideoSourcePlayer' does not contain a definition for 'KeepAspectRatio' and no extension method 'KeepAspectRatio' accepting a first argument of type 'VideoSourcePlayer' could be found (are you missing a using directive or an assembly reference?)
DSZ
 
Posts: 13
Joined: Mon Feb 25, 2019 7:06 am

Re: Aforge player missing it's aspect ratio when rotate 90 d

Postby andrew.kirillov » Fri May 17, 2019 7:46 am

Get the fresh code from GitHub then.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3395
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to AForge.NET Framework