xxxxxxxxxx
77
let img; // SSD-1B用
let img_background; // 背景用
let pointX = [];
let pointY = []
function setup() {
createCanvas(800, 600);
img_background = loadImage('background.jpg');
// // Your PAT (Personal Access Token) can be found in the portal under Authentification
// const PAT = "a7e02f595d6f4c37b51772da52e18f0e";
// // Specify the correct user_id/app_id pairings
// // Since you're making inferences outside your app's scope
// const USER_ID = "segmind";
// const APP_ID = "segmind-stable-diffusion";
// // Change these to whatever model and text you want to use
// const MODEL_ID = "ssd-1b";
// const MODEL_VERSION_ID = "5cc1a784916a402eac8b8f51391ed15b";
// const RAW_TEXT = "Parrot wearing sunglasses.";
// const raw = JSON.stringify({
// inputs: [
// {
// data: {
// text: {
// raw: RAW_TEXT,
// // "url": TEXT_FILE_URL
// },
// },
// },
// ],
// });
// const requestOptions = {
// method: "POST",
// headers: {
// Accept: "application/json",
// Authorization: "Key " + PAT,
// },
// body: raw,
// };
// fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/models/ssd-1b/versions/${MODEL_VERSION_ID}/outputs`,
// requestOptions
// )
// .then((response) => response.json())
// .then((result) => {
// const imageBase64 = result.outputs[0].data.image.base64;
// // Create an anchor element for downloading the image
// img = loadImage(`data:image/jpeg;base64,${imageBase64}`);
// console.log("done")
// })
// .catch((error) => console.log("error", error));
background(220);
}
function draw() {
image(img_background, 0, 0, 800, 600)
for(i = 0;i < pointX.length;i++){
circle(pointX[i], pointY[i], 20);
}
// if(typeof img != undefined){
// image(img,0,0, img.width / 2, img.height / 2);
// }
}
function mouseClicked(){
pointX.push(mouseX);
pointY.push(mouseY);
}