Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/build for macos #25

Merged

Conversation

SergeyAME
Copy link
Contributor

Fix for issue #22 .
Now you can build a project for the OS X (CPU version).

  • Added target for OS X.
  • Fixed problems with resolution of WebCamTexture.

@homuler homuler self-requested a review November 28, 2020 04:25
private bool IsWebCamTextureInitialized()
{
//At least on OSX, at the beginning webCamTexture always has 16x16 size. So we must wait, until size will be correct
return webCamTexture.width > TEXTURE_SIZE_THRESHOLD;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to check whether the size is set correctly.

return webCamTexture.width == DefaultWidth && webCamTexture.height == DefaultHeight;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that it will be work in all cases. For example when you request DefaultWidth = 480, webCamTexture return 640 (at least at OS X). If you request DefaultWidth = 640, it return 640.

p.s. also code will crash in that point and other, if requested resolution is not supported (for example i request full HD, but my web cam support only HD. I think it doesn't matter at current moment, because as i understand you completely change the way like SDK will work with webCamTexture and pixels.

Copy link
Owner

@homuler homuler Dec 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example when you request DefaultWidth = 480, webCamTexture return 640 (at least at OS X). If you request DefaultWidth = 640, it return 640.

Yes, because the actual value is set in each .unity file (those values are overwritten).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, that real value come from .unity file, and values from code will be overwritten :) I'm talking about the values that WebCamTexture returns at runtime after we have passed our values (overwritten by .unity) to the WebCamTexture constructor.

Look at the screen, that was done from debug view in studio.
Screenshot 2020-12-01 at 13 29 13

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Now I see.
Hmm...certainly it looks that the value cannot be predicted (https://docs.unity3d.com/ScriptReference/WebCamTexture-requestedHeight.html).

Will you change the comment like this? (if you use MacBook pro).
In fact, I'm not sure if it is OS X's problem (the camera may causes the issue).

// Some cameras may take time to be initialized, so wait here. (e.g. on MacBook Pro, the size of webCamTexture is 16x16 at the beginning.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think problem are more common. I came across several topics where people are faced with getting the correct dimensions for the texture. Just for example:
https://answers.unity.com/questions/232168/how-can-i-get-the-device-camera-aspect-ratio.html?_ga=2.132976206.1384449721.1606825289-1204939603.1605516746
https://answers.unity.com/questions/773464/webcamtexture-correct-resolution-and-ratio.html#answer-1148424

You don't have that problem on your device?
Of course i can change comment, but i don't sure that it will be right :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think problem are more common.

I completely agree with you. That's why I would not like to particularly refer to OS X here.

You don't have that problem on your device?

Well, not yet for better or worse.

Copy link
Owner

@homuler homuler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants