Register    Login    Forum    Search    FAQ

Board index » Software » Windows




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post Posted: Thu May 11, 2017 2:45 pm 
Offline

Joined: Thu May 11, 2017 2:36 pm
Posts: 4
Hi,

How do I show the video captured by the zwo camera on a picturebox in Visual Studio 2015 ?

Code:
                 if (ASICameraDll.GetVideoData(0, ImageBuf, size, 0))
                {
                    outputBox.Items.Add("Successful");
                    byte[] dataByte = null;
                    if (imageType == ASICameraDll.ASI_IMG_TYPE.ASI_IMG_RAW16)
                        size *= 2;

                    dataByte = new byte[size];
                    Marshal.Copy(ImageBuf, dataByte, 0, size);

                    pictureBox.Image = xxx;// what do i put here so that i am able to show the video out?

                }


Apart from that, when I run the code, it doesn't seem to be running into this loop, is there anyone who can advise me??

Thanks


Top 
 Profile  
Reply with quote  
 Post Posted: Fri May 12, 2017 1:05 am 
Offline
Site Admin

Joined: Fri Jul 25, 2014 2:43 am
Posts: 175
I'm not clear about C# image diaplay, when I have time I'll create a C# demo. currently please refer to our c/c++ demo contained in our SDK package.

_________________
ZWO software engineer
Location:lon=120.6 lat=31.3
SuZhou China


Top 
 Profile  
Reply with quote  
 Post Posted: Tue May 16, 2017 6:58 am 
Offline

Joined: Thu May 11, 2017 2:36 pm
Posts: 4
Ohh.. by any chance, do you know how to convert (by casting, or is there other methods) the camera's image into system.drawing.image? :/


Top 
 Profile  
Reply with quote  
 Post Posted: Wed May 17, 2017 12:54 am 
Offline
Site Admin

Joined: Fri Jul 25, 2014 2:43 am
Posts: 175
You can do like below to display a image array, but Format8bppIndexed seems not correct, you should modify somewhere to make image looks normal.
int bufferSize = Height * Width;
byte[] buffer = new Byte[bufferSize];
IntPtr dataPtr = Marshal.AllocHGlobal(bufferSize);
if (GetVideoData(dataPtr, bufferSize, 0))
{
Marshal.Copy(dataPtr, buffer, 0, bufferSize);
int columns = Width;
int rows = Height;
int stride = columns;
Bitmap im = new Bitmap(columns, rows, stride, PixelFormat.Format8bppIndexed, Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0));
Bitmap resized = new Bitmap(im, new Size(pictureBox.Width, pictureBox.Height));
pictureBox.Image = resized;
}
Marshal.FreeHGlobal(dataPtr);

_________________
ZWO software engineer
Location:lon=120.6 lat=31.3
SuZhou China


Top 
 Profile  
Reply with quote  
 Post Posted: Fri May 19, 2017 2:41 pm 
Offline

Joined: Thu May 11, 2017 2:36 pm
Posts: 4
thank you!!

now i have a little problem with the image displayed. currently the image displayed is a still picture, i need to press a button for it to reload. however, i require the picturebox to show a live stream of the camera. do you have any idea on how i can do it?


Top 
 Profile  
Reply with quote  
 Post Posted: Mon May 22, 2017 8:47 am 
Offline

Joined: Mon Mar 27, 2017 11:47 am
Posts: 15
Hi limeye,

To get a live stream, you need put this segment of Yang's code into a loop.

yang wrote:
if (GetVideoData(dataPtr, bufferSize, 0))
{
Marshal.Copy(dataPtr, buffer, 0, bufferSize);
int columns = Width;
int rows = Height;
int stride = columns;
Bitmap im = new Bitmap(columns, rows, stride, PixelFormat.Format8bppIndexed, Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0));
Bitmap resized = new Bitmap(im, new Size(pictureBox.Width, pictureBox.Height));
pictureBox.Image = resized;
}


So the logic is, once you have read a frame from memory and rendered it on screen you read the next frame and render it.

Best regards,

Evren


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 6 posts ] 

Board index » Software » Windows


Who is online

Users browsing this forum: Bing [Bot] and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: